Bladeren bron

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

Vanessa 7 maanden geleden
bovenliggende
commit
5abdf08706

+ 4 - 0
app/src/history/history.ts

@@ -15,6 +15,7 @@ import {openModel} from "../mobile/menu/model";
 import {closeModel} from "../mobile/util/closePanel";
 import {App} from "../index";
 import {resizeSide} from "./resizeSide";
+import {searchMarkRender, searchTextMarkRender} from "../protyle/render/searchMarkRender";
 
 let historyEditor: Protyle;
 
@@ -694,12 +695,14 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
                 } else if (type === "doc") {
                     fetchPost("/api/history/getDocHistoryContent", {
                         historyPath: dataPath,
+                        highlight: CSS && CSS.highlights,
                         k: (firstPanelElement.querySelector(".b3-text-field") as HTMLInputElement).value
                     }, (response) => {
                         if (response.data.isLargeDoc) {
                             mdElement.value = response.data.content;
                             mdElement.classList.remove("fn__none");
                             docElement.classList.add("fn__none");
+                            searchTextMarkRender(mdElement,  []);
                         } else {
                             mdElement.classList.add("fn__none");
                             docElement.classList.remove("fn__none");
@@ -709,6 +712,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
                                 protyle: historyEditor.protyle,
                                 action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],
                             });
+                            searchMarkRender(historyEditor.protyle,  historyEditor.protyle.wysiwyg.element.querySelectorAll('span[data-type~="search-mark"]'));
                         }
                     });
                 }

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

@@ -437,6 +437,7 @@ export class Backlink extends Model {
             fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
                 defID: this.blockId,
                 refTreeID: docId,
+                highlight: CSS && CSS.highlights,
                 keyword: isMention ? this.inputsElement[1].value : this.inputsElement[0].value,
             }, (response) => {
                 svgElement.removeAttribute("disabled");

+ 5 - 0
app/src/protyle/render/searchMarkRender.ts

@@ -27,3 +27,8 @@ export const searchMarkRender = (protyle: IProtyle, matchElements: NodeListOf<El
         CSS.highlights.set("search-mark-hl-" + protyle.highlight.styleElement.dataset.uuid, protyle.highlight.markHL);
     }
 };
+
+
+export const searchTextMarkRender = (element: HTMLElement, k: string[]) => {
+
+}

+ 3 - 0
app/src/protyle/scroll/saveScroll.ts

@@ -73,6 +73,7 @@ export const getDocByScroll = (options: {
             query: options.protyle.query?.key,
             queryMethod: options.protyle.query?.method,
             queryTypes: options.protyle.query?.types,
+            highlight: CSS && CSS.highlights,
         }, response => {
             if (response.code === 1) {
                 fetchPost("/api/filetree/getDoc", {
@@ -80,6 +81,7 @@ export const getDocByScroll = (options: {
                     query: options.protyle.query?.key,
                     queryMethod: options.protyle.query?.method,
                     queryTypes: options.protyle.query?.types,
+                    highlight: CSS && CSS.highlights,
                 }, response => {
                     onGet({
                         data: response,
@@ -111,6 +113,7 @@ export const getDocByScroll = (options: {
         query: options.protyle.query?.key,
         queryMethod: options.protyle.query?.method,
         queryTypes: options.protyle.query?.types,
+        highlight: CSS && CSS.highlights,
     }, response => {
         onGet({
             data: response,

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

@@ -40,6 +40,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
             fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
                 defID: protyle.element.getAttribute("data-defid"),
                 refTreeID: protyle.block.rootID,
+                highlight: CSS && CSS.highlights,
                 keyword: isMention ? inputsElement[1].value : inputsElement[0].value,
             }, response => {
                 protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks;

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

@@ -1221,6 +1221,7 @@ export const getArticle = (options: {
                 mode: zoomIn ? 0 : 3,
                 size: zoomIn ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,
                 zoom: zoomIn,
+                highlight: CSS && CSS.highlights,
             }, getResponse => {
                 options.edit.protyle.query = {
                     key: options.value || null,