mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
20bc84c542
commit
70c369e435
1 changed files with 11 additions and 9 deletions
|
|
@ -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");
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue