Browse Source

:art: fix https://github.com/siyuan-note/siyuan/issues/6804

Vanessa 1 year ago
parent
commit
5eed2feca2
1 changed files with 22 additions and 14 deletions
  1. 22 14
      app/src/protyle/wysiwyg/index.ts

+ 22 - 14
app/src/protyle/wysiwyg/index.ts

@@ -1607,6 +1607,28 @@ export class WYSIWYG {
             } else {
             } else {
                 beforeContextmenuRange = undefined;
                 beforeContextmenuRange = undefined;
             }
             }
+            /// #if BROWSER && !MOBILE
+            if (protyle.breadcrumb) {
+                const indentElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="indent"]')
+                if (indentElement && getSelection().rangeCount > 0) {
+                    setTimeout(() => {
+                        const newRange = getSelection().getRangeAt(0);
+                        const blockElement = hasClosestBlock(newRange.startContainer);
+                        if (!blockElement) {
+                            return
+                        }
+                        const outdentElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="outdent"]');
+                        if (blockElement.parentElement.classList.contains("li")) {
+                            indentElement.removeAttribute("disabled");
+                            outdentElement.removeAttribute("disabled");
+                        } else {
+                            indentElement.setAttribute("disabled", "true");
+                            outdentElement.setAttribute("disabled", "true");
+                        }
+                    }, 520);
+                }
+            }
+            /// #endif
         });
         });
 
 
         let preventGetTopHTML = false;
         let preventGetTopHTML = false;
@@ -2394,20 +2416,6 @@ export class WYSIWYG {
                 /// #if !MOBILE
                 /// #if !MOBILE
                 pushBack(protyle, newRange);
                 pushBack(protyle, newRange);
                 /// #endif
                 /// #endif
-                if (protyle.breadcrumb) {
-                    const indentElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="indent"]')
-                    const blockElement = hasClosestBlock(newRange.startContainer);
-                    if (indentElement && blockElement) {
-                        const outdentElement = protyle.breadcrumb.element.parentElement.querySelector('[data-type="outdent"]');
-                        if (blockElement.parentElement.classList.contains("li")) {
-                            indentElement.removeAttribute("disabled");
-                            outdentElement.removeAttribute("disabled");
-                        } else {
-                            indentElement.setAttribute("disabled", "true");
-                            outdentElement.setAttribute("disabled", "true");
-                        }
-                    }
-                }
             }, (isMobile() || isInIOS()) ? 520 : 0); // Android/iPad 双击慢了出不来
             }, (isMobile() || isInIOS()) ? 520 : 0); // Android/iPad 双击慢了出不来
             protyle.hint.enableExtend = false;
             protyle.hint.enableExtend = false;
             if (event.shiftKey) {
             if (event.shiftKey) {