From 27ec03d938d31cbce23d2e84e091aa5e435051f1 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 24 Jun 2022 15:26:10 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5279 --- app/src/assets/scss/_search.scss | 1 + app/src/protyle/markdown/highlightRender.ts | 1 + app/src/search/index.ts | 2 +- app/src/search/spread.ts | 9 ++++++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/assets/scss/_search.scss b/app/src/assets/scss/_search.scss index 554709697..9746aa0db 100644 --- a/app/src/assets/scss/_search.scss +++ b/app/src/assets/scss/_search.scss @@ -24,6 +24,7 @@ overflow: auto; top: 48px; position: absolute; + left: 8px; } } diff --git a/app/src/protyle/markdown/highlightRender.ts b/app/src/protyle/markdown/highlightRender.ts index a957d57f5..bf70a8a49 100644 --- a/app/src/protyle/markdown/highlightRender.ts +++ b/app/src/protyle/markdown/highlightRender.ts @@ -63,6 +63,7 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) = if (!hljs.getLanguage(language)) { language = "plaintext"; } + block.classList.add("hljs"); block.innerHTML = hljs.highlight( block.textContent + (block.textContent.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609 { diff --git a/app/src/search/index.ts b/app/src/search/index.ts index d679877e2..c6c2e2f6a 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -192,7 +192,7 @@ export class Search extends Model { const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHETABDATA) || "[]"); data.forEach((s: string) => { if (s !== inputElement.value) { - html += `
${s}
`; + html += `
${escapeHtml(s)}
`; } }); historyElement.classList.remove("fn__none"); diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index 8de480d4c..c40731b44 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -110,7 +110,10 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
- + + + + @@ -325,7 +328,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri let html = ""; (localData.list || []).forEach((s: string) => { if (s !== searchInputElement.value) { - html += `
${s}
`; + html += `
${escapeHtml(s)}
`; } }); historyElement.classList.remove("fn__none"); @@ -343,7 +346,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri let html = ""; (localData.replaceList || []).forEach((s: string) => { if (s !== replaceInputElement.value) { - html += `
${s}
`; + html += `
${escapeHtml(s)}
`; } }); replaceHistoryElement.classList.remove("fn__none");