|
@@ -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,
|
|
|
}]);
|