From 04806ea4b98b67646d4086487f516068e8ed2983 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 7 Dec 2024 11:07:42 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/13343 --- app/src/history/history.ts | 6 +++--- app/src/layout/dock/Backlink.ts | 2 +- app/src/protyle/render/searchMarkRender.ts | 4 +++- app/src/protyle/scroll/saveScroll.ts | 6 +++--- app/src/protyle/util/reload.ts | 2 +- app/src/search/util.ts | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/history/history.ts b/app/src/history/history.ts index 07acd9d3a..9a0605108 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -695,14 +695,14 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => { } else if (type === "doc") { fetchPost("/api/history/getDocHistoryContent", { historyPath: dataPath, - highlight: CSS && CSS.highlights, + highlight: CSS && CSS.highlights ? true : false, 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, []); + searchTextMarkRender(mdElement, []); } else { mdElement.classList.add("fn__none"); docElement.classList.remove("fn__none"); @@ -712,7 +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"]')); + searchMarkRender(historyEditor.protyle, historyEditor.protyle.wysiwyg.element.querySelectorAll('span[data-type~="search-mark"]')); } }); } diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts index 536e85f60..6ca2288ca 100644 --- a/app/src/layout/dock/Backlink.ts +++ b/app/src/layout/dock/Backlink.ts @@ -437,7 +437,7 @@ export class Backlink extends Model { fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", { defID: this.blockId, refTreeID: docId, - highlight: CSS && CSS.highlights, + highlight: CSS && CSS.highlights ? true : false, keyword: isMention ? this.inputsElement[1].value : this.inputsElement[0].value, }, (response) => { svgElement.removeAttribute("disabled"); diff --git a/app/src/protyle/render/searchMarkRender.ts b/app/src/protyle/render/searchMarkRender.ts index ad966278a..c9c527da2 100644 --- a/app/src/protyle/render/searchMarkRender.ts +++ b/app/src/protyle/render/searchMarkRender.ts @@ -30,5 +30,7 @@ export const searchMarkRender = (protyle: IProtyle, matchElements: NodeListOf { - + if (!CSS || !CSS.highlights) { + return; + } } diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.ts index ac1c1177c..f06761c69 100644 --- a/app/src/protyle/scroll/saveScroll.ts +++ b/app/src/protyle/scroll/saveScroll.ts @@ -73,7 +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, + highlight: CSS && CSS.highlights ? true : false, }, response => { if (response.code === 1) { fetchPost("/api/filetree/getDoc", { @@ -81,7 +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, + highlight: CSS && CSS.highlights ? true : false, }, response => { onGet({ data: response, @@ -113,7 +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, + highlight: CSS && CSS.highlights ? true : false, }, response => { onGet({ data: response, diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.ts index 852601a38..1e0ecdf73 100644 --- a/app/src/protyle/util/reload.ts +++ b/app/src/protyle/util/reload.ts @@ -40,7 +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, + highlight: CSS && CSS.highlights ? true : false, keyword: isMention ? inputsElement[1].value : inputsElement[0].value, }, response => { protyle.options.backlinkData = isMention ? response.data.backmentions : response.data.backlinks; diff --git a/app/src/search/util.ts b/app/src/search/util.ts index e23ce2909..e64d0beaf 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -1221,7 +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, + highlight:CSS && CSS.highlights ? true : false, }, getResponse => { options.edit.protyle.query = { key: options.value || null,