mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-19 21:48:06 +01:00
This commit is contained in:
parent
3a53fd4a9a
commit
fdee19e703
6 changed files with 16 additions and 15 deletions
|
|
@ -77,9 +77,15 @@ export class Protyle {
|
|||
markHL: new Highlight(),
|
||||
ranges: [],
|
||||
rangeIndex: 0,
|
||||
styleElement: document.createElement("style"),
|
||||
}
|
||||
};
|
||||
|
||||
const styleId = genUUID();
|
||||
this.protyle.highlight.styleElement.dataset.uuid = styleId;
|
||||
this.protyle.highlight.styleElement.textContent = `.protyle-wysiwyg::highlight(search-mark-${styleId}) {background-color: var(--b3-protyle-inline-mark-background);color: var(--b3-protyle-inline-mark-color);}
|
||||
.protyle-wysiwyg::highlight(search-mark-hl-${styleId}) {background-color: var(--b3-theme-primary-lighter);box-shadow: 0 0 0 .5px var(--b3-theme-on-background);}`;
|
||||
|
||||
this.protyle.hint = new Hint(this.protyle);
|
||||
if (mergedOptions.render.breadcrumb) {
|
||||
this.protyle.breadcrumb = new Breadcrumb(this.protyle);
|
||||
|
|
|
|||
|
|
@ -15,13 +15,15 @@ export const searchMarkRender = (protyle: IProtyle, matchElements: NodeListOf<El
|
|||
item.setAttribute("data-type", item.getAttribute("data-type").replace(" search-mark", "").replace("search-mark ", ""));
|
||||
range.selectNodeContents(item);
|
||||
}
|
||||
if (index === protyle.highlight.rangeIndex) {
|
||||
if (index === protyle.highlight.rangeIndex && !protyle.options.backlinkData) {
|
||||
protyle.highlight.markHL.add(range);
|
||||
} else {
|
||||
protyle.highlight.mark.add(range);
|
||||
}
|
||||
protyle.highlight.ranges.push(range);
|
||||
});
|
||||
CSS.highlights.set("search-mark", protyle.highlight.mark);
|
||||
CSS.highlights.set("search-mark-hl", protyle.highlight.markHL);
|
||||
CSS.highlights.set("search-mark-" + protyle.highlight.styleElement.dataset.uuid, protyle.highlight.mark);
|
||||
if (!protyle.options.backlinkData) {
|
||||
CSS.highlights.set("search-mark-hl-" + protyle.highlight.styleElement.dataset.uuid, protyle.highlight.markHL);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ export const initUI = (protyle: IProtyle) => {
|
|||
protyle.element.appendChild(protyle.toolbar.element);
|
||||
protyle.element.appendChild(protyle.toolbar.subElement);
|
||||
|
||||
protyle.element.append(protyle.highlight.styleElement);
|
||||
|
||||
addLoading(protyle);
|
||||
|
||||
setEditMode(protyle, protyle.options.mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue