Browse Source

:art: https://github.com/siyuan-note/siyuan/issues/12900

Vanessa 8 tháng trước cách đây
mục cha
commit
f09c10a097
1 tập tin đã thay đổi với 63 bổ sung65 xóa
  1. 63 65
      app/src/protyle/wysiwyg/index.ts

+ 63 - 65
app/src/protyle/wysiwyg/index.ts

@@ -2126,76 +2126,74 @@ export class WYSIWYG {
                 event.stopPropagation();
                 event.stopPropagation();
                 event.preventDefault();
                 event.preventDefault();
                 hideElements(["dialog", "toolbar"], protyle);
                 hideElements(["dialog", "toolbar"], protyle);
-                if (range.toString() !== "" && !event.shiftKey) {
-                    // 选择不打开引用
-                    return;
-                }
-                let refBlockId: string;
-                if (blockRefElement) {
-                    refBlockId = blockRefElement.getAttribute("data-id");
-                } else if (aElement) {
-                    refBlockId = aLink.substring(16, 38);
-                }
-                checkFold(refBlockId, (zoomIn, action, isRoot) => {
-                    // 块引用跳转后需要短暂高亮目标块 https://github.com/siyuan-note/siyuan/issues/11542
-                    if (!isRoot) {
-                        action.push(Constants.CB_GET_HL);
-                    }
-                    /// #if MOBILE
-                    openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
-                    activeBlur();
-                    hideKeyboardToolbar();
-                    /// #else
-                    if (event.shiftKey) {
-                        openFileById({
-                            app: protyle.app,
-                            id: refBlockId,
-                            position: "bottom",
-                            action,
-                            zoomIn
-                        });
-                        window.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape"}));
-                    } else if (event.altKey) {
-                        openFileById({
-                            app: protyle.app,
-                            id: refBlockId,
-                            position: "right",
-                            action,
-                            zoomIn
-                        });
-                    } else if (ctrlIsPressed) {
-                        openFileById({
-                            app: protyle.app,
-                            id: refBlockId,
-                            keepCursor: true,
-                            action: zoomIn ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
-                            zoomIn
-                        });
-                    } else {
-                        openFileById({
-                            app: protyle.app,
-                            id: refBlockId,
-                            action,
-                            zoomIn
-                        });
-                    }
-                    /// #endif
-                });
-                /// #if !MOBILE
-                if (protyle.model) {
-                    // 打开双链需记录到后退中 https://github.com/siyuan-note/insider/issues/801
-                    let blockElement: HTMLElement | false;
+                if (range.toString() === "" || event.shiftKey) {
+                    let refBlockId: string;
                     if (blockRefElement) {
                     if (blockRefElement) {
-                        blockElement = hasClosestBlock(blockRefElement);
+                        refBlockId = blockRefElement.getAttribute("data-id");
                     } else if (aElement) {
                     } else if (aElement) {
-                        blockElement = hasClosestBlock(aElement);
+                        refBlockId = aLink.substring(16, 38);
                     }
                     }
-                    if (blockElement) {
-                        pushBack(protyle, getEditorRange(this.element), blockElement);
+                    checkFold(refBlockId, (zoomIn, action, isRoot) => {
+                        // 块引用跳转后需要短暂高亮目标块 https://github.com/siyuan-note/siyuan/issues/11542
+                        if (!isRoot) {
+                            action.push(Constants.CB_GET_HL);
+                        }
+                        /// #if MOBILE
+                        openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
+                        activeBlur();
+                        hideKeyboardToolbar();
+                        /// #else
+                        if (event.shiftKey) {
+                            openFileById({
+                                app: protyle.app,
+                                id: refBlockId,
+                                position: "bottom",
+                                action,
+                                zoomIn
+                            });
+                            window.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape"}));
+                        } else if (event.altKey) {
+                            openFileById({
+                                app: protyle.app,
+                                id: refBlockId,
+                                position: "right",
+                                action,
+                                zoomIn
+                            });
+                        } else if (ctrlIsPressed) {
+                            openFileById({
+                                app: protyle.app,
+                                id: refBlockId,
+                                keepCursor: true,
+                                action: zoomIn ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
+                                zoomIn
+                            });
+                        } else {
+                            openFileById({
+                                app: protyle.app,
+                                id: refBlockId,
+                                action,
+                                zoomIn
+                            });
+                        }
+                        /// #endif
+                    });
+                    /// #if !MOBILE
+                    if (protyle.model) {
+                        // 打开双链需记录到后退中 https://github.com/siyuan-note/insider/issues/801
+                        let blockElement: HTMLElement | false;
+                        if (blockRefElement) {
+                            blockElement = hasClosestBlock(blockRefElement);
+                        } else if (aElement) {
+                            blockElement = hasClosestBlock(aElement);
+                        }
+                        if (blockElement) {
+                            pushBack(protyle, getEditorRange(this.element), blockElement);
+                        }
                     }
                     }
+                    /// #endif
+                    return;
                 }
                 }
-                /// #endif
-                return;
             }
             }
             /// #if MOBILE
             /// #if MOBILE
             // https://github.com/siyuan-note/siyuan/issues/10513
             // https://github.com/siyuan-note/siyuan/issues/10513