瀏覽代碼

override selection colors with highlight colors

Gildas 5 年之前
父節點
當前提交
a7b56631f7
共有 2 個文件被更改,包括 12 次插入17 次删除
  1. 7 0
      extension/ui/content/content-ui-editor-web.js
  2. 5 17
      extension/ui/pages/editor-frame-web.css

+ 7 - 0
extension/ui/content/content-ui-editor-web.js

@@ -832,10 +832,17 @@ table {
 			document.querySelectorAll(NOTE_TAGNAME).forEach(noteElement => noteElement.shadowRoot.querySelector("." + NOTE_CLASS).classList.add(NOTE_HIDDEN_CLASS));
 		}
 		if (message.method == "enableHighlight") {
+			if (highlightColor) {
+				document.documentElement.classList.remove(highlightColor + "-mode");
+			}
 			highlightColor = message.color;
 			highlightSelectionMode = true;
+			document.documentElement.classList.add(message.color + "-mode");
 		}
 		if (message.method == "disableHighlight") {
+			if (highlightColor) {
+				document.documentElement.classList.remove(highlightColor + "-mode");
+			}
 			highlightSelectionMode = false;
 		}
 		if (message.method == "displayHighlights") {

+ 5 - 17
extension/ui/pages/editor-frame-web.css

@@ -1,36 +1,24 @@
-.single-file-highlight-yellow {
+.single-file-highlight-yellow, .single-file-highlight-yellow-mode ::selection {
     background-color: #ffff7c !important;
     color: black !important;
 }
 
-span.single-file-highlight-yellow {
-    display: inline !important;
-}
-
-.single-file-highlight-pink {
+.single-file-highlight-pink, .single-file-highlight-pink-mode ::selection {
     background-color: #ffbbb6 !important;
     color: black !important;
 }
 
-span.single-file-highlight-pink {
-    display: inline !important;
-}
-
-.single-file-highlight-blue {
+.single-file-highlight-blue, .single-file-highlight-blue-mode ::selection {
     background-color: #95d0ff !important;
     color: black !important;
 }
 
-span.single-file-highlight-blue {
-    display: inline !important;
-}
-
-.single-file-highlight-green {
+.single-file-highlight-green, .single-file-highlight-green-mode ::selection {
     background-color: #93ef8d !important;
     color: black !important;
 }
 
-span.single-file-highlight-green {
+span.single-file-highlight-yellow, span.single-file-highlight-pink, span.single-file-highlight-blue, span.single-file-highlight-green {
     display: inline !important;
 }