mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-15 11:38:06 +01:00
🚨
This commit is contained in:
parent
9337cb6657
commit
e354fcd39c
8 changed files with 32 additions and 30 deletions
|
|
@ -21,15 +21,15 @@ import {isBrowser} from "../../util/functions";
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
|
||||
const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isSameDoc: boolean, position: InsertPosition) => {
|
||||
let topSourceElement
|
||||
const doOperations: IOperation[] = []
|
||||
const undoOperations: IOperation[] = []
|
||||
const foldHeadingIds: { id: string, parentID: string }[] = []
|
||||
const targetId = targetElement.getAttribute("data-node-id")
|
||||
let tempTargetElement = targetElement
|
||||
let topSourceElement;
|
||||
const doOperations: IOperation[] = [];
|
||||
const undoOperations: IOperation[] = [];
|
||||
const foldHeadingIds: { id: string, parentID: string }[] = [];
|
||||
const targetId = targetElement.getAttribute("data-node-id");
|
||||
let tempTargetElement = targetElement;
|
||||
sourceElements.reverse().forEach((item, index) => {
|
||||
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;
|
||||
if (index === sourceElements.length - 1) {
|
||||
topSourceElement = getTopAloneElement(item);
|
||||
if (topSourceElement.isSameNode(item)) {
|
||||
|
|
@ -66,7 +66,7 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
|||
if (position !== "afterend") {
|
||||
tempTargetElement = item;
|
||||
}
|
||||
})
|
||||
});
|
||||
undoOperations.reverse();
|
||||
for (let j = 0; j < foldHeadingIds.length; j++) {
|
||||
const childrenItem = foldHeadingIds[j];
|
||||
|
|
@ -78,7 +78,7 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
|||
previousID: childrenItem.id,
|
||||
parentID: childrenItem.parentID,
|
||||
});
|
||||
})
|
||||
});
|
||||
undoOperations.push({
|
||||
action: "foldHeading",
|
||||
id: childrenItem.id,
|
||||
|
|
@ -93,8 +93,8 @@ const moveTo = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
|||
doOperations,
|
||||
undoOperations,
|
||||
topSourceElement,
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean, direct: "col" | "row") => {
|
||||
const isSameDoc = protyle.element.contains(sourceElements[0]);
|
||||
|
|
@ -184,11 +184,11 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
|||
id: newSourceElement.getAttribute("data-node-id"),
|
||||
});
|
||||
} else {
|
||||
const foldHeadingIds: { id: string, parentID: string }[] = []
|
||||
let afterPreviousID
|
||||
const foldHeadingIds: { id: string, parentID: string }[] = [];
|
||||
let afterPreviousID;
|
||||
sourceElements.reverse().forEach((item, index) => {
|
||||
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;
|
||||
if (index === sourceElements.length - 1) {
|
||||
topSourceElement = getTopAloneElement(item);
|
||||
if (topSourceElement.isSameNode(item)) {
|
||||
|
|
@ -233,9 +233,9 @@ const dragSb = async (protyle: IProtyle, sourceElements: Element[], targetElemen
|
|||
previousID: childrenItem.id,
|
||||
parentID: childrenItem.parentID,
|
||||
});
|
||||
})
|
||||
});
|
||||
if (j === 0) {
|
||||
afterPreviousID = headingIds.data[0]
|
||||
afterPreviousID = headingIds.data[0];
|
||||
}
|
||||
undoOperations.push({
|
||||
action: "foldHeading",
|
||||
|
|
@ -369,7 +369,7 @@ const dragSame = async (protyle: IProtyle, sourceElements: Element[], targetElem
|
|||
}
|
||||
let topSourceElement: Element;
|
||||
let oldSourceParentElement = sourceElements[0].parentElement;
|
||||
const targetId = targetElement.getAttribute("data-node-id")
|
||||
const targetId = targetElement.getAttribute("data-node-id");
|
||||
if (isBottom) {
|
||||
if (newSourceElement) {
|
||||
targetElement.insertAdjacentElement("afterend", newSourceElement);
|
||||
|
|
@ -680,7 +680,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
insertHTML(protyle.lute.SpinBlockDOM(html), protyle, true);
|
||||
blockRender(protyle, protyle.wysiwyg.element);
|
||||
} else if (targetElement) {
|
||||
hideElements(["gutter"], protyle)
|
||||
hideElements(["gutter"], protyle);
|
||||
const targetClass = targetElement.className.split(" ");
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ export const alignImgCenter = (protyle: IProtyle, nodeElement: Element, assetEle
|
|||
}
|
||||
});
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||
}
|
||||
};
|
||||
|
||||
export const alignImgLeft = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => {
|
||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||
|
|
@ -296,4 +296,4 @@ export const alignImgLeft = (protyle: IProtyle, nodeElement: Element, assetEleme
|
|||
}
|
||||
});
|
||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (matchHotKey(window.siyuan.config.keymap.editor.general.alignLeft.custom, event)) {
|
||||
const imgSelectElements = nodeElement.querySelectorAll(".img--select");
|
||||
if (imgSelectElements.length > 0) {
|
||||
alignImgLeft(protyle, nodeElement, Array.from(imgSelectElements), nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML)
|
||||
alignImgLeft(protyle, nodeElement, Array.from(imgSelectElements), nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML);
|
||||
} else {
|
||||
let selectElements: HTMLElement[] = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
|
||||
if (selectElements.length === 0) {
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
if (updateElements.length === 0) {
|
||||
// 页签拖入浮窗 https://github.com/siyuan-note/siyuan/issues/6647
|
||||
window.siyuan.blockPanels.forEach((item) => {
|
||||
const updateCloneElement = item.element.querySelector(`[data-node-id="${operation.id}"]`)
|
||||
const updateCloneElement = item.element.querySelector(`[data-node-id="${operation.id}"]`);
|
||||
if (updateCloneElement) {
|
||||
updateElements.push(updateCloneElement.cloneNode(true) as Element);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue