Преглед изворни кода

:bug: fix https://github.com/siyuan-note/siyuan/issues/6169

Vanessa пре 2 година
родитељ
комит
17dc719fc7
1 измењених фајлова са 2 додато и 51 уклоњено
  1. 2 51
      app/src/protyle/util/editorCommonEvent.ts

+ 2 - 51
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");