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/17143
Vanessaae173db74ed4
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex e92ea669b3..a91dbf8e71 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -1449,8 +1449,7 @@ export class Toolbar {focusByRange(this.range);}});- inputElement.addEventListener("input", (event) => {- event.stopPropagation();+ const genList = () => {fetchPost("/api/search/searchTemplate", {k: inputElement.value,}, (response) => {@@ -1468,13 +1467,33 @@ export class Toolbar {</span></div>`;});listElement.innerHTML = searchHTML || `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;- const currentPath = response.data.blocks[0]?.path;- if (previewPath === currentPath) {++ if (!previewPath) {+ previewPath = response.data.blocks[0]?.path;+ /// #if !MOBILE+ const rangePosition = getSelectionPosition(nodeElement, range);+ setPosition(this.subElement, rangePosition.left, rangePosition.top + 18, Constants.SIZE_TOOLBAR_HEIGHT);+ (this.subElement.firstElementChild as HTMLElement).style.maxHeight = Math.min(window.innerHeight * 0.8, window.innerHeight - this.subElement.getBoundingClientRect().top) - 16 + "px";+ /// #else+ setPosition(this.subElement, 0, 0);+ /// #endif+ } else if (response.data.blocks[0]?.path === previewPath) {return;+ } else {+ previewPath = response.data.blocks[0]?.path;}- previewPath = currentPath;previewTemplate(previewPath, previewElement, protyle.block.parentID);});+ };+ inputElement.addEventListener("compositionend", () => {+ genList();+ });+ inputElement.addEventListener("input", (event: KeyboardEvent) => {+ event.stopPropagation();+ if (event.isComposing) {+ return;+ }+ genList();});this.subElement.lastElementChild.addEventListener("click", (event) => {const target = event.target as HTMLElement;@@ -1539,33 +1558,7 @@ export class Toolbar {this.subElementCloseCB = undefined;this.element.classList.add("fn__none");inputElement.select();- fetchPost("/api/search/searchTemplate", {- k: "",- }, (response) => {- let html = "";- response.data.blocks.forEach((item: { path: string, content: string }, index: number) => {- html += `<div data-value="${item.path}" class="b3-list-item--hide-action b3-list-item${index === 0 ? " b3-list-item--focus" : ""}">-<span class="b3-list-item__text">${item.content}</span>`;- /// #if !BROWSER- html += `<span data-type="open" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.showInFolder}">- <svg><use xlink:href="#iconFolder"></use></svg>-</span>`;- /// #endif- html += `<span data-type="remove" class="b3-list-item__action b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.remove}">- <svg><use xlink:href="#iconTrashcan"></use></svg>-</span></div>`;- });- this.subElement.querySelector(".b3-list--background").innerHTML = html || `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;- /// #if !MOBILE- const rangePosition = getSelectionPosition(nodeElement, range);- setPosition(this.subElement, rangePosition.left, rangePosition.top + 18, Constants.SIZE_TOOLBAR_HEIGHT);- (this.subElement.firstElementChild as HTMLElement).style.maxHeight = Math.min(window.innerHeight * 0.8, window.innerHeight - this.subElement.getBoundingClientRect().top) - 16 + "px";- /// #else- setPosition(this.subElement, 0, 0);- /// #endif- previewPath = listElement.firstElementChild.getAttribute("data-value");- previewTemplate(previewPath, previewElement, protyle.block.parentID);- });+ genList();}public showWidget(protyle: IProtyle, nodeElement: HTMLElement, range: Range) {@@ -1595,8 +1588,7 @@ export class Toolbar {focusByRange(this.range);}});- inputElement.addEventListener("input", (event) => {- event.stopPropagation();+ const genList = (init = false) => {fetchPost("/api/search/searchWidget", {k: inputElement.value,}, (response) => {@@ -1608,7 +1600,25 @@ export class Toolbar {</div>`;});listElement.innerHTML = searchHTML;+ if (init) {+ /// #if !MOBILE+ const rangePosition = getSelectionPosition(nodeElement, range);+ setPosition(this.subElement, rangePosition.left, rangePosition.top + 18, Constants.SIZE_TOOLBAR_HEIGHT);+ /// #else+ setPosition(this.subElement, 0, 0);+ /// #endif+ }});+ };+ inputElement.addEventListener("compositionend", () => {+ genList();+ });+ inputElement.addEventListener("input", (event: KeyboardEvent) => {+ event.stopPropagation();+ if (event.isComposing) {+ return;+ }+ genList();});this.subElement.lastElementChild.addEventListener("click", (event) => {const target = event.target as HTMLElement;@@ -1623,24 +1633,7 @@ export class Toolbar {this.subElementCloseCB = undefined;this.element.classList.add("fn__none");inputElement.select();- fetchPost("/api/search/searchWidget", {- k: "",- }, (response) => {- let html = "";- response.data.blocks.forEach((item: { content: string, name: string }, index: number) => {- html += `<div class="b3-list-item${index === 0 ? " b3-list-item--focus" : ""}" data-content="${item.content}">-${item.name}-<span class="b3-list-item__meta">${item.content}</span>-</div>`;- });- this.subElement.querySelector(".b3-list--background").innerHTML = html;- /// #if !MOBILE- const rangePosition = getSelectionPosition(nodeElement, range);- setPosition(this.subElement, rangePosition.left, rangePosition.top + 18, Constants.SIZE_TOOLBAR_HEIGHT);- /// #else- setPosition(this.subElement, 0, 0);- /// #endif- });+ genList(true);}public showContent(protyle: IProtyle, range: Range, nodeElement: Element) {