Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/6665

Vanessaad3aaab34a44
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
index d009dfd188..494487cb35 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy
@@ -7,7 +7,7 @@
"id": "20200924100950-9op5xi1",
"title": "Shortcuts",
"type": "doc",
- "updated": "20221109143648"
+ "updated": "20221123220150"
},
"Children": [
{
@@ -7603,7 +7603,7 @@
"Properties": {
"colgroup": "|",
"id": "20210601185420-1s8e9uy",
- "updated": "20221105230819"
+ "updated": "20221123220150"
},
"Children": [
{
@@ -7652,7 +7652,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Move"
+ "Data": "Open the menu"
}
]
},
@@ -7667,7 +7667,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Drag"
+ "TextMarkTextContent": "Click"
},
{
"Type": "NodeText",
@@ -7687,7 +7687,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Open the menu"
+ "Data": "Zoom in"
}
]
},
@@ -7702,7 +7702,16 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Click"
+ "TextMarkTextContent": "Ctrl+Click"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌘Click"
},
{
"Type": "NodeText",
@@ -7722,7 +7731,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Zoom in"
+ "Data": "Collapse/Expand"
}
]
},
@@ -7737,7 +7746,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Ctrl+Click"
+ "TextMarkTextContent": "Alt+Click"
},
{
"Type": "NodeText",
@@ -7746,7 +7755,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌘Click"
+ "TextMarkTextContent": "⌥Click"
},
{
"Type": "NodeText",
@@ -7766,7 +7775,11 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Collapse/Expand"
+ "Data": "Attributes"
+ },
+ {
+ "Type": "NodeBr",
+ "Data": "br"
}
]
},
@@ -7781,7 +7794,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Alt+Click"
+ "TextMarkTextContent": "Shift+Click"
},
{
"Type": "NodeText",
@@ -7790,7 +7803,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌥Click"
+ "TextMarkTextContent": "⇧Click"
},
{
"Type": "NodeText",
@@ -7810,11 +7823,42 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Attributes"
+ "Data": "Move"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
},
{
- "Type": "NodeBr",
- "Data": "br"
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Drag"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Copy and move"
}
]
},
@@ -7829,7 +7873,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Click"
+ "TextMarkTextContent": "Ctrl+Drag"
},
{
"Type": "NodeText",
@@ -7838,7 +7882,95 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⇧Click"
+ "TextMarkTextContent": "⌃+Drag"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Generate block ref"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Alt+Drag"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌥+Drag"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Generate embed block"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift+Drag"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⇧+Drag"
},
{
"Type": "NodeText",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
index 2dc7778e84..97cabd428a 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy
@@ -7,7 +7,7 @@
"id": "20200813004551-gm0pbn1",
"title": "快捷键",
"type": "doc",
- "updated": "20221109143355"
+ "updated": "20221123214805"
},
"Children": [
{
@@ -7572,7 +7572,7 @@
"Properties": {
"colgroup": "|",
"id": "20210526200223-xyuqsge",
- "updated": "20221105230414"
+ "updated": "20221123214805"
},
"Children": [
{
@@ -7617,7 +7617,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "移动"
+ "Data": "打开菜单"
}
]
},
@@ -7632,11 +7632,11 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "拖拽"
+ "TextMarkTextContent": "Click"
},
{
"Type": "NodeText",
- "Data": "​"
+ "Data": "​​"
}
]
}
@@ -7652,7 +7652,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "打开菜单"
+ "Data": "聚焦进入"
}
]
},
@@ -7667,11 +7667,64 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Click"
+ "TextMarkTextContent": "Ctrl+Click"
},
+ {
+ "Type": "NodeText",
+ "Data": "​​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌘Click"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "折叠/展开"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
{
"Type": "NodeText",
"Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Alt+Click"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌥Click"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​"
}
]
}
@@ -7687,7 +7740,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "聚焦进入"
+ "Data": "属性"
}
]
},
@@ -7702,20 +7755,55 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Ctrl+Click"
+ "TextMarkTextContent": "Shift+Click"
},
{
"Type": "NodeText",
- "Data": "​ / "
+ "Data": "​​ / "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌘Click"
+ "TextMarkTextContent": "⇧Click"
},
+ {
+ "Type": "NodeText",
+ "Data": "​​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "移动"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
{
"Type": "NodeText",
"Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​"
}
]
}
@@ -7731,7 +7819,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "折叠/展开"
+ "Data": "复制并移动"
}
]
},
@@ -7746,20 +7834,20 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Alt+Click"
+ "TextMarkTextContent": "Ctrl+拖拽"
},
{
"Type": "NodeText",
- "Data": "​ / "
+ "Data": "​​ / "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌥Click"
+ "TextMarkTextContent": "⌃+拖拽"
},
{
"Type": "NodeText",
- "Data": "​"
+ "Data": "​​"
}
]
}
@@ -7775,7 +7863,11 @@
"Children": [
{
"Type": "NodeText",
- "Data": "属性"
+ "Data": "生成块"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "引用"
}
]
},
@@ -7790,20 +7882,64 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Click"
+ "TextMarkTextContent": "Alt+拖拽"
},
{
"Type": "NodeText",
- "Data": "​ / "
+ "Data": "​​ / "
},
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⇧Click"
+ "TextMarkTextContent": "⌥+拖拽"
},
+ {
+ "Type": "NodeText",
+ "Data": "​​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "生成嵌入块"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
{
"Type": "NodeText",
"Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⇧+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​​"
}
]
}
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
index 785d12a32c..778c0ebd55 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy
@@ -6,7 +6,7 @@
"icon": "2328",
"id": "20211226122549-jktxego",
"title": "快捷鍵",
- "updated": "20221109143714"
+ "updated": "20221123220121"
},
"Children": [
{
@@ -7604,7 +7604,7 @@
"Properties": {
"colgroup": "|",
"id": "20211226122652-ykdt6pc",
- "updated": "20221105230731"
+ "updated": "20221123220121"
},
"Children": [
{
@@ -7649,7 +7649,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "移動"
+ "Data": "打開菜單"
}
]
},
@@ -7664,7 +7664,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "拖拽"
+ "TextMarkTextContent": "Click"
},
{
"Type": "NodeText",
@@ -7684,7 +7684,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "打開菜單"
+ "Data": "聚焦進入"
}
]
},
@@ -7699,7 +7699,16 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Click"
+ "TextMarkTextContent": "Ctrl+Click"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌘Click"
},
{
"Type": "NodeText",
@@ -7719,7 +7728,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "聚焦進入"
+ "Data": "摺疊/展開"
}
]
},
@@ -7734,7 +7743,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Ctrl+Click"
+ "TextMarkTextContent": "Alt+Click"
},
{
"Type": "NodeText",
@@ -7743,7 +7752,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌘Click"
+ "TextMarkTextContent": "⌥Click"
},
{
"Type": "NodeText",
@@ -7763,7 +7772,11 @@
"Children": [
{
"Type": "NodeText",
- "Data": "摺疊/展開"
+ "Data": "屬性"
+ },
+ {
+ "Type": "NodeBr",
+ "Data": "br"
}
]
},
@@ -7778,7 +7791,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Alt+Click"
+ "TextMarkTextContent": "Shift+Click"
},
{
"Type": "NodeText",
@@ -7787,7 +7800,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⌥Click"
+ "TextMarkTextContent": "⇧Click"
},
{
"Type": "NodeText",
@@ -7807,11 +7820,42 @@
"Children": [
{
"Type": "NodeText",
- "Data": "屬性"
+ "Data": "移動"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
},
{
- "Type": "NodeBr",
- "Data": "br"
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "複製並移動"
}
]
},
@@ -7826,7 +7870,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "Shift+Click"
+ "TextMarkTextContent": "Ctrl+拖拽"
},
{
"Type": "NodeText",
@@ -7835,7 +7879,95 @@
{
"Type": "NodeTextMark",
"TextMarkType": "kbd",
- "TextMarkTextContent": "⇧Click"
+ "TextMarkTextContent": "⌃+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "生成塊引用"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Alt+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⌥+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableRow",
+ "Data": "tr",
+ "Children": [
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "生成嵌入塊"
+ }
+ ]
+ },
+ {
+ "Type": "NodeTableCell",
+ "Data": "td",
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "​"
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Shift+拖拽"
+ },
+ {
+ "Type": "NodeText",
+ "Data": "​ / "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "⇧+拖拽"
},
{
"Type": "NodeText",
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 1bdb88225e..8cdd2b285d 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -20,7 +20,8 @@ import {insertHTML} from "./insertHTML";
import {isBrowser} from "../../util/functions";
import {hideElements} from "../ui/hideElements";
-const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isSameDoc: boolean, position: InsertPosition) => {
+const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element,
+ isSameDoc: boolean, position: InsertPosition, isCopy: boolean) => {
let topSourceElement;
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
@@ -43,28 +44,57 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
item.removeAttribute("fold");
foldHeadingIds.push({id, parentID});
}
- undoOperations.push({
- action: "move",
- id,
- previousID: item.previousElementSibling?.getAttribute("data-node-id"),
- parentID,
- });
- if (!isSameDoc) {
+ let copyId
+ let copyElement
+ if (isCopy) {
+ copyId = Lute.NewNodeID();
+ undoOperations.push({
+ action: "delete",
+ id: copyId,
+ });
+ } else {
+ undoOperations.push({
+ action: "move",
+ id,
+ previousID: item.previousElementSibling?.getAttribute("data-node-id"),
+ parentID,
+ });
+ }
+ if (!isSameDoc && !isCopy) {
// 打开两个相同的文档
const sameElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`);
if (sameElement) {
sameElement.remove();
}
}
- tempTargetElement.insertAdjacentElement(position, item);
- doOperations.push({
- action: "move",
- id,
- previousID: position === "afterend" ? targetId : item.previousElementSibling?.getAttribute("data-node-id"), // 不能使用常量,移动后会被修改
- parentID: item.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID,
- });
+
+ if (isCopy) {
+ copyElement = item.cloneNode(true) as HTMLElement;
+ copyElement.setAttribute("data-node-id", copyId);
+ copyElement.querySelectorAll("[data-node-id]").forEach((e) => {
+ const newId = Lute.NewNodeID();
+ e.setAttribute("data-node-id", newId);
+ e.setAttribute("updated", newId.split("-")[0]);
+ });
+ tempTargetElement.insertAdjacentElement(position, copyElement);
+ doOperations.push({
+ action: "insert",
+ id: copyId,
+ data: copyElement.outerHTML,
+ previousID: position === "afterend" ? targetId : item.previousElementSibling?.getAttribute("data-node-id"), // 不能使用常量,移动后会被修改
+ parentID: item.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID,
+ });
+ } else {
+ tempTargetElement.insertAdjacentElement(position, item);
+ doOperations.push({
+ action: "move",
+ id,
+ previousID: position === "afterend" ? targetId : item.previousElementSibling?.getAttribute("data-node-id"), // 不能使用常量,移动后会被修改
+ parentID: item.parentElement?.getAttribute("data-node-id") || protyle.block.parentID || protyle.block.rootID,
+ });
+ }
if (position !== "afterend") {
- tempTargetElement = item;
+ tempTargetElement = isCopy ? copyElement : item;
}
});
undoOperations.reverse();
@@ -353,7 +383,7 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
focusBlock(sourceElements[0]);
};
-const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean) => {
+const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean, isCopy: boolean) => {
const isSameDoc = protyle.element.contains(sourceElements[0]);
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
@@ -425,7 +455,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
id: newSourceElement.getAttribute("data-node-id"),
});
} else {
- const moveToResult = await moveTo(protyle, sourceElements, targetElement, isSameDoc, "afterend");
+ const moveToResult = await moveTo(protyle, sourceElements, targetElement, isSameDoc, "afterend", isCopy);
doOperations.push(...moveToResult.doOperations);
undoOperations.push(...moveToResult.undoOperations);
topSourceElement = moveToResult.topSourceElement;
@@ -485,7 +515,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
id: newSourceElement.getAttribute("data-node-id"),
});
} else {
- const moveToResult = await moveTo(protyle, sourceElements, targetElement, isSameDoc, "beforebegin");
+ const moveToResult = await moveTo(protyle, sourceElements, targetElement, isSameDoc, "beforebegin", isCopy);
doOperations.push(...moveToResult.doOperations);
undoOperations.push(...moveToResult.undoOperations);
topSourceElement = moveToResult.topSourceElement;
@@ -515,7 +545,8 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
});
});
}
- if (oldSourceParentElement && oldSourceParentElement.classList.contains("list") &&
+ if (!isCopy &&
+ oldSourceParentElement && oldSourceParentElement.classList.contains("list") &&
oldSourceParentElement.getAttribute("data-subtype") === "o" &&
!oldSourceParentElement.isSameNode(sourceElements[0].parentElement) && oldSourceParentElement.childElementCount > 1) {
Array.from(oldSourceParentElement.children).forEach((item) => {
@@ -550,7 +581,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
}
// 删除空元素
- if (topSourceElement) {
+ if (!isCopy && topSourceElement) {
doOperations.push({
action: "delete",
id: topSourceElement.getAttribute("data-node-id"),
@@ -572,12 +603,12 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
}
}
}
- if (oldSourceParentElement && oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
+ if (!isCopy && oldSourceParentElement && oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
// 拖拽后,sb 只剩下一个元素
const sbData = cancelSB(protyle, oldSourceParentElement);
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
undoOperations.splice(0, 0, sbData.undoOperations[0], sbData.undoOperations[1]);
- } else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.childElementCount === 0) {
+ } else if (!isCopy && oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.childElementCount === 0) {
/// #if !MOBILE
// 拖拽后,根文档原内容为空,且不为悬浮窗
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
@@ -599,7 +630,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
}
/// #endif
}
- if (isSameDoc) {
+ if (isSameDoc || isCopy) {
transaction(protyle, doOperations, undoOperations);
} else {
// 跨文档不支持撤销
@@ -686,7 +717,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
targetElement.parentElement.getAttribute("data-sb-layout") === "col") {
if (targetClass.includes("dragover__left") || targetClass.includes("dragover__right")) {
- dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__right"));
+ dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__right"), event.ctrlKey);
} else {
dragSb(protyle, sourceElements, targetElement, targetClass.includes("dragover__bottom"), "row");
}
@@ -694,7 +725,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
if (targetClass.includes("dragover__left") || targetClass.includes("dragover__right")) {
dragSb(protyle, sourceElements, targetElement, targetClass.includes("dragover__right"), "col");
} else {
- dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__bottom"));
+ dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__bottom"), event.ctrlKey);
}
}
}
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 0a941b27d7..09397e3bec 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -227,9 +227,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
const newId = Lute.NewNodeID();
e.setAttribute("data-node-id", newId);
e.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");
- if (e.getAttribute("updated")) {
- e.setAttribute("updated", newId.split("-")[0]);
- }
+ e.setAttribute("updated", newId.split("-")[0]);
isBlock = true;
});
if (nodeElement.classList.contains("table")) {