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/9791
Vanessa1b41f30bbd2c
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scssindex 88b5fc7c0e..3f07da507e 100644--- a/app/src/assets/scss/business/_av.scss+++ b/app/src/assets/scss/business/_av.scss@@ -102,7 +102,8 @@display: block;}- &--select {+ &--select,+ &--hl {&:not(.av__row--header) .av__cell,&:not(.av__row--header) .av__firstcol {background-color: var(--b3-av-background-hl);@@ -324,6 +325,7 @@@extend .av__checkbox;opacity: 0;padding: 9.5px 5px;+ cursor: pointer;}&:hover svg {diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 8bd64a5811..25bf314d6e 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -185,8 +185,13 @@ export class Gutter {window.siyuan.menus.menu.remove();return;}+ const gutterRect = buttonElement.getBoundingClientRect();if (buttonElement.dataset.type === "NodeAttributeViewRowMenu" || buttonElement.dataset.type === "NodeAttributeViewRow") {- const rowElement = protyle.wysiwyg.element.querySelector(`.av__row[data-id="${buttonElement.dataset.nodeId}"]`) as HTMLElement;+ const rowElement = Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-node-id="${buttonElement.dataset.nodeId}"] .av__row[data-id="${buttonElement.dataset.rowId}"]`)).find((item: HTMLElement) => {+ if (!hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed")) {+ return true;+ }+ });if (!rowElement) {return;}@@ -194,11 +199,10 @@ export class Gutter {if (!blockElement) {return;}- blockElement.querySelector(".av__cell--select")?.classList.remove("av__cell--select");if (buttonElement.dataset.type === "NodeAttributeViewRow") {const avID = blockElement.getAttribute("data-av-id");const srcIDs = [Lute.NewNodeID()];- const previousID = event.altKey ? (rowElement.previousElementSibling.getAttribute("data-id") || "") : buttonElement.dataset.nodeId;+ const previousID = event.altKey ? (rowElement.previousElementSibling.getAttribute("data-id") || "") : buttonElement.dataset.rowId;transaction(protyle, [{action: "insertAttrViewBlock",avID,@@ -212,19 +216,19 @@ export class Gutter {}]);insertAttrViewBlockAnimation(blockElement, srcIDs, previousID, avID);} else {- const gutterRect = buttonElement.getBoundingClientRect();- avContextmenu(protyle, rowElement, {+ avContextmenu(protyle, rowElement as HTMLElement, {x: gutterRect.left,y: gutterRect.bottom,w: gutterRect.width,- h: gutterRect.height+ h: gutterRect.height,+ isLeft: true});}return;}if (isOnlyMeta(event)) {zoomOut({protyle, id});- } else if (event.altKey) {+ } else if (event.altKey && !protyle.disabled) {let foldElement: Element;Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find(item => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed") &&@@ -276,7 +280,7 @@ export class Gutter {foldElement.classList.remove("protyle-wysiwyg--hl");} else if (window.siyuan.shiftIsPressed && !protyle.disabled) {openAttr(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`), "bookmark", protyle);- } else {+ } else if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {this.renderMenu(protyle, buttonElement);// https://ld246.com/article/1648433751993if (!protyle.toolbar.range) {@@ -285,7 +289,7 @@ export class Gutter {if (isMobile()) {window.siyuan.menus.menu.fullscreen();} else {- window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});+ window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");focusByRange(protyle.toolbar.range);}@@ -293,13 +297,31 @@ export class Gutter {});this.element.addEventListener("contextmenu", (event: MouseEvent & { target: HTMLInputElement }) => {const buttonElement = hasClosestByTag(event.target, "BUTTON");- if (!buttonElement || protyle.disabled || buttonElement.getAttribute("data-type") === "fold") {+ if (!buttonElement || buttonElement.getAttribute("data-type") === "fold") {return;}if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {- this.renderMenu(protyle, buttonElement);- window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});- window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");+ const gutterRect = buttonElement.getBoundingClientRect();+ if (buttonElement.dataset.type === "NodeAttributeViewRowMenu") {+ const rowElement = Array.from(protyle.wysiwyg.element.querySelectorAll(`.av[data-node-id="${buttonElement.dataset.nodeId}"] .av__row[data-id="${buttonElement.dataset.rowId}"]`)).find((item: HTMLElement) => {+ if (!hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed")) {+ return true;+ }+ });+ if (rowElement) {+ avContextmenu(protyle, rowElement as HTMLElement, {+ x: gutterRect.left,+ y: gutterRect.bottom,+ w: gutterRect.width,+ h: gutterRect.height,+ isLeft: true+ });+ }+ } else if (buttonElement.dataset.type !== "NodeAttributeViewRow") {+ this.renderMenu(protyle, buttonElement);+ window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});+ window.siyuan.menus.menu.element.setAttribute("data-from", hasClosestByClassName(protyle.element, "block__edit") ? "popover" : "app");+ }}event.preventDefault();event.stopPropagation();@@ -309,28 +331,37 @@ export class Gutter {if (!buttonElement) {return;}- if (buttonElement.getAttribute("data-type") === "fold") {- Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl")).forEach(hlItem => {- hlItem.classList.remove("protyle-wysiwyg--hl");+ const type = buttonElement.getAttribute("data-type");+ if (type === "fold" || type === "NodeAttributeViewRow") {+ Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, .av__row--hl")).forEach(item => {+ item.classList.remove("protyle-wysiwyg--hl", "av__row--hl");});return;}Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${buttonElement.getAttribute("data-node-id")}"]`)).find(item => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed") && this.isMatchNode(item)) {- Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl")).forEach(hlItem => {+ const rowItem = item.querySelector(`.av__row[data-id="${buttonElement.dataset.rowId}"]`)+ Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, av__row--hl")).forEach(hlItem => {if (!item.isSameNode(hlItem)) {hlItem.classList.remove("protyle-wysiwyg--hl");}+ if (rowItem && !rowItem.isSameNode(hlItem)) {+ rowItem.classList.remove("av__row--hl");+ }});- item.classList.add("protyle-wysiwyg--hl");+ if (type === "NodeAttributeViewRowMenu") {+ rowItem.classList.add("av__row--hl");+ } else {+ item.classList.add("protyle-wysiwyg--hl");+ }return true;}});event.preventDefault();});this.element.addEventListener("mouseleave", (event: MouseEvent & { target: HTMLInputElement }) => {- Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl")).forEach(item => {- item.classList.remove("protyle-wysiwyg--hl");+ Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, .av__row--hl")).forEach(item => {+ item.classList.remove("protyle-wysiwyg--hl", "av__row--hl");});event.preventDefault();event.stopPropagation();@@ -1869,12 +1900,13 @@ export class Gutter {if (isShow) {type = nodeElement.getAttribute("data-type");}+ const dataNodeId = nodeElement.getAttribute("data-node-id")if (type === "NodeAttributeView" && target) {const rowElement = hasClosestByClassName(target, "av__row");if (rowElement && !rowElement.classList.contains("av__row--header")) {element = rowElement;- html = `<button data-type="NodeAttributeViewRow" data-node-id="${rowElement.dataset.id}" class="ariaLabel" data-position="right" aria-label="${isMac() ? window.siyuan.languages.addBelowAbove : window.siyuan.languages.addBelowAbove.replace("⌥", "Alt+")}"><svg><use xlink:href="#iconAdd"></use></svg></button>-<button data-type="NodeAttributeViewRowMenu" data-node-id="${rowElement.dataset.id}" class="ariaLabel" data-position="right" aria-label="${window.siyuan.languages.rowTip}"><svg><use xlink:href="#iconDrag"></use></svg><span ${protyle.disabled ? "" : 'draggable="true"'}></span></button>`+ html = `<button data-type="NodeAttributeViewRow" data-node-id="${dataNodeId}" data-row-id="${rowElement.dataset.id}" class="ariaLabel" data-position="right" aria-label="${isMac() ? window.siyuan.languages.addBelowAbove : window.siyuan.languages.addBelowAbove.replace("⌥", "Alt+")}"><svg><use xlink:href="#iconAdd"></use></svg></button>+<button data-type="NodeAttributeViewRowMenu" data-node-id="${dataNodeId}" data-row-id="${rowElement.dataset.id}" class="ariaLabel" data-position="right" aria-label="${window.siyuan.languages.rowTip}"><svg><use xlink:href="#iconDrag"></use></svg><span ${protyle.disabled ? "" : 'draggable="true"'}></span></button>`break;}}@@ -1901,7 +1933,7 @@ export class Gutter {}index += 1;const buttonHTML = `<button class="ariaLabel" data-position="right" aria-label="${this.gutterTip}"-data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}">+data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${dataNodeId}"><svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg><span ${protyle.disabled ? "" : 'draggable="true"'}></span></button>`;@@ -1945,10 +1977,16 @@ data-type="fold"><svg style="width:10px${fold && fold === "1" ? "" : ";transformif (buttonsElement.length !== html.split("</button>").length - 1) {match = false;} else {- buttonsElement.forEach(item => {+ Array.from(buttonsElement).find(item => {const id = item.getAttribute("data-node-id");if (id && html.indexOf(id) === -1) {match = false;+ return true+ }+ const rowId = item.getAttribute("data-row-id");+ if (rowId && html.indexOf(rowId) === -1) {+ match = false;+ return true;}});}diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex 6a2dc929c8..672dbf743b 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -256,6 +256,9 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positiif (!blockElement) {return false;}+ blockElement.querySelectorAll(".av__cell--select").forEach(item => {+ item.classList.remove("av__cell--select");+ });if (!rowElement.classList.contains("av__row--select")) {blockElement.querySelectorAll(".av__row--select").forEach(item => {item.classList.remove("av__row--select");diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex 4464cb9434..7ee9910c26 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -297,6 +297,11 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: boolif (!isUndo && operation.action === "insertAttrViewBlock" && operation.isDetached && isCurrent) {popTextCell(protyle, [item.querySelector(`.av__row[data-id="${operation.srcIDs[0]}"] .av__cell[data-detached="true"]`)], "block");}+ if (operation.action === "insertAttrViewBlock") {+ item.querySelectorAll(".av__cell--select").forEach((cellElement: HTMLElement) => {+ cellElement.classList.remove("av__cell--select");+ });+ }}, ["addAttrViewView", "duplicateAttrViewView"].includes(operation.action) ? operation.id :(operation.action === "removeAttrViewView" ? null : undefined));});