mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-14 16:11:00 +08:00
This commit is contained in:
parent
89902a9fd9
commit
0184fb55f5
@ -820,16 +820,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
});
|
||||
|
||||
hideElements(["gutter"], protyle);
|
||||
|
||||
const targetClass = targetElement.className.split(" ");
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||
|
||||
if (targetElement.classList.contains("av__cell")) {
|
||||
const blockElement = hasClosestBlock(targetElement);
|
||||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
if (blockElement) {
|
||||
const avID = blockElement.getAttribute("data-av-id");
|
||||
transaction(protyle, [{
|
||||
action: "sortAttrViewCol",
|
||||
avID,
|
||||
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-col-id") : targetElement.getAttribute("data-col-id")) || "",
|
||||
previousID: (targetClass.includes("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-col-id") : targetElement.getAttribute("data-col-id")) || "",
|
||||
id: gutterTypes[2],
|
||||
}], [{
|
||||
action: "sortAttrViewCol",
|
||||
@ -837,16 +839,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
previousID: targetElement.parentElement.querySelector(`[data-col-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-col-id") || "",
|
||||
id: gutterTypes[2],
|
||||
}]);
|
||||
return;
|
||||
}
|
||||
if (targetElement.classList.contains("av__row")) {
|
||||
} else if (targetElement.classList.contains("av__row")) {
|
||||
// 拖拽到属性视图内
|
||||
const blockElement = hasClosestBlock(targetElement);
|
||||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
if (blockElement) {
|
||||
let previousID = "";
|
||||
if (targetElement.classList.contains("dragover__bottom")) {
|
||||
if (targetClass.includes("dragover__bottom")) {
|
||||
previousID = targetElement.getAttribute("data-id") || "";
|
||||
} else {
|
||||
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
|
||||
@ -885,10 +884,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
}]);
|
||||
insertAttrViewBlockAnimation(blockElement, sourceIds.length, previousID);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const targetClass = targetElement.className.split(" ");
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||
} else {
|
||||
if (targetElement.parentElement.getAttribute("data-type") === "NodeSuperBlock" &&
|
||||
targetElement.parentElement.getAttribute("data-sb-layout") === "col") {
|
||||
if (targetClass.includes("dragover__left") || targetClass.includes("dragover__right")) {
|
||||
@ -915,17 +912,16 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
blockRender(protyle, targetElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE)?.split("-").length > 1
|
||||
&& targetElement && !protyle.options.backlinkData) {
|
||||
&& targetElement && !protyle.options.backlinkData && targetElement.className.indexOf("dragover__") > -1) {
|
||||
// 文件树拖拽
|
||||
const scrollTop = protyle.contentElement.scrollTop;
|
||||
const ids = event.dataTransfer.getData(Constants.SIYUAN_DROP_FILE).split(",");
|
||||
if (targetElement.classList.contains("av__row")) {
|
||||
// 拖拽到属性视图内
|
||||
const blockElement = hasClosestBlock(targetElement);
|
||||
if (!blockElement) {
|
||||
return;
|
||||
}
|
||||
if (blockElement) {
|
||||
let previousID = "";
|
||||
if (targetElement.classList.contains("dragover__bottom")) {
|
||||
previousID = targetElement.getAttribute("data-id") || "";
|
||||
@ -944,8 +940,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
avID,
|
||||
}]);
|
||||
insertAttrViewBlockAnimation(blockElement, ids.length, previousID);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
if (ids[i]) {
|
||||
await fetchSyncPost("/api/filetree/doc2Heading", {
|
||||
@ -976,7 +972,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
protyle.scroll.lastScrollTop = scrollTop - 1;
|
||||
}, Constants.TIMEOUT_LOAD);
|
||||
});
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top");
|
||||
}
|
||||
targetElement.classList.remove("dragover__bottom", "dragover__top", "dragover__left", "dragover__right", "protyle-wysiwyg--select");
|
||||
} else if (!window.siyuan.dragElement && (event.dataTransfer.types[0] === "Files" || event.dataTransfer.types.includes("text/html"))) {
|
||||
// 外部文件拖入编辑器中或者编辑器内选中文字拖拽
|
||||
focusByRange(getRangeByPoint(event.clientX, event.clientY));
|
||||
|
Loading…
Reference in New Issue
Block a user