This commit is contained in:
parent
847c27957f
commit
9f463fec1e
1 changed files with 8 additions and 4 deletions
|
@ -2,6 +2,7 @@ import {addScript} from "../util/addScript";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {focusByOffset} from "../util/selection";
|
import {focusByOffset} from "../util/selection";
|
||||||
import {setCodeTheme} from "../../util/assets";
|
import {setCodeTheme} from "../../util/assets";
|
||||||
|
import {hasClosestByClassName} from "../util/hasClosest";
|
||||||
|
|
||||||
export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
|
export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
|
||||||
let codeElements: NodeListOf<Element>;
|
let codeElements: NodeListOf<Element>;
|
||||||
|
@ -98,10 +99,13 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
|
||||||
languageElement.style.marginLeft = "";
|
languageElement.style.marginLeft = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const matchElement = block.querySelector('span[data-type="search-mark"]');
|
// 搜索定位
|
||||||
if (matchElement) {
|
const layoutElement = hasClosestByClassName(block, "search__layout", true)
|
||||||
// 搜索定位
|
if (layoutElement && block.parentElement.getAttribute("data-node-id") === layoutElement.querySelector("#searchList > .b3-list-item--focus")?.getAttribute("data-node-id")) {
|
||||||
matchElement.scrollIntoView();
|
const matchElement = block.querySelector('span[data-type="search-mark"]');
|
||||||
|
if (matchElement) {
|
||||||
|
matchElement.scrollIntoView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
block.innerHTML = hljs.highlight(
|
block.innerHTML = hljs.highlight(
|
||||||
block.textContent + (block.textContent.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609
|
block.textContent + (block.textContent.endsWith("\n") ? "" : "\n"), // https://github.com/siyuan-note/siyuan/issues/4609
|
||||||
|
|
Loading…
Add table
Reference in a new issue