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/13843
Vanessac3342935d64b
diff --git a/app/src/protyle/render/searchMarkRender.ts b/app/src/protyle/render/searchMarkRender.tsindex c17fd76c17..45676d0018 100644--- a/app/src/protyle/render/searchMarkRender.ts+++ b/app/src/protyle/render/searchMarkRender.ts@@ -20,7 +20,6 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], hlId?: strin});}-// 准备一个数组来保存所有文本节点const textNodes: Node[] = [];const textNodesSize: number[] = [];@@ -75,6 +74,20 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], hlId?: strin}});+ // 没有匹配到关键字,但是有高亮块时,需将其添加进去+ if (!isSetHL && hlBlockElement) {+ const startIndex = text.indexOf(hlBlockElement.textContent);+ if (startIndex > -1) {+ const range = new Range();+ let currentNodeIndex = 0;+ while (textNodes.length && textNodesSize[currentNodeIndex] <= startIndex) {+ currentNodeIndex++;+ }+ range.setStart(textNodes[currentNodeIndex], 0);+ rangeIndexes.push({range, startIndex, isCurrent: true});+ }+ }+rangeIndexes.sort((b, a) => {if (a.startIndex > b.startIndex) {return -1;diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex 9b9cdb2ed1..193abeccc4 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -1019,17 +1019,21 @@ const renderNextSearchMark = (options: {if (options.edit.protyle.highlight.rangeIndex >= options.edit.protyle.highlight.ranges.length) {options.edit.protyle.highlight.rangeIndex = 0;}- let rangeTop;+ let currentRange: Range;options.edit.protyle.highlight.ranges.forEach((item, index) => {if (options.edit.protyle.highlight.rangeIndex === index) {options.edit.protyle.highlight.markHL.add(item);- rangeTop = item.getBoundingClientRect().top;+ currentRange = item} else {options.edit.protyle.highlight.mark.add(item);}});- if (typeof rangeTop === "number") {- options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + rangeTop - contentRect.top - contentRect.height / 2;+ if (currentRange) {+ if (!currentRange.toString()) {+ highlightById(options.edit.protyle, options.id);+ } else {+ options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + currentRange.getBoundingClientRect().top - contentRect.top - contentRect.height / 2;+ }}return;}@@ -1102,8 +1106,7 @@ export const getArticle = (options: {if (isSupportCSSHL()) {searchMarkRender(options.edit.protyle, getResponse.data.keywords, options.id, () => {if (options.edit.protyle.highlight.ranges.length > 0 && options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex]) {- const blockElement = hasClosestBlock(options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].startContainer);- if (blockElement && blockElement.getAttribute("data-node-id") !== options.id) {+ if (!options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].toString()) {highlightById(options.edit.protyle, options.id);} else {options.edit.protyle.contentElement.scrollTop = options.edit.protyle.contentElement.scrollTop + options.edit.protyle.highlight.ranges[options.edit.protyle.highlight.rangeIndex].getBoundingClientRect().top - contentRect.top - contentRect.height / 2;