Skip to content

Commit

Permalink
🎨 #5520
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 22, 2022
1 parent 20bc84c commit 70c369e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/src/protyle/markdown/highlightRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
language = "plaintext";
}
block.classList.add("hljs");
// TODO 等待讨论是否需要渲染 if (!hasClosestByAttribute(block, "id", "searchPreview", true) || isPreview) {
block.innerHTML = hljs.highlight(
block.textContent + (block.textContent.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609
{
language,
ignoreIllegals: true
}).value;
// }
block.setAttribute("data-render", "true");
const autoEnter = block.parentElement.getAttribute("linewrap");
const ligatures = block.parentElement.getAttribute("ligatures");
Expand Down Expand Up @@ -106,7 +98,17 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
languageElement.style.marginLeft = "";
}
}

const matchElement = block.querySelector('span[data-type="search-mark"]');
if (matchElement) {
// 搜索定位
matchElement.scrollIntoView();
}
block.innerHTML = hljs.highlight(
block.textContent + (block.textContent.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609
{
language,
ignoreIllegals: true
}).value;
if (wbrElement && getSelection().rangeCount > 0) {
focusByOffset(block, startIndex, startIndex);
}
Expand Down

0 comments on commit 70c369e

Please sign in to comment.