From 17dc719fc76b475e07929b4ca28f4fcec2b4adc2 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 13 Oct 2022 00:48:27 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/6169 --- app/src/protyle/util/editorCommonEvent.ts | 53 +---------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 4199fbd42..ceb642538 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -555,57 +555,8 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { editorElement.addEventListener("drop", async (event: DragEvent & { target: HTMLElement }) => { if (event.dataTransfer.getData(Constants.SIYUAN_DROP_EDITOR)) { // 编辑器内选中文字拖拽 - if (getSelection().rangeCount === 0) { - return; - } - const targetElement = hasClosestBlock(event.target); - const sourceElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer); - if (!targetElement || !sourceElement) { - return; - } - hideElements(["toolbar"], protyle); - const isSameNode = targetElement.isSameNode(sourceElement); - const undoOperations: IOperation[] = [{ - action: "update", - data: targetElement.outerHTML, - id: targetElement.getAttribute("data-node-id"), - }]; - if (!isSameNode) { - undoOperations.push({ - action: "update", - data: sourceElement.outerHTML, - id: sourceElement.getAttribute("data-node-id"), - }); - } - setTimeout(() => { - const range = getSelection().getRangeAt(0); - range.insertNode(document.createElement("wbr")); - const targetHTML = protyle.lute.SpinBlockDOM(targetElement.outerHTML); - targetElement.outerHTML = targetHTML; - const doOperations: IOperation[] = [{ - action: "update", - data: targetHTML, - id: targetElement.getAttribute("data-node-id"), - }]; - if (!isSameNode) { - const sourceHTML = protyle.lute.SpinBlockDOM(sourceElement.outerHTML); - sourceElement.outerHTML = sourceHTML; - doOperations.push({ - action: "update", - data: sourceHTML, - id: sourceElement.getAttribute("data-node-id"), - }); - } - transaction(protyle, doOperations, undoOperations); - mathRender(protyle.wysiwyg.element); - if (targetElement.classList.contains("code-block")) { - highlightRender(protyle.wysiwyg.element); - } else { - focusByWbr(protyle.wysiwyg.element, range); - } - // 拖拽后无法使用快捷键 - protyle.selectElement.classList.add("fn__none"); - }); + event.preventDefault(); + event.stopPropagation(); return; } const targetElement = editorElement.querySelector(".dragover__bottom") || editorElement.querySelector(".dragover__top") || editorElement.querySelector(".dragover__left") || editorElement.querySelector(".dragover__right");