Browse Source

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

Vanessa 2 năm trước cách đây
mục cha
commit
cfe11c944c

+ 2 - 12
app/src/protyle/util/paste.ts

@@ -178,18 +178,8 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
             updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
             updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
             focusByWbr(protyle.wysiwyg.element, range);
             focusByWbr(protyle.wysiwyg.element, range);
         } else {
         } else {
-            nodeElement.insertAdjacentHTML("afterend", code);
-            const codeElement = nodeElement.nextElementSibling as HTMLElement;
-            transaction(protyle, [{
-                action: "insert",
-                data: codeElement.outerHTML,
-                id: codeElement.getAttribute("data-node-id"),
-                previousID: id
-            }], [{
-                action: "delete",
-                id: codeElement.getAttribute("data-node-id")
-            }]);
-            highlightRender(codeElement);
+            insertHTML(code, protyle, true);
+            highlightRender(protyle.wysiwyg.element);
         }
         }
     } else {
     } else {
         let isHTML = false;
         let isHTML = false;

+ 3 - 1
app/src/protyle/util/selection.ts

@@ -507,7 +507,9 @@ export const focusSideBlock = (updateElement: Element) => {
     if (updateElement.getAttribute("data-node-id")) {
     if (updateElement.getAttribute("data-node-id")) {
         let sideBlockElement;
         let sideBlockElement;
         let collapse;
         let collapse;
-        if (updateElement.nextElementSibling) {
+        if (updateElement.nextElementSibling &&
+            !updateElement.nextElementSibling.classList.contains("protyle-attr") // 用例 https://ld246.com/article/1661928364696
+        ) {
             collapse = true;
             collapse = true;
             sideBlockElement = getNextBlock(updateElement) as HTMLElement;
             sideBlockElement = getNextBlock(updateElement) as HTMLElement;
         } else if (updateElement.previousElementSibling) {
         } else if (updateElement.previousElementSibling) {