mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
9084fe20b0
commit
4170f50dc6
1 changed files with 11 additions and 47 deletions
|
|
@ -2,7 +2,7 @@ import {focusBlock, focusByWbr, focusByRange} from "./selection";
|
||||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";
|
import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {paste} from "./paste";
|
import {paste} from "./paste";
|
||||||
import {genEmptyElement, genSBElement} from "../../block/util";
|
import {cancelSB, genEmptyElement, genSBElement} from "../../block/util";
|
||||||
import {transaction} from "../wysiwyg/transaction";
|
import {transaction} from "../wysiwyg/transaction";
|
||||||
import {getTopAloneElement} from "../wysiwyg/getBlock";
|
import {getTopAloneElement} from "../wysiwyg/getBlock";
|
||||||
import {updateListOrder} from "../wysiwyg/list";
|
import {updateListOrder} from "../wysiwyg/list";
|
||||||
|
|
@ -205,29 +205,11 @@ const dragSb = (protyle: IProtyle, sourceElements: Element[], targetElement: Ele
|
||||||
oldSourceParentElement = topSourceElement.parentElement;
|
oldSourceParentElement = topSourceElement.parentElement;
|
||||||
topSourceElement.remove();
|
topSourceElement.remove();
|
||||||
}
|
}
|
||||||
if (oldSourceParentElement && (oldSourceParentElement.classList.contains("bq") || oldSourceParentElement.classList.contains("sb")) && oldSourceParentElement.childElementCount === 1) {
|
if (oldSourceParentElement && oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
|
||||||
// 拖拽后,bq 为空
|
// 拖拽后,sb 只剩下一个元素
|
||||||
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
const sbData = cancelSB(protyle, oldSourceParentElement);
|
||||||
if (protyleElement) {
|
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
|
||||||
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
|
undoOperations.splice(0, 0, sbData.undoOperations[0], sbData.undoOperations[1]);
|
||||||
if (editor && editor.model instanceof Editor) {
|
|
||||||
const newId = Lute.NewNodeID();
|
|
||||||
const newElement = genEmptyElement(false, false, newId);
|
|
||||||
doOperations.splice(0, 0, {
|
|
||||||
action: "insert",
|
|
||||||
id: newId,
|
|
||||||
data: newElement.outerHTML,
|
|
||||||
parentID: oldSourceParentElement.getAttribute("data-node-id")
|
|
||||||
});
|
|
||||||
undoOperations.splice(0, 0, {
|
|
||||||
action: "delete",
|
|
||||||
id: newId,
|
|
||||||
});
|
|
||||||
if (isSameDoc) {
|
|
||||||
oldSourceParentElement.insertAdjacentElement("afterbegin", newElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.innerHTML === "") {
|
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.innerHTML === "") {
|
||||||
// 拖拽后,根文档原内容为空,且不为悬浮窗
|
// 拖拽后,根文档原内容为空,且不为悬浮窗
|
||||||
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
||||||
|
|
@ -499,29 +481,11 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oldSourceParentElement && (oldSourceParentElement.classList.contains("bq") || oldSourceParentElement.classList.contains("sb")) && oldSourceParentElement.childElementCount === 1) {
|
if (oldSourceParentElement && oldSourceParentElement.classList.contains("sb") && oldSourceParentElement.childElementCount === 2) {
|
||||||
// 拖拽后,bq 为空
|
// 拖拽后,sb 只剩下一个元素
|
||||||
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
const sbData = cancelSB(protyle, oldSourceParentElement);
|
||||||
if (protyleElement) {
|
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
|
||||||
const editor = getInstanceById(protyleElement.getAttribute("data-id")) as Tab;
|
undoOperations.splice(0, 0, sbData.undoOperations[0], sbData.undoOperations[1]);
|
||||||
if (editor && editor.model instanceof Editor) {
|
|
||||||
const newId = Lute.NewNodeID();
|
|
||||||
const newElement = genEmptyElement(false, false, newId);
|
|
||||||
doOperations.splice(0, 0, {
|
|
||||||
action: "insert",
|
|
||||||
id: newId,
|
|
||||||
data: newElement.outerHTML,
|
|
||||||
parentID: oldSourceParentElement.getAttribute("data-node-id")
|
|
||||||
});
|
|
||||||
undoOperations.splice(0, 0, {
|
|
||||||
action: "delete",
|
|
||||||
id: newId,
|
|
||||||
});
|
|
||||||
if (isSameDoc) {
|
|
||||||
oldSourceParentElement.insertAdjacentElement("afterbegin", newElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.childElementCount === 0) {
|
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.childElementCount === 0) {
|
||||||
// 拖拽后,根文档原内容为空,且不为悬浮窗
|
// 拖拽后,根文档原内容为空,且不为悬浮窗
|
||||||
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue