Skip to content

Commit

Permalink
🎨 fix #11555
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 27, 2024
1 parent b275690 commit 4798658
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions app/src/protyle/util/editorCommonEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {hideElements} from "../ui/hideElements";
import {insertAttrViewBlockAnimation} from "../render/av/row";
import {dragUpload} from "../render/av/asset";
import * as dayjs from "dayjs";
import {zoomOut} from "../../menus/protyle";

const moveToNew = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, newSourceElement: Element,
isSameDoc: boolean, isBottom: boolean, isCopy: boolean) => {
Expand Down Expand Up @@ -520,18 +521,22 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
if (editor && editor.model instanceof Editor && editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
const newId = Lute.NewNodeID();
doOperations.splice(0, 0, {
action: "insert",
id: newId,
data: genEmptyElement(false, false, newId).outerHTML,
parentID: editor.model.editor.protyle.block.parentID
});
undoOperations.splice(0, 0, {
action: "delete",
id: newId,
});
if (editor && editor.model instanceof Editor) {
if (editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
const newId = Lute.NewNodeID();
doOperations.splice(0, 0, {
action: "insert",
id: newId,
data: genEmptyElement(false, false, newId).outerHTML,
parentID: editor.model.editor.protyle.block.parentID
});
undoOperations.splice(0, 0, {
action: "delete",
id: newId,
});
} else {
zoomOut({protyle: editor.model.editor.protyle, id: editor.model.editor.protyle.block.rootID});
}
}
}
/// #endif
Expand Down Expand Up @@ -680,18 +685,23 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
if (editor && editor.model instanceof Editor && editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
const newId = Lute.NewNodeID();
doOperations.splice(0, 0, {
action: "insert",
id: newId,
data: genEmptyElement(false, false, newId).outerHTML,
parentID: editor.model.editor.protyle.block.parentID
});
undoOperations.splice(0, 0, {
action: "delete",
id: newId,
});
if (editor && editor.model instanceof Editor) {
if (editor.model.editor.protyle.block.id === editor.model.editor.protyle.block.rootID) {
const newId = Lute.NewNodeID();
doOperations.splice(0, 0, {
action: "insert",
id: newId,
data: genEmptyElement(false, false, newId).outerHTML,
parentID: editor.model.editor.protyle.block.parentID
});
undoOperations.splice(0, 0, {
action: "delete",
id: newId,
});
} else {
zoomOut({protyle: editor.model.editor.protyle, id: editor.model.editor.protyle.block.rootID});
}

}
}
/// #endif
Expand Down

0 comments on commit 4798658

Please sign in to comment.