فهرست منبع

made code compatible with Chrome

Gildas 7 سال پیش
والد
کامیت
105aaef78b
1فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 12 0
      extension/ui/content/content-ui.js

+ 12 - 0
extension/ui/content/content-ui.js

@@ -215,6 +215,7 @@ this.singlefile.ui = this.singlefile.ui || (() => {
 					contentSelected = true;
 					const range = document.createRange();
 					range.selectNodeContents(selectedElement);
+					cleanupSelectionRanges();
 					getSelection().addRange(range);
 					if (!multiSelect) {
 						cleanupAndResolve();
@@ -224,6 +225,17 @@ this.singlefile.ui = this.singlefile.ui || (() => {
 				}
 			}
 
+			function cleanupSelectionRanges() {
+				const selection = getSelection();
+				for (let indexRange = selection.rangeCount - 1; indexRange >= 0; indexRange--) {
+					const range = selection.getRangeAt(indexRange);
+					if (range.startOffset == range.endOffset) {
+						selection.removeRange(range);
+						indexRange--;
+					}
+				}
+			}
+
 			function cleanupAndResolve() {
 				getAreaSelector().remove();
 				removeEventListener("mousemove", mousemoveListener, true);