mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
f920ce5cf3
commit
a543ec97a5
2 changed files with 9 additions and 4 deletions
|
|
@ -50,7 +50,7 @@ export class Undo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private render(protyle: IProtyle, state: IOperations, redo: boolean) {
|
private render(protyle: IProtyle, state: IOperations, redo: boolean) {
|
||||||
hideElements(["hint"], protyle);
|
hideElements(["hint", "gutter"], protyle);
|
||||||
protyle.wysiwyg.lastHTMLs = {};
|
protyle.wysiwyg.lastHTMLs = {};
|
||||||
if (!redo) {
|
if (!redo) {
|
||||||
state.undoOperations.forEach(item => {
|
state.undoOperations.forEach(item => {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {blockRender} from "../markdown/blockRender";
|
||||||
import {uploadLocalFiles} from "../upload";
|
import {uploadLocalFiles} from "../upload";
|
||||||
import {insertHTML} from "./insertHTML";
|
import {insertHTML} from "./insertHTML";
|
||||||
import {isBrowser} from "../../util/functions";
|
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) => {
|
||||||
let topSourceElement
|
let topSourceElement
|
||||||
|
|
@ -183,6 +184,7 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const foldHeadingIds: { id: string, parentID: string }[] = []
|
const foldHeadingIds: { id: string, parentID: string }[] = []
|
||||||
|
let afterPreviousID
|
||||||
sourceElements.reverse().forEach((item, index) => {
|
sourceElements.reverse().forEach((item, index) => {
|
||||||
const id = item.getAttribute("data-node-id");
|
const id = item.getAttribute("data-node-id");
|
||||||
const parentID = item.parentElement.getAttribute("data-node-id") || protyle.block.rootID
|
const parentID = item.parentElement.getAttribute("data-node-id") || protyle.block.rootID
|
||||||
|
|
@ -192,6 +194,9 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
topSourceElement = undefined;
|
topSourceElement = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (index === 0) {
|
||||||
|
afterPreviousID = id;
|
||||||
|
}
|
||||||
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
|
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
|
||||||
item.removeAttribute("fold");
|
item.removeAttribute("fold");
|
||||||
foldHeadingIds.push({id, parentID});
|
foldHeadingIds.push({id, parentID});
|
||||||
|
|
@ -217,7 +222,6 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
undoOperations.reverse();
|
undoOperations.reverse();
|
||||||
let afterPreviousID
|
|
||||||
for (let j = 0; j < foldHeadingIds.length; j++) {
|
for (let j = 0; j < foldHeadingIds.length; j++) {
|
||||||
const childrenItem = foldHeadingIds[j];
|
const childrenItem = foldHeadingIds[j];
|
||||||
const headingIds = await fetchSyncPost("/api/block/getHeadingChildrenIDs", {id: childrenItem.id});
|
const headingIds = await fetchSyncPost("/api/block/getHeadingChildrenIDs", {id: childrenItem.id});
|
||||||
|
|
@ -250,11 +254,11 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
||||||
parentID: sbElement.getAttribute("data-node-id")
|
parentID: sbElement.getAttribute("data-node-id")
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
sbElement.insertAdjacentElement("beforeend", targetElement);
|
sbElement.lastElementChild.insertAdjacentElement("beforebegin", targetElement);
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "move",
|
action: "move",
|
||||||
id: targetElement.getAttribute("data-node-id"),
|
id: targetElement.getAttribute("data-node-id"),
|
||||||
previousID: afterPreviousID || doOperations[0].id
|
previousID: afterPreviousID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -675,6 +679,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||||
insertHTML(protyle.lute.SpinBlockDOM(html), protyle, true);
|
insertHTML(protyle.lute.SpinBlockDOM(html), protyle, true);
|
||||||
blockRender(protyle, protyle.wysiwyg.element);
|
blockRender(protyle, protyle.wysiwyg.element);
|
||||||
} else if (targetElement) {
|
} else if (targetElement) {
|
||||||
|
hideElements(["gutter"], protyle)
|
||||||
const targetClass = targetElement.className.split(" ");
|
const targetClass = targetElement.className.split(" ");
|
||||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||||
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
|
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue