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/10964
Vanessa6d7637850aba
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 8eff381375..6b76098473 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -279,6 +279,7 @@ export class Gutter {content: ""}],blockID: id,+ groupID: rowElement.parentElement.getAttribute("data-group-id"),}, {action: "doUpdateUpdated",id,diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex 9fd489e130..66ba636c9e 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -157,7 +157,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleevent.stopPropagation();return true;} else if (type === "av-add-more") {- insertRows(blockElement, protyle, 1, undefined);+ insertRows({blockElement, protyle, count: 1, previousID: ""});event.preventDefault();event.stopPropagation();return true;@@ -210,10 +210,14 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleevent.stopPropagation();return true;} else if (type === "av-add-bottom") {- insertRows(blockElement, protyle, 1,- blockElement.querySelector(".av__row--util")?.previousElementSibling?.getAttribute("data-id") ||- target.previousElementSibling?.getAttribute("data-id") || undefined- );+ const bodyElement = hasClosestByClassName(target, "av__body");+ insertRows({+ blockElement, protyle,+ count: 1,+ previousID: blockElement.querySelector(".av__row--util")?.previousElementSibling?.getAttribute("data-id") ||+ target.previousElementSibling?.getAttribute("data-id") || undefined,+ groupID: bodyElement ? bodyElement.getAttribute("data-group-id") : ""+ });event.preventDefault();event.stopPropagation();return true;@@ -582,7 +586,8 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positiavID,ignoreFillFilter: true,srcs,- blockID: listItemElement.dataset.blockId+ blockID: listItemElement.dataset.blockId,+ groupID: rowElement.parentElement.getAttribute("data-group-id")}, {action: "doUpdateUpdated",id: listItemElement.dataset.blockId,@@ -611,12 +616,24 @@ ${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBeif (document.activeElement === inputElement) {return;}- insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id"));+ insertRows({+ blockElement,+ protyle,+ count: parseInt(inputElement.value),+ previousID: rowElements[0].previousElementSibling.getAttribute("data-id"),+ groupID: rowElements[0].parentElement.getAttribute("data-group-id")+ });menu.close();});inputElement.addEventListener("keydown", (event: KeyboardEvent) => {if (!event.isComposing && event.key === "Enter") {- insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id"));+ insertRows({+ blockElement,+ protyle,+ count: parseInt(inputElement.value),+ previousID: rowElements[0].previousElementSibling.getAttribute("data-id"),+ groupID: rowElements[0].parentElement.getAttribute("data-group-id")+ });menu.close();}});@@ -634,12 +651,24 @@ ${window.siyuan.languages[avType === "table" ? "insertRowAfter" : "insertItemAftif (document.activeElement === inputElement) {return;}- insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));+ insertRows({+ blockElement,+ protyle,+ count: parseInt(inputElement.value),+ previousID: rowElements[0].getAttribute("data-id"),+ groupID: rowElements[0].parentElement.getAttribute("data-group-id")+ });menu.close();});inputElement.addEventListener("keydown", (event: KeyboardEvent) => {if (!event.isComposing && event.key === "Enter") {- insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));+ insertRows({+ blockElement,+ protyle,+ count: parseInt(inputElement.value),+ previousID: rowElements[0].getAttribute("data-id"),+ groupID: rowElements[0].parentElement.getAttribute("data-group-id")+ });menu.close();}});diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.tsindex c09d922c0a..d9aeaf6c05 100644--- a/app/src/protyle/render/av/relation.ts+++ b/app/src/protyle/render/av/relation.ts@@ -420,6 +420,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelectorconst blockID = target.querySelector(".popover__block").getAttribute("data-id");const content = target.querySelector("b").textContent;const rowId = Lute.NewNodeID();+ const bodyElement = hasClosestByClassName(cellElements[0], "av__body");transaction(protyle, [{action: "insertAttrViewBlock",ignoreFillFilter: true,@@ -430,6 +431,7 @@ draggable="true">${genSelectItemHTML("selected", targetId, !target.querySelectorcontent}],blockID,+ groupID: bodyElement ? bodyElement.getAttribute("data-group-id") : "",}, {action: "doUpdateUpdated",id: blockID,diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex 112ecf1904..b2c70ef765 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -239,7 +239,7 @@ const renderGroupTable = (options: ITableOptions) => {<svg class="${group.groupFolded ? "" : "av__group-arrow--open"}"><use xlink:href="#iconRight"></use></svg></div><span class="fn__space"></span>${group.name}<span class="${group.rows.length === 0 ? "fn__none" : "counter"}">${group.rows.length}</span></div>-<div class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement).contentHTML}</div>`;+<div data-group-id="${group.id}" class="av__body${group.groupFolded ? " fn__none" : ""}">${getTableHTMLs(group, options.blockElement).contentHTML}</div>`;}});if (options.renderAll) {diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.tsindex ba72f73bbe..f81374b2a4 100644--- a/app/src/protyle/render/av/row.ts+++ b/app/src/protyle/render/av/row.ts@@ -84,7 +84,7 @@ export const updateHeader = (rowElement: HTMLElement) => {}const counterElement = blockElement.querySelector(".av__counter");- const allCount = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").length+ const allCount = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)").length;if (allCount === 0) {counterElement.classList.add("fn__none");return;@@ -432,7 +432,8 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {isDetached: blockValue.isDetached,content: blockValue.block.content}],- blockID: blockElement.dataset.nodeId+ blockID: blockElement.dataset.nodeId,+ groupID: item.parentElement.getAttribute("data-group-id")});});const newUpdated = dayjs().format("YYYYMMDDHHmmss");@@ -458,11 +459,17 @@ export const deleteRow = (blockElement: HTMLElement, protyle: IProtyle) => {blockElement.setAttribute("updated", newUpdated);};-export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count: number, previousID: string) => {- const avID = blockElement.getAttribute("data-av-id");+export const insertRows = (options: {+ blockElement: HTMLElement,+ protyle: IProtyle,+ count: number,+ previousID: string,+ groupID?: string+}) => {+ const avID = options.blockElement.getAttribute("data-av-id");const srcIDs: string[] = [];const srcs: IOperationSrcs[] = [];- new Array(count).fill(0).forEach(() => {+ new Array(options.count).fill(0).forEach(() => {const newNodeID = Lute.NewNodeID();srcIDs.push(newNodeID);srcs.push({@@ -472,15 +479,16 @@ export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count:});});const newUpdated = dayjs().format("YYYYMMDDHHmmss");- transaction(protyle, [{+ transaction(options.protyle, [{action: "insertAttrViewBlock",avID,- previousID,+ previousID: options.previousID,srcs,- blockID: blockElement.dataset.nodeId,+ blockID: options.blockElement.dataset.nodeId,+ groupID: options.groupID}, {action: "doUpdateUpdated",- id: blockElement.dataset.nodeId,+ id: options.blockElement.dataset.nodeId,data: newUpdated,}], [{action: "removeAttrViewBlock",@@ -488,18 +496,18 @@ export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count:avID,}, {action: "doUpdateUpdated",- id: blockElement.dataset.nodeId,- data: blockElement.getAttribute("updated")+ id: options.blockElement.dataset.nodeId,+ data: options.blockElement.getAttribute("updated")}]);- if (blockElement.getAttribute("data-av-type") === "gallery") {+ if (options.blockElement.getAttribute("data-av-type") === "gallery") {insertGalleryItemAnimation({- blockElement,- protyle,+ blockElement: options.blockElement,+ protyle: options.protyle,srcIDs,- previousId: previousID+ previousId: options.previousID});} else {- insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID);+ insertAttrViewBlockAnimation(options.protyle, options.blockElement, srcIDs, options.previousID, avID);}- blockElement.setAttribute("updated", newUpdated);+ options.blockElement.setAttribute("updated", newUpdated);};diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex cd2dad7c31..0f22c20b6b 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -1109,7 +1109,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {avID,previousID,srcs,- blockID: blockElement.dataset.nodeId+ blockID: blockElement.dataset.nodeId,+ groupID: targetElement.parentElement.getAttribute("data-group-id")}, {action: "doUpdateUpdated",id: blockElement.dataset.nodeId,@@ -1169,7 +1170,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {avID,previousID,srcs,- blockID: blockElement.dataset.nodeId+ blockID: blockElement.dataset.nodeId,+ groupID: targetElement.parentElement.getAttribute("data-group-id")}, {action: "doUpdateUpdated",id: blockElement.dataset.nodeId,@@ -1290,6 +1292,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {previousID,srcs,blockID: blockElement.dataset.nodeId,+ groupID: targetElement.parentElement.getAttribute("data-group-id")}, {action: "doUpdateUpdated",id: blockElement.dataset.nodeId,diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex fbc18b48d9..f235780606 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -552,6 +552,7 @@ interface IOperation {blockIDs?: string[] // add/removeFlashcards 专享removeDest?: boolean // removeAttrViewCol 专享layout?: string // addAttrViewView 专享+ groupID?: string // insertAttrViewBlock 专享}interface IOperationSrcs {