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/11569
Vanessa872191d0782c
diff --git a/app/src/config/image.ts b/app/src/config/image.tsindex 4c1825c73c..12cbec2ef3 100644--- a/app/src/config/image.ts+++ b/app/src/config/image.ts@@ -12,8 +12,11 @@ import {openBy} from "../editor/util";import {renderAssetsPreview} from "../asset/renderAssets";import {writeText} from "../protyle/util/compatibility";import {Constants} from "../constants";-import {avRender} from "../protyle/render/av/render";import {showMessage} from "../dialog/message";+import {Protyle} from "../protyle";+import {App} from "../index";+import {disabledProtyle, onGet} from "../protyle/util/onGet";+import {removeLoading} from "../protyle/ui/initUI";export const image = {element: undefined as Element,@@ -78,9 +81,22 @@ export const image = {</div></div>`;},- bindEvent: () => {+ bindEvent: (app: App) => {const assetsListElement = image.element.querySelector('.config-assets[data-type="remove"] .config-assets__list');const avListElement = image.element.querySelector('.config-assets[data-type="removeAV"] .config-assets__list');+ const editor = new Protyle(app, avListElement.nextElementSibling as HTMLElement, {+ blockId: "",+ action: [Constants.CB_GET_HISTORY],+ render: {+ background: false,+ gutter: false,+ breadcrumb: false,+ breadcrumbDocName: false,+ },+ typewriterMode: false,+ });+ disabledProtyle(editor.protyle);+ removeLoading(editor.protyle);image.element.addEventListener("click", (event) => {let target = event.target as HTMLElement;while (target && !target.isEqualNode(image.element)) {@@ -138,14 +154,25 @@ export const image = {event.stopPropagation();break;} else if (target.getAttribute("data-tab-type") === "unRefAV") {- avListElement.nextElementSibling.innerHTML = `<div data-node-id="${Lute.NewNodeID()}" data-av-id="${target.dataset.item}" data-type="NodeAttributeView" data-av-type="table"><div spellcheck="true"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;- avRender(avListElement.nextElementSibling.firstElementChild, null);+ onGet({+ data: {+ data: {+ content: `<div class="av" data-node-id="${Lute.NewNodeID()}" data-av-id="${target.dataset.item}" data-type="NodeAttributeView" data-av-type="table"><div spellcheck="true"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`,+ id: Lute.NewNodeID(),+ rootID: Lute.NewNodeID(),+ },+ msg: "",+ code: 0+ },+ protyle: editor.protyle,+ action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],+ });event.preventDefault();event.stopPropagation();break;} else if (type === "copy") {if (target.parentElement.getAttribute("data-tab-type") === "unRefAV") {- writeText(`<div data-node-id="${Lute.NewNodeID()}" data-av-id="${target.parentElement.dataset.item}" data-type="NodeAttributeView" data-av-type="table"></div>`);+ writeText(`<div class="av" data-node-id="${Lute.NewNodeID()}" data-av-id="${target.parentElement.dataset.item}" data-type="NodeAttributeView" data-av-type="table"></div>`);} else {writeText(target.parentElement.querySelector(".b3-list-item__text").textContent.trim());}diff --git a/app/src/config/index.ts b/app/src/config/index.tsindex 84c82e3671..8b1e6a168e 100644--- a/app/src/config/index.ts+++ b/app/src/config/index.ts@@ -43,7 +43,7 @@ export const genItemPanel = (type: string, containerElement: Element, app: App)case "image":containerElement.innerHTML = image.genHTML();image.element = containerElement;- image.bindEvent();+ image.bindEvent(app);break;case "export":containerElement.innerHTML = exportConfig.genHTML();diff --git a/app/src/history/history.ts b/app/src/history/history.tsindex fe26dafcdd..82395b89c1 100644--- a/app/src/history/history.ts+++ b/app/src/history/history.ts@@ -753,7 +753,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {onGet({data: {data: {- content: `<div data-node-id="${Lute.NewNodeID()}" data-av-id="${target.querySelector(".b3-list-item__text").textContent}" data-type="NodeAttributeView" data-av-type="table"><div spellcheck="true"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`,+ content: `<div class="av" data-node-id="${Lute.NewNodeID()}" data-av-id="${target.querySelector(".b3-list-item__text").textContent}" data-type="NodeAttributeView" data-av-type="table"><div spellcheck="true"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`,id: Lute.NewNodeID(),rootID: Lute.NewNodeID(),},diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.tsindex 0f832d09c0..bd91a23bff 100644--- a/app/src/mobile/menu/index.ts+++ b/app/src/mobile/menu/index.ts@@ -1,6 +1,6 @@import {popSearch} from "./search";import {initAppearance} from "../settings/appearance";-import {initAssets} from "../settings/assets";+import {initConfigAssets} from "../settings/assets";import {closePanel} from "../util/closePanel";import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";import {repos} from "../../config/repos";@@ -178,7 +178,7 @@ export const initRightMenu = (app: App) => {event.stopPropagation();break;} else if (target.id === "menuAssets") {- initAssets();+ initConfigAssets(app);event.preventDefault();event.stopPropagation();break;diff --git a/app/src/mobile/settings/assets.ts b/app/src/mobile/settings/assets.tsindex 39de47b4de..88a8ddeae6 100644--- a/app/src/mobile/settings/assets.ts+++ b/app/src/mobile/settings/assets.ts@@ -1,14 +1,15 @@import {openModel} from "../menu/model";import {image} from "../../config/image";+import {App} from "../../index";-export const initAssets = () => {+export const initConfigAssets = (app: App) => {openModel({title: window.siyuan.languages.assets,icon: "iconImage",html: image.genHTML(),bindEvent(modelMainElement: HTMLElement) {image.element = modelMainElement.firstElementChild;- image.bindEvent();+ image.bindEvent(app);}});};diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex 9fdbb45b85..14cbef2de6 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -864,7 +864,7 @@ export const duplicateCompletely = (protyle: IProtyle, nodeElement: HTMLElement)fetchPost("/api/av/duplicateAttributeViewBlock", {avID: nodeElement.getAttribute("data-av-id")}, (response) => {nodeElement.classList.remove("protyle-wysiwyg--select");const tempElement = document.createElement("template");- tempElement.innerHTML = protyle.lute.SpinBlockDOM(`<div data-node-id="${response.data.blockID}" data-av-id="${response.data.avID}" data-type="NodeAttributeView" data-av-type="table"></div>`);+ tempElement.innerHTML = protyle.lute.SpinBlockDOM(`<div class="av" data-node-id="${response.data.blockID}" data-av-id="${response.data.avID}" data-type="NodeAttributeView" data-av-type="table"></div>`);const cloneElement = tempElement.content.firstElementChild;nodeElement.after(cloneElement);avRender(cloneElement, protyle, () => {diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex f1a1eaed15..a5df3aea39 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -270,7 +270,7 @@ const renderGroupTable = (options: ITableOptions) => {});if (options.renderAll) {options.blockElement.firstElementChild.outerHTML = `<div class="av__container">- ${genTabHeaderHTML(options.data, isSearching || !!query, options.protyle ? (!options.protyle.disabled && !hasClosestByAttribute(options.blockElement, "data-type", "NodeBlockQueryEmbed")) : false)}+ ${genTabHeaderHTML(options.data, isSearching || !!query, !options.protyle.disabled && !hasClosestByAttribute(options.blockElement, "data-type", "NodeBlockQueryEmbed"))}<div class="av__scroll">${avBodyHTML}</div>@@ -290,13 +290,13 @@ const afterRenderTable = (options: ITableOptions) => {options.blockElement.setAttribute("data-render", "true");options.blockElement.querySelector(".av__scroll").scrollLeft = options.resetData.left;options.blockElement.style.alignSelf = options.resetData.alignSelf;- const editRect = options.protyle ? options.protyle.contentElement.getBoundingClientRect() : null;+ const editRect = options.protyle.contentElement.getBoundingClientRect();if (options.resetData.headerTransform) {const headerTransformElement = options.blockElement.querySelector(`.av__body[data-group-id="${options.resetData.headerTransform.groupId}"] .av__row--header`) as HTMLElement;if (headerTransformElement) {headerTransformElement.style.transform = options.resetData.headerTransform.transform;}- } else if (editRect && options.protyle && !options.protyle.options.action.includes(Constants.CB_GET_HISTORY)) {+ } else if (editRect && !options.protyle.options.action.includes(Constants.CB_GET_HISTORY)) {// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787setTimeout(() => {stickyRow(options.blockElement, editRect, "top");@@ -307,7 +307,7 @@ const afterRenderTable = (options: ITableOptions) => {if (footerTransformElement) {footerTransformElement.style.transform = options.resetData.footerTransform.transform;}- } else if (editRect && options.protyle && !options.protyle.options.action.includes(Constants.CB_GET_HISTORY)) {+ } else if (editRect && !options.protyle.options.action.includes(Constants.CB_GET_HISTORY)) {// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787setTimeout(() => {stickyRow(options.blockElement, editRect, "bottom");@@ -552,8 +552,8 @@ export const avRender = async (element: Element, protyle: IProtyle, cb?: (data:const avPageSize = getPageSize(e);let data: IAV;if (!avData) {- const created = protyle ? protyle.options.history?.created : false;- const snapshot = protyle ? protyle.options.history?.snapshot : false;+ const created = protyle.options.history?.created;+ const snapshot = protyle.options.history?.snapshot;const response = await fetchSyncPost(created ? "/api/av/renderHistoryAttributeView" : (snapshot ? "/api/av/renderSnapshotAttributeView" : "/api/av/renderAttributeView"), {id: e.getAttribute("data-av-id"),created,@@ -588,7 +588,7 @@ export const avRender = async (element: Element, protyle: IProtyle, cb?: (data:</div>`;if (renderAll) {e.firstElementChild.outerHTML = `<div class="av__container">- ${genTabHeaderHTML(data, resetData.isSearching || !!resetData.query, protyle ? (!protyle.disabled && !hasClosestByAttribute(e, "data-type", "NodeBlockQueryEmbed")) : false)}+ ${genTabHeaderHTML(data, resetData.isSearching || !!resetData.query, !protyle.disabled && !hasClosestByAttribute(e, "data-type", "NodeBlockQueryEmbed"))}<div class="av__scroll">${avBodyHTML}</div>