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/8019
Vanessa468b670bcce6
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex e9032cf70e..8723b81dac 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1798,7 +1798,6 @@ export class WYSIWYG {needClipboardWrite = true;const response = await fetchSyncPost("/api/block/getHeadingChildrenDOM", {id: item.getAttribute("data-node-id")});html += response.data;- setFold(protyle, topElement, undefined, true);} else {html += removeEmbed(topElement);}diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 61501fd70c..c4a91db520 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -23,6 +23,7 @@ import {hasClosestByClassName} from "../util/hasClosest";import {getInstanceById} from "../../layout/util";import {Tab} from "../../layout/Tab";import {Backlink} from "../../layout/dock/Backlink";+import {fetchSyncPost} from "../../util/fetch";export const removeBlock = async (protyle: IProtyle, blockElement: Element, range: Range, type: "Delete" | "Backspace" | "remove") => {protyle.observerLoad?.disconnect();@@ -32,7 +33,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangif (selectElements?.length > 0) {const deletes: IOperation[] = [];const inserts: IOperation[] = [];- let sideElement;+ let sideElement: Element | boolean;let sideIsNext = false;if (type === "Backspace") {sideElement = selectElements[0].previousElementSibling;@@ -52,7 +53,8 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, ranglet topParentElement: Element;hideElements(["select"], protyle);let foldPreviousId: string;- selectElements.find((item: HTMLElement) => {+ for (let i = 0; i < selectElements.length; i++) {+ const item = selectElements[i];const topElement = getTopAloneElement(item);topParentElement = topElement.parentElement;const id = topElement.getAttribute("data-node-id");@@ -79,19 +81,23 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rangsideIsNext = false;}if (topElement.getAttribute("data-type") === "NodeHeading" && topElement.getAttribute("fold") === "1") {- // https://github.com/siyuan-note/siyuan/issues/2188- setFold(protyle, topElement, undefined, true);+ const foldTransaction = await fetchSyncPost("/api/block/getHeadingDeleteTransaction", {+ id: topElement.getAttribute("data-node-id"),+ });+ deletes.push(...foldTransaction.data.doOperations.slice(1));let previousID = topElement.previousElementSibling ? topElement.previousElementSibling.getAttribute("data-node-id") : "";if (typeof foldPreviousId !== "undefined") {previousID = foldPreviousId;}- inserts.push({- action: "insert",- data: topElement.outerHTML,- id,- previousID: previousID,- parentID: topElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID+ foldTransaction.data.undoOperations.forEach((operationItem: IOperation, index: number) => {+ operationItem.previousID = previousID;+ if (index > 0) {+ operationItem.context = {+ ignoreProcess: "true"+ };+ }});+ inserts.push(...foldTransaction.data.undoOperations);// 折叠块和非折叠块同时删除时撤销异常 https://github.com/siyuan-note/siyuan/issues/11312let foldPreviousElement = getPreviousBlock(topElement);while (foldPreviousElement && foldPreviousElement.childElementCount === 3) {@@ -102,17 +108,9 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang} else {foldPreviousId = "";}- // https://github.com/siyuan-note/siyuan/issues/4422+ // // https://github.com/siyuan-note/siyuan/issues/4422topElement.firstElementChild.removeAttribute("contenteditable");- // 在折叠标题后输入文字,然后全选删除再撤销会重建索引。因此不能删除折叠标题后新输入的输入折叠标题下的内容- const nextElement = topElement.nextElementSibling;- if (nextElement) {- const nextType = nextElement.getAttribute("data-type");- if (nextType !== "NodeHeading" ||- (nextType === "NodeHeading" && nextElement.getAttribute("data-subtype") > topElement.getAttribute("data-subtype"))) {- return true;- }- }+ topElement.remove();} else {let data = topElement.outerHTML; // 不能 spin ,否则 li 会变为 listif (topElement.classList.contains("render-node") || topElement.querySelector("div.render-node")) {@@ -136,7 +134,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang}topElement.remove();}- });+ }if (sideElement) {if (protyle.block.showAll && sideElement.classList.contains("protyle-wysiwyg") && protyle.wysiwyg.element.childElementCount === 0) {setTimeout(() => {@@ -164,11 +162,11 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang// https://github.com/siyuan-note/siyuan/issues/10389// https://github.com/siyuan-note/siyuan/issues/10899if (type !== "Backspace" && sideIsNext) {- focusBlock(sideElement);+ focusBlock(sideElement as Element);} else {- focusBlock(sideElement, undefined, false);+ focusBlock(sideElement as Element, undefined, false);}- scrollCenter(protyle, sideElement);+ scrollCenter(protyle, sideElement as Element);if (listElement) {inserts.push({action: "update",diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 94f2014c14..3ca640a084 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -754,6 +754,9 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:return;}if (operation.action === "insert") {+ if (operation.context?.ignoreProcess === "true") {+ return;+ }const cursorElements = [];if (operation.previousID) {const previousElement = protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.previousID}"]`);