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/16051
Vanessa4d2d0a8d4cf6
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex b6552ab720..aa11682fed 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -626,6 +626,14 @@ export class Gutter {selectsElement,type: "Blocks2Blockquote"}));+ turnIntoSubmenu.push(this.turnsIntoOne({+ menuId: "callout",+ icon: "iconCallout",+ label: window.siyuan.languages.callout,+ protyle,+ selectsElement,+ type: "Blocks2Callout"+ }));}turnIntoSubmenu.push(this.turnsInto({menuId: "paragraph",@@ -1007,6 +1015,14 @@ export class Gutter {selectsElement: [nodeElement],type: "Blocks2Blockquote"}));+ turnIntoSubmenu.push(this.turnsIntoOne({+ menuId: "callout",+ icon: "iconCallout",+ label: window.siyuan.languages.callout,+ protyle,+ selectsElement: [nodeElement],+ type: "Blocks2Callout"+ }));turnIntoSubmenu.push(this.turnsInto({menuId: "heading1",icon: "iconH1",@@ -1086,6 +1102,14 @@ export class Gutter {selectsElement: [nodeElement],type: "Blocks2Blockquote"}));+ turnIntoSubmenu.push(this.turnsIntoOne({+ menuId: "callout",+ icon: "iconCallout",+ label: window.siyuan.languages.callout,+ protyle,+ selectsElement: [nodeElement],+ type: "Blocks2Callout"+ }));if (subType !== "h1") {turnIntoSubmenu.push(this.turnsInto({menuId: "heading1",@@ -1178,6 +1202,14 @@ export class Gutter {selectsElement: [nodeElement],type: "Blocks2Blockquote"}));+ turnIntoSubmenu.push(this.turnsIntoOne({+ menuId: "callout",+ icon: "iconCallout",+ label: window.siyuan.languages.callout,+ protyle,+ selectsElement: [nodeElement],+ type: "Blocks2Callout"+ }));if (nodeElement.getAttribute("data-subtype") === "o") {turnIntoSubmenu.push(this.turnsOneInto({menuId: "list",diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 9b749c0934..e8742debfc 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -162,11 +162,14 @@ const promiseTransaction = () => {} else if (updateElements.length > 0) {Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.parentID}"]`)).forEach(item => {if (!isInEmbedBlock(item) && !getFirstBlock(item).contains(range.startContainer)) {+ const cloneElement = processClonePHElement(updateElements[0].cloneNode(true) as Element);// 列表特殊处理if (item.firstElementChild?.classList.contains("protyle-action")) {- item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));+ item.firstElementChild.after(cloneElement);+ } else if (item.classList.contains("callout")) {+ item.querySelector(".callout-content").prepend(cloneElement);} else {- item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));+ item.prepend(cloneElement);}hasFind = true;}@@ -208,10 +211,14 @@ const promiseTransaction = () => {if (!isInEmbedBlock(item) && !item.contains(range.startContainer)) {// 列表特殊处理if (item.firstElementChild && item.firstElementChild.classList.contains("protyle-action") &&- item.firstElementChild.nextElementSibling.getAttribute("data-node-id") !== operation.id) {+ item.firstElementChild.nextElementSibling?.getAttribute("data-node-id") !== operation.id) {item.firstElementChild.insertAdjacentHTML("afterend", operation.data);cursorElements.push(item.firstElementChild.nextElementSibling);- } else if (item.firstElementChild && item.firstElementChild.getAttribute("data-node-id") !== operation.id) {+ } else if (item.classList.contains("callout") &&+ item.querySelector('[data-node-id]')?.getAttribute("data-node-id") !== operation.id) {+ item.querySelector(".callout-content").insertAdjacentHTML("afterbegin", operation.data);+ cursorElements.push(item.querySelector('[data-node-id]'));+ } else if (item.firstElementChild.getAttribute("data-node-id") !== operation.id) {item.insertAdjacentHTML("afterbegin", operation.data);cursorElements.push(item.firstElementChild);}@@ -719,11 +726,14 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:} else {parentElement.forEach(item => {if (!isInEmbedBlock(item)) {+ const cloneElement = processClonePHElement(updateElements[0].cloneNode(true) as Element);// 列表特殊处理if (item.firstElementChild?.classList.contains("protyle-action")) {- item.firstElementChild.after(processClonePHElement(updateElements[0].cloneNode(true) as Element));+ item.firstElementChild.after(cloneElement);+ } else if (item.classList.contains("callout")) {+ item.querySelector(".callout-content").prepend(cloneElement);} else {- item.prepend(processClonePHElement(updateElements[0].cloneNode(true) as Element));+ item.prepend(cloneElement);}hasFind = true;}@@ -825,6 +835,9 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:if (item.firstElementChild?.classList.contains("protyle-action")) {item.firstElementChild.insertAdjacentHTML("afterend", operation.data);cursorElements.push(item.firstElementChild.nextElementSibling);+ } else if (item.classList.contains("callout")) {+ item.querySelector(".callout-content").insertAdjacentHTML("afterbegin", operation.data);+ cursorElements.push(item.querySelector('[data-node-id]'));} else {item.insertAdjacentHTML("afterbegin", operation.data);cursorElements.push(item.firstElementChild);@@ -923,14 +936,15 @@ export const turnsIntoOneTransaction = (options: {parentElement.classList.add("bq");parentElement.setAttribute("data-node-id", id);parentElement.setAttribute("data-type", "NodeBlockquote");- parentElement.innerHTML = '<div class="protyle-attr" contenteditable="false"></div>';+ parentElement.innerHTML = `<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;} else if (options.type === "Blocks2Callout") {- // TODOparentElement = document.createElement("div");- parentElement.classList.add("bq");+ parentElement.classList.add("callout");parentElement.setAttribute("data-node-id", id);- parentElement.setAttribute("data-type", "NodeBlockquote");- parentElement.innerHTML = '<div class="protyle-attr" contenteditable="false"></div>';+ parentElement.setAttribute("data-type", "NodeCallout");+ parentElement.setAttribute("contenteditable", "false");+ parentElement.setAttribute("data-subtype", "NOTE");+ parentElement.innerHTML = `<div class="callout-info"><span class="callout-icon">✏️</span><span class="callout-title">Note</span></div><div class="callout-content"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;} else if (options.type.endsWith("Ls")) {parentElement = document.createElement("div");parentElement.classList.add("list");@@ -989,6 +1003,14 @@ export const turnsIntoOneTransaction = (options: {parentID: parentElement.children[index].getAttribute("data-node-id")});parentElement.children[index].firstElementChild.after(item);+ } else if (options.type === "Blocks2Callout") {+ doOperations.push({+ action: "move",+ id: itemId,+ previousID: itemPreviousId,+ parentID: id+ });+ parentElement.querySelector(".callout-content").insertAdjacentElement("beforeend", item);} else {doOperations.push({action: "move",