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/11656
Vanessa6acf780269b5
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 6c17443ef3..50f3091546 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -54,6 +54,7 @@ import {avContextmenu, duplicateCompletely} from "../render/av/action";import {getPlainText} from "../util/paste";import {Menu} from "../../plugin/Menu";import {addEditorToDatabase} from "../render/av/addToDatabase";+import {processClonePHElement} from "../render/util";export class Gutter {public element: HTMLElement;@@ -111,7 +112,7 @@ export class Gutter {getContenteditableElement(embedElement).innerHTML = `<svg class="svg"><use xlink:href="${buttonElement.querySelector("use").getAttribute("xlink:href")}"></use></svg> ${getLangByType(type)}`;ghostElement.append(embedElement);} else {- ghostElement.append(item.cloneNode(true));+ ghostElement.append(processClonePHElement(item.cloneNode(true) as Element));}});ghostElement.setAttribute("style", `position:fixed;opacity:.1;width:${selectElements[0].clientWidth}px;padding:0;`);diff --git a/app/src/protyle/render/util.ts b/app/src/protyle/render/util.tsindex 0a72f7f42f..dee0bac8c3 100644--- a/app/src/protyle/render/util.ts+++ b/app/src/protyle/render/util.ts@@ -13,3 +13,11 @@ export const genIconHTML = (element?: false|HTMLElement) => {<span aria-label="${window.siyuan.languages.more}" class="b3-tooltips__nw b3-tooltips protyle-icon protyle-action__menu protyle-icon--last${enable ? "" : " protyle-icon--first"}"><svg><use xlink:href="#iconMore"></use></svg></span></div>`;};++export const processClonePHElement = (item:Element) => {+ if (item.getAttribute("data-type") === "NodeHTMLBlock") {+ const phElement = item.querySelector("protyle-html");+ phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));+ }+ return item;+}diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.tsindex 959fb5b005..7b1dee5053 100644--- a/app/src/protyle/wysiwyg/commonHotkey.ts+++ b/app/src/protyle/wysiwyg/commonHotkey.ts@@ -16,6 +16,7 @@ import {onGet} from "../util/onGet";import {Constants} from "../../constants";import * as dayjs from "dayjs";import {net2LocalAssets} from "../breadcrumb/action";+import {processClonePHElement} from "../render/util";export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.copyHPath.custom, event)) {@@ -211,15 +212,7 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {tempElement.setAttribute("data-marker", (orderIndex) + ".");tempElement.querySelector(".protyle-action--order").textContent = (orderIndex) + ".";}- if (tempElement.dataset.type === "NodeHTMLBlock") {- const phElement = tempElement.querySelector("protyle-html");- const content = phElement.getAttribute("data-content");- phElement.setAttribute("data-content", "");- nodeElements[0].after(tempElement);- phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(content));- } else {- nodeElements[0].after(tempElement);- }+ nodeElements[0].after(processClonePHElement(tempElement));doOperations.push({action: "insert",data: tempElement.outerHTML,diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 490fb95576..474c071c26 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -19,6 +19,7 @@ import {reloadProtyle} from "../util/reload";import {countBlockWord} from "../../layout/status";import {isPaidUser, needSubscribe} from "../../util/needSubscribe";import {resize} from "../util/resize";+import {processClonePHElement} from "../render/util";const removeTopElement = (updateElement: Element, protyle: IProtyle) => {// 移动到其他文档中,该块需移除@@ -207,7 +208,7 @@ const promiseTransaction = () => {if (operation.previousID && updateElements.length > 0) {Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {- item.after(updateElements[0].cloneNode(true));+ item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));hasFind = true;}});@@ -216,9 +217,9 @@ const promiseTransaction = () => {if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {// 列表特殊处理if (item.firstElementChild?.classList.contains("protyle-action")) {- item.firstElementChild.after(updateElements[0].cloneNode(true));+ item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));} else {- item.prepend(updateElements[0].cloneNode(true));+ item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));}hasFind = true;}@@ -638,22 +639,22 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:if (operation.previousID && updateElements.length > 0) {Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`)).forEach(item => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {- item.after(updateElements[0].cloneNode(true));+ item.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));hasFind = true;}});} else if (updateElements.length > 0) {if (!protyle.options.backlinkData && operation.parentID === protyle.block.parentID) {- protyle.wysiwyg.element.prepend(updateElements[0].cloneNode(true));+ protyle.wysiwyg.element.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));hasFind = true;} else {Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`)).forEach(item => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {// 列表特殊处理if (item.firstElementChild?.classList.contains("protyle-action")) {- item.firstElementChild.after(updateElements[0].cloneNode(true));+ item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));} else {- item.prepend(updateElements[0].cloneNode(true));+ item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));}hasFind = true;}