Parcourir la source

:art: https://github.com/siyuan-note/siyuan/issues/13178

Vanessa il y a 7 mois
Parent
commit
c315fce720
3 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 2 0
      app/src/layout/dock/Backlink.ts
  2. 1 0
      app/src/protyle/util/reload.ts
  3. 3 0
      app/src/search/util.ts

+ 2 - 0
app/src/layout/dock/Backlink.ts

@@ -10,6 +10,7 @@ import {openFileById} from "../../editor/util";
 import {Protyle} from "../../protyle";
 import {Protyle} from "../../protyle";
 import {MenuItem} from "../../menus/Menu";
 import {MenuItem} from "../../menus/Menu";
 import {App} from "../../index";
 import {App} from "../../index";
+import {highlightMark} from "../../search/util";
 
 
 export class Backlink extends Model {
 export class Backlink extends Model {
     public element: HTMLElement;
     public element: HTMLElement;
@@ -456,6 +457,7 @@ export class Backlink extends Model {
                     }
                     }
                 });
                 });
                 editor.protyle.notebookId = liElement.getAttribute("data-notebook-id");
                 editor.protyle.notebookId = liElement.getAttribute("data-notebook-id");
+                highlightMark(editor.protyle, editor.protyle.wysiwyg.element.querySelectorAll('span[data-type~="search-mark"]'));
                 this.editors.push(editor);
                 this.editors.push(editor);
             });
             });
         }
         }

+ 1 - 0
app/src/protyle/util/reload.ts

@@ -49,6 +49,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
             }, response => {
             }, response => {
                 protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks;
                 protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks;
                 renderBacklink(protyle, protyle.options.backlinkData);
                 renderBacklink(protyle, protyle.options.backlinkData);
+                highlightMark(protyle, protyle.wysiwyg.element.querySelectorAll('span[data-type~="search-mark"]'));
             });
             });
         }
         }
     } else {
     } else {

+ 3 - 0
app/src/search/util.ts

@@ -1504,6 +1504,9 @@ ${item.tag ? `<span class="b3-list-item__meta b3-list-item__meta--ellipsis">${it
 };
 };
 
 
 export const highlightMark = (protyle: IProtyle, matchElements: NodeListOf<Element>) => {
 export const highlightMark = (protyle: IProtyle, matchElements: NodeListOf<Element>) => {
+    if (matchElements.length === 0) {
+        return;
+    }
     protyle.highlight.markHL.clear();
     protyle.highlight.markHL.clear();
     protyle.highlight.markHL.clear();
     protyle.highlight.markHL.clear();
     protyle.highlight.ranges = [];
     protyle.highlight.ranges = [];