An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/16011
Vanessa130dd32801bd
diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex 7e24e2d6dd..06de392dde 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -90,8 +90,8 @@ export class Protyle {if (isSupportCSSHL()) {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-highlight-background);color: var(--b3-highlight-color);}- .protyle-wysiwyg::highlight(search-mark-hl-${styleId}) {color: var(--b3-highlight-color);background-color: var(--b3-highlight-current-background)}`;+ this.protyle.highlight.styleElement.textContent = `.protyle-content::highlight(search-mark-${styleId}) {background-color: var(--b3-highlight-background);color: var(--b3-highlight-color);}+ .protyle-content::highlight(search-mark-hl-${styleId}) {color: var(--b3-highlight-color);background-color: var(--b3-highlight-current-background)}`;}this.protyle.hint = new Hint(this.protyle);diff --git a/app/src/protyle/render/searchMarkRender.ts b/app/src/protyle/render/searchMarkRender.tsindex 84207eaa7b..1cab32c6f6 100644--- a/app/src/protyle/render/searchMarkRender.ts+++ b/app/src/protyle/render/searchMarkRender.ts@@ -8,6 +8,7 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], hlId?: strinsetTimeout(() => {protyle.highlight.markHL.clear();protyle.highlight.mark.clear();+ protyle.highlight.rangeIndex = 0;protyle.highlight.ranges = [];let isSetHL = false;let hlBlockElement: Element;@@ -20,12 +21,16 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], hlId?: strin});}+ if (!hlBlockElement && hlId === protyle.block.rootID && protyle.title && !protyle.title.element.classList.contains("fn__none")) {+ hlBlockElement = protyle.title.element;+ }+// 准备一个数组来保存所有文本节点const textNodes: Node[] = [];const textNodesSize: number[] = [];let currentSize = 0;- const treeWalker = document.createTreeWalker(protyle.wysiwyg.element, NodeFilter.SHOW_TEXT);+ const treeWalker = document.createTreeWalker(protyle.contentElement, NodeFilter.SHOW_TEXT);let currentNode = treeWalker.nextNode();while (currentNode) {textNodes.push(currentNode);@@ -34,7 +39,7 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], hlId?: strincurrentNode = treeWalker.nextNode();}- const text = protyle.wysiwyg.element.textContent;+ const text = protyle.contentElement.textContent;const rangeIndexes: { range: Range, startIndex: number, isCurrent: boolean }[] = [];if (keys && keys.length > 0) {keys.forEach(key => {diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 50d0ea2da3..cc7a6e8938 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -1123,6 +1123,7 @@ export const getArticle = (options: {const contentRect = options.edit.protyle.contentElement.getBoundingClientRect();if (isSupportCSSHL()) {+ let observer:ResizeObserver;searchMarkRender(options.edit.protyle, getResponse.data.keywords, options.id, () => {const highlightKeys = () => {const currentRange = options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex];@@ -1136,8 +1137,11 @@ export const getArticle = (options: {highlightById(options.edit.protyle, options.id);}};+ if (observer) {+ observer.disconnect();+ }highlightKeys();- const observer = new ResizeObserver(() => {+ observer = new ResizeObserver(() => {highlightKeys();});observer.observe(options.edit.protyle.wysiwyg.element);