瀏覽代碼

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

Vanessa 1 年之前
父節點
當前提交
eb54ebe5ac
共有 3 個文件被更改,包括 9 次插入1 次删除
  1. 3 0
      app/src/menus/protyle.ts
  2. 3 1
      app/src/protyle/wysiwyg/index.ts
  3. 3 0
      app/src/protyle/wysiwyg/keydown.ts

+ 3 - 0
app/src/menus/protyle.ts

@@ -366,6 +366,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
         accelerator: window.siyuan.config.keymap.editor.general.openBy.custom + "/" + window.siyuan.languages.click,
         click() {
             checkFold(refBlockId, (zoomIn, action) => {
+                action.push(Constants.CB_GET_HL);
                 openFileById({
                     app: protyle.app,
                     id: refBlockId,
@@ -397,6 +398,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
         accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/⌥" + window.siyuan.languages.click,
         click() {
             checkFold(refBlockId, (zoomIn, action) => {
+                action.push(Constants.CB_GET_HL);
                 openFileById({
                     app: protyle.app,
                     id: refBlockId,
@@ -413,6 +415,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
         accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + "⇧" + window.siyuan.languages.click,
         click() {
             checkFold(refBlockId, (zoomIn, action) => {
+                action.push(Constants.CB_GET_HL);
                 openFileById({
                     app: protyle.app,
                     id: refBlockId,

+ 3 - 1
app/src/protyle/wysiwyg/index.ts

@@ -2043,7 +2043,6 @@ export class WYSIWYG {
             }
             const range = getEditorRange(this.element);
             // 需放在嵌入块之前,否则嵌入块内的引用、链接、pdf 双链无法点击打开 https://ld246.com/article/1630479789513
-            const blockRefElement = hasClosestByAttribute(event.target, "data-type", "block-ref");
             const aElement = hasClosestByAttribute(event.target, "data-type", "a") ||
                 hasClosestByClassName(event.target, "av__celltext--url");   // 数据库中资源文件、链接、电话、邮箱单元格
             let aLink = aElement ? (aElement.getAttribute("data-href") || "") : "";
@@ -2058,6 +2057,7 @@ export class WYSIWYG {
                 }
             }
 
+            const blockRefElement = hasClosestByAttribute(event.target, "data-type", "block-ref");
             if (blockRefElement || aLink.startsWith("siyuan://blocks/")) {
                 event.stopPropagation();
                 event.preventDefault();
@@ -2073,6 +2073,8 @@ export class WYSIWYG {
                     refBlockId = aLink.substring(16, 38);
                 }
                 checkFold(refBlockId, (zoomIn, action) => {
+                    // 块引用跳转后需要短暂高亮目标块 https://github.com/siyuan-note/siyuan/issues/11542
+                    action.push(Constants.CB_GET_HL);
                     /// #if MOBILE
                     openMobileFileById(protyle.app, refBlockId, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
                     activeBlur();

+ 3 - 0
app/src/protyle/wysiwyg/keydown.ts

@@ -1525,6 +1525,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
             const id = refElement.getAttribute("data-id");
             if (matchHotKey(window.siyuan.config.keymap.editor.general.openBy.custom, event)) {
                 checkFold(id, (zoomIn, action) => {
+                    action.push(Constants.CB_GET_HL);
                     openFileById({
                         app: protyle.app,
                         id,
@@ -1551,6 +1552,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
                 return true;
             } else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
                 checkFold(id, (zoomIn, action) => {
+                    action.push(Constants.CB_GET_HL);
                     openFileById({
                         app: protyle.app,
                         id,
@@ -1564,6 +1566,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
                 return true;
             } else if (matchHotKey(window.siyuan.config.keymap.editor.general.insertBottom.custom, event)) {
                 checkFold(id, (zoomIn, action) => {
+                    action.push(Constants.CB_GET_HL);
                     openFileById({
                         app: protyle.app,
                         id,