From 0c2f466ccae166947274ac369b7d54e3dc48887c Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 21 Oct 2023 23:39:56 +0800 Subject: [PATCH] :art: The outline cannot jump to the heading in the folded list https://github.com/siyuan-note/siyuan/issues/9469 --- app/src/layout/dock/Outline.ts | 4 ++-- kernel/model/blockial.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index ab376d6d5..73ad67e5a 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -122,11 +122,11 @@ export class Outline extends Model { }); } } else { - fetchPost("/api/attr/getBlockAttrs", {id}, (attrResponse) => { + fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ app: options.app, id, - action: attrResponse.data["heading-fold"] === "1" ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT, Constants.CB_GET_HTML], }); }); } diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go index 012de75ef..c7f3fab91 100644 --- a/kernel/model/blockial.go +++ b/kernel/model/blockial.go @@ -28,6 +28,7 @@ import ( "github.com/88250/lute/lex" "github.com/88250/lute/parse" "github.com/araddon/dateparse" + "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/cache" "github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/treenode" @@ -256,6 +257,11 @@ func GetBlockAttrs(id string) (ret map[string]string) { } node := treenode.GetNodeInTree(tree, id) + if nil == node { + logging.LogWarnf("block [%s] not found", id) + return + } + for _, kv := range node.KramdownIAL { ret[kv[0]] = html.UnescapeAttrVal(kv[1]) }