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/insider/issues/1088
Vanessad5931778cf39
diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.tsindex 9ab59c28c6..a606c4398a 100644--- a/app/src/layout/dock/Backlink.ts+++ b/app/src/layout/dock/Backlink.ts@@ -306,7 +306,7 @@ export class Backlink extends Model {const clickEvent = (currentSort: string) => {(type === "sort" ? this.tree : this.mTree).element.previousElementSibling.querySelector(`[data-type="${type}"]`).setAttribute("data-sort", currentSort);this.searchBacklinks();- }+ };window.siyuan.menus.menu.remove();window.siyuan.menus.menu.append(new MenuItem({icon: sort === "0" ? "iconSelect" : undefined,@@ -314,57 +314,57 @@ export class Backlink extends Model {click: () => {clickEvent("0");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "1" ? "iconSelect" : undefined,label: window.siyuan.languages.fileNameDESC,click: () => {clickEvent("1");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "4" ? "iconSelect" : undefined,label: window.siyuan.languages.fileNameNatASC,click: () => {clickEvent("4");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "5" ? "iconSelect" : undefined,label: window.siyuan.languages.fileNameNatDESC,click: () => {clickEvent("5");}- }).element)- window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element)+ }).element);+ window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "9" ? "iconSelect" : undefined,label: window.siyuan.languages.createdASC,click: () => {clickEvent("9");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "10" ? "iconSelect" : undefined,label: window.siyuan.languages.createdDESC,click: () => {clickEvent("10");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "2" ? "iconSelect" : undefined,label: window.siyuan.languages.modifiedASC,click: () => {clickEvent("2");}- }).element)+ }).element);window.siyuan.menus.menu.append(new MenuItem({icon: sort === "3" ? "iconSelect" : undefined,label: window.siyuan.languages.modifiedDESC,click: () => {clickEvent("3");}- }).element)+ }).element);}private toggleItem(liElement: HTMLElement, isMention: boolean) {@@ -443,13 +443,13 @@ export class Backlink extends Model {backlinkOpenIds: [],backlinkMOpenIds: [],backlinkMStatus: 3 // 0 全展开,1 展开一半箭头向下,2 展开一半箭头向上,3 全收起- }+ };this.tree.element.querySelectorAll(".b3-list-item__arrow--open").forEach(item => {- this.status[this.blockId].backlinkOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"))- })+ this.status[this.blockId].backlinkOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"));+ });this.mTree.element.querySelectorAll(".b3-list-item__arrow--open").forEach(item => {- this.status[this.blockId].backlinkMOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"))- })+ this.status[this.blockId].backlinkMOpenIds.push(item.parentElement.parentElement.getAttribute("data-node-id"));+ });if (this.mTree.element.style.flex) {if (this.mTree.element.style.height === "0px") {this.status[this.blockId].backlinkMStatus = 3;@@ -513,15 +513,15 @@ export class Backlink extends Model {backlinkOpenIds: [],backlinkMOpenIds: [],backlinkMStatus: 3- }+ };if (data.mentionsCount === 0) {this.status[this.blockId].backlinkMStatus = 3;} else {- this.status[this.blockId].backlinkMOpenIds = [data.backmentions[0].id]+ this.status[this.blockId].backlinkMOpenIds = [data.backmentions[0].id];if (data.linkRefsCount === 0) {this.status[this.blockId].backlinkMStatus = 0;} else {- this.status[this.blockId].backlinkOpenIds = [data.backlinks[0].id]+ this.status[this.blockId].backlinkOpenIds = [data.backlinks[0].id];this.status[this.blockId].backlinkMStatus = 1;}}@@ -529,17 +529,17 @@ export class Backlink extends Model {// restore statusthis.status[this.blockId].backlinkOpenIds.forEach(item => {- const liElement = this.tree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement+ const liElement = this.tree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement;if (liElement) {this.toggleItem(liElement, false);}- })+ });this.status[this.blockId].backlinkMOpenIds.forEach(item => {- const liElement = this.mTree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement+ const liElement = this.mTree.element.querySelector(`.b3-list-item[data-node-id="${item}"]`) as HTMLElement;if (liElement) {this.toggleItem(liElement, true);}- })+ });// 0 全展开,1 展开一半箭头向下,2 展开一半箭头向上,3 全收起const layoutElement = this.mTree.element.previousElementSibling.querySelector('[data-type="layout"]');if (this.status[this.blockId].backlinkMStatus === 2 || this.status[this.blockId].backlinkMStatus === 1) {@@ -563,8 +563,8 @@ export class Backlink extends Model {layoutElement.setAttribute("aria-label", window.siyuan.languages.down);layoutElement.querySelector("use").setAttribute("xlink:href", "#iconDown");}- this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort)- this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort)+ this.tree.element.previousElementSibling.querySelector('[data-type="sort"]').setAttribute("data-sort", this.status[this.blockId].sort);+ this.mTree.element.previousElementSibling.querySelector('[data-type="mSort"]').setAttribute("data-sort", this.status[this.blockId].mSort);setTimeout(() => {this.tree.element.scrollTop = this.status[this.blockId].scrollTop;diff --git a/app/src/layout/status.ts b/app/src/layout/status.tsindex cb2bc6ef70..ae293f2a3f 100644--- a/app/src/layout/status.ts+++ b/app/src/layout/status.ts@@ -166,7 +166,7 @@ export const countBlockWord = (ids: string[], rootID?: string) => {export const clearCounter = () => {document.querySelector("#status .status__counter").innerHTML = "";-}+};export const renderStatusbarCounter = (stat: { runeCount: number, wordCount: number, linkCount: number, imageCount: number, refCount: number }) => {let html = `<span class="ft__on-surface">${window.siyuan.languages.runeCount}</span> ${stat.runeCount}<span class="fn__space"></span>diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex 24d752bc10..39889c8432 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -14,7 +14,7 @@ export const openByMobile = (uri: string) => {};export const writeText = async (text: string) => {- let range: Range+ let range: Range;if (getSelection().rangeCount > 0) {range = getSelection().getRangeAt(0).cloneRange();}diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 370ed8cfd3..7385f3e662 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1101,8 +1101,8 @@ export class WYSIWYG {this.element.addEventListener("contextmenu", (event: MouseEvent & { detail: any }) => {event.stopPropagation();event.preventDefault();- const x = event.clientX || event.detail.x- const y = event.clientY || event.detail.y+ const x = event.clientX || event.detail.x;+ const y = event.clientY || event.detail.y;const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");if (selectElements.length > 1) {// 多选块@@ -1111,7 +1111,7 @@ export class WYSIWYG {window.siyuan.menus.menu.popup({x, y});return;}- const target = event.detail.target || event.target as HTMLElement+ const target = event.detail.target || event.target as HTMLElement;const embedElement = hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed");if (embedElement) {if (getSelection().rangeCount === 0) {diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 47d3bcc629..7ef205382c 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -446,6 +446,7 @@ declare interface IFile {declare interface IBlockTree {nodeType: string,+ hPath: string,subType: string,name: string,type: string,diff --git a/app/src/util/Tree.ts b/app/src/util/Tree.tsindex e450c6c087..4230b6d89e 100644--- a/app/src/util/Tree.ts+++ b/app/src/util/Tree.ts@@ -57,14 +57,17 @@ export class Tree {private genHTML(data: IBlockTree[]) {let html = `<ul${data[0].depth === 0 ? " class='b3-list b3-list--background'" : ""}>`;data.forEach((item) => {+ let titleTip = "";let iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconFolder"></use></svg>';if (item.type === "bookmark") {iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconBookmark"></use></svg>';} else if (item.type === "tag") {iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconTags"></use></svg>';} else if (item.type === "backlink") {+ titleTip= ` title="${item.hPath}"`;iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;} else if (item.type === "outline") {+ titleTip= ` title="${Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name))}"`;iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;}let countHTML = "";@@ -82,7 +85,7 @@ ${item.label ? "data-label='" + item.label + "'" : ""}><svg data-id="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow ${((item.children && item.children.length > 0) || (item.blocks && item.blocks.length > 0)) ? "b3-list-item__arrow--open" : (item.type === "backlink" ? "" : "fn__hidden")}"><use xlink:href="#iconRight"></use></svg></span>${iconHTML}- <span class="b3-list-item__text"${item.type === "outline" ? ' title="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name)) + '"' : ""}>${item.name}</span>+ <span class="b3-list-item__text"${titleTip}>${item.name}</span>${countHTML}${this.topExtHTML || ""}</li>`;