mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
b2ba9ace07
commit
14424d3dc0
1 changed files with 11 additions and 4 deletions
|
|
@ -434,12 +434,21 @@ export const hintRenderAssets = (value: string, protyle: IProtyle) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const hintMoveBlock = (pathString: string, sourceElements: Element[], protyle: IProtyle) => {
|
export const hintMoveBlock = (pathString: string, sourceElements: Element[], protyle: IProtyle) => {
|
||||||
|
if (pathString === "/") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const parentID = getDisplayName(pathString, true, true)
|
||||||
|
if (protyle.block.rootID === parentID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const doOperations: IOperation[] = [];
|
const doOperations: IOperation[] = [];
|
||||||
let topSourceElement: Element;
|
let topSourceElement: Element;
|
||||||
const parentElement = sourceElements[0].parentElement;
|
const parentElement = sourceElements[0].parentElement;
|
||||||
let sideElement;
|
let sideElement;
|
||||||
sourceElements.forEach((item, index) => {
|
sourceElements.forEach((item, index) => {
|
||||||
if (index === sourceElements.length - 1) {
|
if (index === sourceElements.length - 1 &&
|
||||||
|
// 动态加载过慢,导致 item 被移除
|
||||||
|
item.parentElement) {
|
||||||
topSourceElement = getTopAloneElement(item);
|
topSourceElement = getTopAloneElement(item);
|
||||||
sideElement = topSourceElement.nextElementSibling || topSourceElement.previousElementSibling;
|
sideElement = topSourceElement.nextElementSibling || topSourceElement.previousElementSibling;
|
||||||
if (topSourceElement.isSameNode(item)) {
|
if (topSourceElement.isSameNode(item)) {
|
||||||
|
|
@ -449,7 +458,7 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
|
||||||
doOperations.push({
|
doOperations.push({
|
||||||
action: "append",
|
action: "append",
|
||||||
id: item.getAttribute("data-node-id"),
|
id: item.getAttribute("data-node-id"),
|
||||||
parentID: getDisplayName(pathString, true, true)
|
parentID,
|
||||||
});
|
});
|
||||||
item.remove();
|
item.remove();
|
||||||
});
|
});
|
||||||
|
|
@ -494,8 +503,6 @@ export const hintMoveBlock = (pathString: string, sourceElements: Element[], pro
|
||||||
} else if (sideElement) {
|
} else if (sideElement) {
|
||||||
focusBlock(sideElement);
|
focusBlock(sideElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跨文档不支持撤销
|
// 跨文档不支持撤销
|
||||||
transaction(protyle, doOperations);
|
transaction(protyle, doOperations);
|
||||||
hideElements(["util"], protyle);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue