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/15210
Vanessa6d6112a50da2
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex 551ed2ab2e..656d43b61d 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -281,7 +281,15 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleevent.stopPropagation();return true;} else if (type === "av-gallery-more") {- openGalleryItemMenu({target, blockElement, protyle, returnMenu: false});+ const rect = target.getBoundingClientRect();+ openGalleryItemMenu({+ target,+ protyle,+ position: {+ x: rect.left,+ y: rect.bottom+ }+ });event.preventDefault();event.stopPropagation();return true;@@ -300,15 +308,23 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positiif (!blockElement) {return false;}- if (!rowElement.classList.contains("av__row--select")) {- clearSelect(["row"], blockElement);+ const avType = blockElement.getAttribute("data-av-type") as TAVView;+ if (avType === "table") {+ if (!rowElement.classList.contains("av__row--select")) {+ clearSelect(["row"], blockElement);+ }+ clearSelect(["cell"], blockElement);+ rowElement.classList.add("av__row--select");+ rowElement.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconCheck");+ updateHeader(rowElement);+ } else {+ if (!rowElement.classList.contains("av__gallery-item--select")) {+ clearSelect(["galleryItem"], blockElement);+ }+ rowElement.classList.add("av__gallery-item--select");}- clearSelect(["cell"], blockElement);const menu = new Menu();- rowElement.classList.add("av__row--select");- rowElement.querySelector(".av__firstcol use").setAttribute("xlink:href", "#iconCheck");- const rowElements = blockElement.querySelectorAll(".av__row--select:not(.av__row--header)");- updateHeader(rowElement);+ const rowElements = blockElement.querySelectorAll(".av__row--select:not(.av__row--header), .av__gallery-item--select");const keyCellElement = rowElements[0].querySelector(".av__cell[data-block-id]") as HTMLElement;const ids = Array.from(rowElements).map(item => item.getAttribute("data-id"));if (rowElements.length === 1 && keyCellElement.getAttribute("data-detached") !== "true") {@@ -558,7 +574,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positiid: "insertRowBefore",icon: "iconBefore",label: `<div class="fn__flex" style="align-items: center;">-${window.siyuan.languages.insertRowBefore.replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" value="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field"><span class="fn__space"></span>`)}+${window.siyuan.languages[avType === "table" ? "insertRowBefore" : "insertItemBefore"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" value="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field"><span class="fn__space"></span>`)}</div>`,bind(element) {const inputElement = element.querySelector("input");@@ -581,7 +597,7 @@ ${window.siyuan.languages.insertRowBefore.replace("${x}", `<span class="fn__spacid: "insertRowAfter",icon: "iconAfter",label: `<div class="fn__flex" style="align-items: center;">-${window.siyuan.languages.insertRowAfter.replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field" value="1"><span class="fn__space"></span>`)}+${window.siyuan.languages[avType === "table" ? "insertRowAfter" : "insertItemAfter"].replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field" value="1"><span class="fn__space"></span>`)}</div>`,bind(element) {const inputElement = element.querySelector("input");diff --git a/app/src/protyle/render/av/gallery/util.ts b/app/src/protyle/render/av/gallery/util.tsindex 6337178bae..c3f321c890 100644--- a/app/src/protyle/render/av/gallery/util.ts+++ b/app/src/protyle/render/av/gallery/util.ts@@ -1,11 +1,9 @@import {transaction} from "../../../wysiwyg/transaction";import {Menu} from "../../../../plugin/Menu";-import * as dayjs from "dayjs";import {hasClosestByClassName} from "../../../util/hasClosest";-import {genCellValueByElement} from "../cell";-import {clearSelect} from "../../../util/clearSelect";import {unicode2Emoji} from "../../../../emoji";import {getColIconByType} from "../col";+import {avContextmenu} from "../action";export const setGalleryCover = (options: {view: IAVGallery@@ -233,73 +231,17 @@ export const setGalleryRatio = (options: {export const openGalleryItemMenu = (options: {target: HTMLElement,- blockElement: HTMLElement,protyle: IProtyle,- returnMenu: boolean+ position: {+ x:number,+ y:number+ }}) => {- const menu = new Menu();- const avID = options.blockElement.getAttribute("data-av-id");const cardElement = hasClosestByClassName(options.target, "av__gallery-item");if (!cardElement) {return;}- if (!cardElement.classList.contains("av__gallery-item--select")) {- clearSelect(["galleryItem"], options.blockElement);- cardElement.classList.add("av__gallery-item--select");- }- menu.addItem({- icon: "iconTrashcan",- warning: true,- label: window.siyuan.languages.delete,- click() {- const srcIDs: string[] = [];- const srcs: IOperationSrcs[] = [];- let previousID = "";- options.blockElement.querySelectorAll(".av__gallery-item--select").forEach((item, index) => {- const blockValue = genCellValueByElement("block", item.querySelector(".av__cell[data-block-id]"));- const id = item.getAttribute("data-id");- srcIDs.push(id);- srcs.push({- id,- isDetached: blockValue.isDetached,- content: blockValue.block.content- });- item.remove();- if (index === 0) {- previousID = item.previousElementSibling?.getAttribute("data-id") || "";- }- });- const newUpdated = dayjs().format("YYYYMMDDHHmmss");- transaction(options.protyle, [{- action: "removeAttrViewBlock",- srcIDs,- avID,- }, {- action: "doUpdateUpdated",- id: options.blockElement.dataset.nodeId,- data: newUpdated,- }], [{- action: "insertAttrViewBlock",- avID,- previousID,- srcs,- blockID: options.blockElement.dataset.nodeId- }, {- action: "doUpdateUpdated",- id: options.blockElement.dataset.nodeId,- data: options.blockElement.getAttribute("updated")- }]);- options.blockElement.setAttribute("updated", newUpdated);- }- });- if (options.returnMenu) {- return menu;- }- const rect = options.target.getBoundingClientRect();- menu.open({- x: rect.left,- y: rect.bottom- });+ avContextmenu(options.protyle, cardElement, options.position);};export const editGalleryItem = (target: Element) => {diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 8a067d41c1..efe7009160 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1973,15 +1973,13 @@ export class WYSIWYG {if (protyle.disabled) {return false;}- const menu = openGalleryItemMenu({+ openGalleryItemMenu({target: avGalleryItemElement.querySelector(".protyle-icon--last"),- blockElement: nodeElement,protyle,- returnMenu: true- });- menu.open({- x: event.clientX,- y: event.clientY+ position: {+ x: event.clientX,+ y: event.clientY+ }});event.stopPropagation();event.preventDefault();