Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/6359

Vanessa89418f95d4e1
diff --git a/app/src/block/util.ts b/app/src/block/util.ts
index b9ee773efd..8a105154b2 100644
--- a/app/src/block/util.ts
+++ b/app/src/block/util.ts
@@ -63,7 +63,7 @@ export const genSBElement = (layout: string, id?: string, attrHTML?: string) =>
return sbElement;
};
-export const jumpToParentNext = (protyle:IProtyle,nodeElement: Element) => {
+export const jumpToParentNext = (protyle: IProtyle, nodeElement: Element) => {
const topElement = getTopAloneElement(nodeElement);
if (topElement) {
const topParentElement = hasClosestByClassName(topElement, "list") || hasClosestByClassName(topElement, "bq") || hasClosestByClassName(topElement, "sb") || topElement;
@@ -97,14 +97,6 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id
if (!blockElement) {
return;
}
- let previousID;
- if (position === "beforebegin") {
- if (blockElement.previousElementSibling) {
- previousID = blockElement.previousElementSibling.getAttribute("data-node-id");
- }
- } else {
- previousID = blockElement.getAttribute("data-node-id");
- }
let newElement = genEmptyElement(false, true);
let orderIndex = 1;
if (blockElement.getAttribute("data-type") === "NodeListItem") {
@@ -119,13 +111,23 @@ export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id
updateListOrder(newElement.parentElement, orderIndex);
updateTransaction(protyle, newElement.parentElement.getAttribute("data-node-id"), newElement.parentElement.outerHTML, parentOldHTML);
} else {
- transaction(protyle, [{
- action: "insert",
- data: newElement.outerHTML,
- id: newId,
- previousID,
- parentID: blockElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID
- }], [{
+ let doOperations: IOperation[]
+ if (position === "beforebegin") {
+ doOperations = [{
+ action: "insert",
+ data: newElement.outerHTML,
+ id: newId,
+ nextID: blockElement.getAttribute("data-node-id"),
+ }];
+ } else {
+ doOperations = [{
+ action: "insert",
+ data: newElement.outerHTML,
+ id: newId,
+ previousID: blockElement.getAttribute("data-node-id"),
+ }];
+ }
+ transaction(protyle, doOperations, [{
action: "delete",
id: newId,
}]);