Vanessa 2024-03-29 20:48:02 +08:00
parent 3ec244ad09
commit 66360757b3
2 changed files with 49 additions and 22 deletions

View file

@ -272,28 +272,48 @@ export class Outline extends Model {
documentSelf.onselect = null;
ghostElement.remove();
item.style.opacity = "";
if (selectItem) {
getAllModels().editor.find(editItem => {
if (editItem.editor.protyle.block.rootID === this.blockId) {
let previousID
let parentID
const undoPreviousID = item.previousElementSibling?.getAttribute("data-node-id")
const undoParentID = item.parentElement.previousElementSibling?.getAttribute("data-node-id")
if (selectItem.classList.contains("dragover")) {
parentID = selectItem.getAttribute("data-node-id");
if (selectItem.nextElementSibling && selectItem.nextElementSibling.tagName === "UL") {
selectItem.nextElementSibling.insertAdjacentElement("afterbegin", item);
} else {
selectItem.insertAdjacentHTML("afterend", `<ul>${item.outerHTML}</ul>`);
item.remove();
}
} else if (selectItem.classList.contains("dragover__top")) {
parentID = selectItem.parentElement.previousElementSibling?.getAttribute("data-node-id");
previousID = selectItem.previousElementSibling?.getAttribute("data-node-id");
selectItem.before(item);
} else if (selectItem.classList.contains("dragover__bottom")) {
previousID = selectItem.getAttribute("data-node-id");
selectItem.after(item);
}
transaction(editItem.editor.protyle, [{
action: "moveOutlineHeading",
id: item.dataset.nodeId,
previousID,
parentID,
}], [{
action: "moveOutlineHeading",
id: item.dataset.nodeId,
previousID: undoPreviousID,
parentID: undoParentID,
}]);
return true;
}
});
}
this.element.querySelectorAll(".dragover__top, .dragover__bottom, .dragover").forEach(item => {
item.classList.remove("dragover__top", "dragover__bottom", "dragover");
});
if (!selectItem) {
return;
}
getAllModels().editor.find(editItem => {
if (editItem.editor.protyle.block.rootID === this.blockId) {
transaction(editItem.editor.protyle, [{
action: "moveOutlineHeading",
id: item.dataset.nodeId,
previousID: selectItem.previousElementSibling?.getAttribute("data-node-id"),
parentID: selectItem.parentElement.previousElementSibling?.getAttribute("data-node-id"),
}], [{
action: "moveOutlineHeading",
id: item.dataset.nodeId,
previousID: item.previousElementSibling?.getAttribute("data-node-id"),
parentID: item.parentElement.previousElementSibling?.getAttribute("data-node-id"),
}]);
return true;
}
});
};
});
}

View file

@ -728,9 +728,13 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
});
// 更新 ws 引用块
updateRef(protyle, operation.id);
} else if (operation.action === "append") {
return;
}
if (operation.action === "append") {
reloadProtyle(protyle, false);
} else if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
return;
}
if (["addAttrViewCol", "insertAttrViewBlock", "updateAttrViewCol", "updateAttrViewColOptions",
"updateAttrViewColOption", "updateAttrViewCell", "sortAttrViewRow", "sortAttrViewCol", "setAttrViewColHidden",
"setAttrViewColWrap", "setAttrViewColWidth", "removeAttrViewColOption", "setAttrViewName", "setAttrViewFilters",
"setAttrViewSorts", "setAttrViewColCalc", "removeAttrViewCol", "updateAttrViewColNumberFormat", "removeAttrViewBlock",
@ -738,10 +742,13 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup"].includes(operation.action)) {
refreshAV(protyle, operation);
} else if (operation.action === "doUpdateUpdated") {
return;
}
if (operation.action === "doUpdateUpdated") {
updateElements.forEach(item => {
item.setAttribute("updated", operation.data);
});
return;
}
};