From a20a338e6d18ce86afbcfcdfaf9a872364de3c6d Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 24 Dec 2022 11:57:03 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/6853 --- app/src/block/Panel.ts | 7 ++++++- app/src/constants.ts | 1 + app/src/protyle/index.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index 8ce393845..1ec1a1015 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -187,10 +187,15 @@ export class BlockPanel { private initProtyle(editorElement: HTMLElement) { const index = parseInt(editorElement.getAttribute("data-index")); + const action = [Constants.CB_GET_ALL]; + if (this.targetElement.classList.contains("protyle-attr--refcount")|| + this.targetElement.classList.contains("counter")) { + action.push(Constants.CB_GET_BACKLINK); + } const editor = new Protyle(editorElement, { blockId: this.nodeIds[index], defId: this.defIds[index] || this.defIds[0] || "", - action: [Constants.CB_GET_ALL], + action, render: { gutter: true, breadcrumbDocName: true, diff --git a/app/src/constants.ts b/app/src/constants.ts index a75e74187..071f05f5a 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -50,6 +50,7 @@ export abstract class Constants { public static readonly CB_GET_FOCUSFIRST = "cb-get-focusfirst"; // 动态定位到第一个块 public static readonly CB_GET_SETID = "cb-get-setid"; // 重置 blockid public static readonly CB_GET_ALL = "cb-get-all"; // 获取所有块 + public static readonly CB_GET_BACKLINK = "cb-get-backlink"; // 悬浮窗为传递型需展示上下文 public static readonly CB_GET_UNUNDO = "cb-get-unundo"; // 不需要记录历史 public static readonly CB_GET_SCROLL = "cb-get-scroll"; // 滚动到指定位置 public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文 diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 71cc94a29..01263f06b 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -169,6 +169,7 @@ export class Protyle { fetchPost("/api/filetree/getDoc", { id: options.blockId, k: options.key || "", + isBacklink: mergedOptions.action.includes(Constants.CB_GET_BACKLINK), mode: (mergedOptions.action && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后 size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => {