Browse Source

[edit] keyword

wenliming 2 years ago
parent
commit
c125e584b1
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/logic/content/keywordReminder.js

+ 6 - 2
src/logic/content/keywordReminder.js

@@ -43,7 +43,7 @@ export const keywordReminderInit = () => {
 export const listenerKeywordInput = debounce(function() {
 export const listenerKeywordInput = debounce(function() {
   let inputBox = getInputBox();
   let inputBox = getInputBox();
   if(inputBox) {
   if(inputBox) {
-    inputBox.oninput = function () {
+    inputBox.onkeyup = function () {
         highlightKeyword();
         highlightKeyword();
     }
     }
   }
   }
@@ -67,6 +67,7 @@ export const highlightKeyword = () => {
             if(checkHasTag({keyword, startPos, endPos, rowIndex: j})) {
             if(checkHasTag({keyword, startPos, endPos, rowIndex: j})) {
               continue;
               continue;
             }
             }
+            removeTag({rowIndex: j, keyword})
 
 
             lastRange = window.getSelection().getRangeAt(0)
             lastRange = window.getSelection().getRangeAt(0)
 
 
@@ -98,12 +99,15 @@ export const highlightKeyword = () => {
             let top = rectDom.top - inputBoxRect.top + 2;
             let top = rectDom.top - inputBoxRect.top + 2;
 
 
             let cssText = `left: ${left}px;top: ${top}px;width: ${rectDom.width}px;height: ${rectDom.height}px;`;
             let cssText = `left: ${left}px;top: ${top}px;width: ${rectDom.width}px;height: ${rectDom.height}px;`;
-            addHighlightDom({cssText, rowIndex: j, keyword})
+            addHighlightDom({cssText, rowIndex: j, keyword});
           } else {
           } else {
             removeTag({rowIndex: j, keyword})
             removeTag({rowIndex: j, keyword})
           }
           }
         }
         }
       }
       }
+    } else {
+      document.getElementById("denet-keword-highlight-wrapper").innerHTML = '';
+      tagData = [];
     }
     }
   }
   }
 }
 }