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/8554 跨块剪切后撤销显示不完全
Vanessa7e8d0c29c943
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex a19bed0b0c..74b2e6f09d 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -62,7 +62,8 @@ import {getImageBlockRefCheckTargets,getRangeBlockRefCheckTargets,IBlockRefCheckTargets,- removeBlock+ removeBlock,+ removeCrossBlockRange} from "./remove";import {highlightRender} from "../render/highlightRender";import {openAttr} from "../../menus/commonMenuItem";@@ -2562,16 +2563,18 @@ export class WYSIWYG {autoSelectedBlock = true;}const selectedStateElements = [...selectElements];+ const endElement = hasClosestBlock(range.endContainer);+ const cutCrossBlockRange = selectedStateElements.length === 0 && !range.collapsed &&+ !!endElement && nodeElement !== endElement && !selectImgElement && !selectAVElement && !selectTableElement;let cutClipboardWritten = false;if (selectedStateElements.length === 0 && (!range.collapsed || selectImgElement) &&!selectAVElement && !selectTableElement) {- const endElement = hasClosestBlock(range.endContainer);let checkTargets: IBlockRefCheckTargets = {elements: [], exactIDs: []};if (selectImgElement) {checkTargets = getImageBlockRefCheckTargets(nodeElement, selectImgElement);} else if (endElement) {checkTargets = getRangeBlockRefCheckTargets(- protyle.wysiwyg.element, range, nodeElement, endElement);+ protyle.wysiwyg.element, range, nodeElement, endElement, cutCrossBlockRange);}const checkIDs = checkTargets.elements.map(item => item.getAttribute("data-node-id")).filter(Boolean);@@ -2596,6 +2599,26 @@ export class WYSIWYG {cutClipboardWritten = true;}}+ if (cutCrossBlockRange) {+ if (!cutClipboardWritten) {+ const clipboardData = new DataTransfer();+ this.element.dispatchEvent(new ClipboardEvent("copy", {+ bubbles: true,+ cancelable: true,+ clipboardData,+ }));+ if (clipboardData.types.length === 0) {+ showMessage(window.siyuan.languages.clipboardPermissionDenied, 7000, "error");+ return;+ }+ Array.from(clipboardData.types).forEach(type => {+ event.clipboardData.setData(type, clipboardData.getData(type));+ });+ }+ await removeCrossBlockRange(protyle, range, nodeElement, endElement, true);+ protyle.hint.render(protyle);+ return;+ }let html = "";let textPlain = "";let isInCodeBlock = false;diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 28a5332deb..1f5c39071d 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -241,7 +241,8 @@ IBlockRefCheckTargets => {};export const removeCrossBlockRange = async (protyle: IProtyle, selectedRange: Range,- startElement: HTMLElement, endElement: HTMLElement) => {+ startElement: HTMLElement, endElement: HTMLElement,+ skipRefCheck = false) => {const editorElement = protyle.wysiwyg.element;const context = getCrossBlockRemovalContext(editorElement, selectedRange, startElement, endElement);const {@@ -256,18 +257,20 @@ export const removeCrossBlockRange = async (protyle: IProtyle, selectedRange: Raif (removeElements.length === 0 && updateElements.length === 0) {return;}- const checkTargets = getBlockRefCheckTargetsFromContext(context, context.removeElements);- const checkIDs = checkTargets.elements.map(item => item.getAttribute("data-node-id")).filter(Boolean);- if (checkIDs.length > 0 && !await confirmBlockRef({- scope: "blocks",- ids: checkIDs,- exactIDs: checkTargets.exactIDs,- notebook: protyle.notebookId,- }, protyle)) {- return;- }- if (checkTargets.elements.some(item => !item.isConnected || item.getAttribute("data-node-id") === null)) {- return;+ if (!skipRefCheck) {+ const checkTargets = getBlockRefCheckTargetsFromContext(context, context.removeElements);+ const checkIDs = checkTargets.elements.map(item => item.getAttribute("data-node-id")).filter(Boolean);+ if (checkIDs.length > 0 && !await confirmBlockRef({+ scope: "blocks",+ ids: checkIDs,+ exactIDs: checkTargets.exactIDs,+ notebook: protyle.notebookId,+ }, protyle)) {+ return;+ }+ if (checkTargets.elements.some(item => !item.isConnected || item.getAttribute("data-node-id") === null)) {+ return;+ }}const undoFocusContext = getUndoFocusContext(editorElement, selectedRange, true);