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/14548
Vanessa9729b72a9e63
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.tsindex ca40c1f224..f5f9be5724 100644--- a/app/src/protyle/header/Background.ts+++ b/app/src/protyle/header/Background.ts@@ -419,11 +419,15 @@ export class Background {});}- private removeTag(protyle: IProtyle) {+ private removeTag(protyle: IProtyle, cb?: () => void) {const tags = this.getTags();fetchPost("/api/attr/setBlockAttrs", {id: protyle.block.rootID,attrs: {"tags": tags.toString()}+ }, () => {+ if (cb) {+ cb();+ }});if (tags.length === 0) {delete this.ial.tags;@@ -540,13 +544,10 @@ export class Background {upDownHint(listElement, event);if (event.key === "Enter") {const currentElement = listElement.querySelector(".b3-list-item--focus");- if (currentElement) {- this.addTags(currentElement.textContent.trim(), protyle);- } else {- this.addTags(inputElement.value.trim(), protyle);- }- inputElement.value = "";- inputElement.dispatchEvent(new CustomEvent("input"));+ this.addTags(currentElement ? currentElement.textContent.trim() : inputElement.value.trim(), protyle, () => {+ inputElement.value = "";+ inputElement.dispatchEvent(new CustomEvent("input"));+ });} else if (event.key === "Escape") {window.siyuan.menus.menu.remove();}@@ -554,7 +555,7 @@ export class Background {inputElement.addEventListener("input", (event) => {event.stopPropagation();fetchPost("/api/search/searchTag", {- k: inputElement.value,+ k: inputElement.value.trim(),}, (response) => {let searchHTML = "";let hasKey = false;@@ -569,7 +570,7 @@ export class Background {}});if (!hasKey && response.data.k) {- searchHTML = `<div class="b3-list-item b3-list-item--narrow${searchHTML ? "" : " b3-list-item--focus"}"><div class="fn__flex-1">${window.siyuan.languages.new} <mark>${escapeHtml(response.data.k)}</mark></div></div>` + searchHTML;+ searchHTML = `<div data-type="new" class="b3-list-item b3-list-item--narrow${searchHTML ? "" : " b3-list-item--focus"}"><div class="fn__flex-1">${window.siyuan.languages.new} <mark>${escapeHtml(response.data.k)}</mark></div></div>` + searchHTML;}listElement.innerHTML = searchHTML;});@@ -580,8 +581,11 @@ export class Background {if (!listItemElement) {return;}- this.addTags(listItemElement.textContent.trim(), protyle);- inputElement.dispatchEvent(new CustomEvent("input"));+ this.addTags(listItemElement.dataset.type === "new" ? listItemElement.querySelector("mark").textContent.trim() : listItemElement.textContent.trim(),+ protyle, () => {+ inputElement.value = "";+ inputElement.dispatchEvent(new CustomEvent("input"));+ });});}});@@ -609,16 +613,18 @@ export class Background {return tags;}- private addTags(tag: string, protyle: IProtyle) {+ private addTags(tag: string, protyle: IProtyle, cb: () => void) {const tags = this.getTags(tag);if (tags.includes(tag)) {- this.removeTag(protyle);+ this.removeTag(protyle, cb);return;}tags.push(tag);fetchPost("/api/attr/setBlockAttrs", {id: protyle.block.rootID,attrs: {"tags": tags.toString()}+ }, () => {+ cb();});this.ial.tags = tags.toString();this.render(this.ial, protyle.block.rootID);