From 98e80831223975b68f397637e6f48733825b6698 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 23 May 2024 11:30:33 +0800 Subject: [PATCH 1/2] :bug: Fix NPE https://github.com/siyuan-note/siyuan/issues/11497 --- kernel/model/render.go | 4 ++++ kernel/sql/block.go | 4 ++++ kernel/sql/block_query.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/kernel/model/render.go b/kernel/model/render.go index 8eed06c53..b6c73080c 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -93,6 +93,10 @@ func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) { } func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) { + if nil == node { + return + } + ret = sql.NodeStaticContent(node, excludeTypes, false, false, false, GetBlockAttrsWithoutWaitWriting) ret = strings.TrimSpace(ret) ret = strings.ReplaceAll(ret, "\n", "") diff --git a/kernel/sql/block.go b/kernel/sql/block.go index 192d373f7..0c98a22a7 100644 --- a/kernel/sql/block.go +++ b/kernel/sql/block.go @@ -139,6 +139,10 @@ func indexNode(tx *sql.Tx, id string) (err error) { func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath, fullAttrView bool, GetBlockAttrsWithoutWaitWriting func(id string) (ret map[string]string)) string { + if nil == node { + return "" + } + if ast.NodeAttributeView == node.Type { if fullAttrView { return getAttributeViewContent(node.AttributeViewID, GetBlockAttrsWithoutWaitWriting) diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index f0176df3f..d723ff71e 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -812,6 +812,10 @@ func GetContainerText(container *ast.Node) string { buf := &bytes.Buffer{} buf.Grow(4096) leaf := treenode.FirstLeafBlock(container) + if nil == leaf { + return "" + } + ast.Walk(leaf, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering { return ast.WalkContinue From 51874aef35a302b86a61a1362b86a8da8db968df Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 23 May 2024 11:41:36 +0800 Subject: [PATCH 2/2] :memo: Supports configuring `Unsplit` and `Unsplit All` hotkeys --- .../20200924100950-9op5xi1.sy | 96 ++++++++++++++++++- .../20200813004551-gm0pbn1.sy | 96 ++++++++++++++++++- .../20211226122549-jktxego.sy | 96 ++++++++++++++++++- 3 files changed, 279 insertions(+), 9 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy index 40fbb0e55..c7efe0ff2 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy @@ -7,7 +7,7 @@ "id": "20200924100950-9op5xi1", "title": "Shortcuts", "type": "doc", - "updated": "20240517003750" + "updated": "20240523114032" }, "Children": [ { @@ -16,7 +16,7 @@ "HeadingLevel": 2, "Properties": { "id": "20201227133532-44ubczo", - "updated": "20240517003750" + "updated": "20240523114032" }, "Children": [ { @@ -40,7 +40,7 @@ "Properties": { "colgroup": "||", "id": "20210106154101-qrojg1b", - "updated": "20240426100644" + "updated": "20240523114032" }, "Children": [ { @@ -1296,6 +1296,96 @@ } ] }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "Unsplit" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "Go to " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Settings - Shortcuts" + }, + { + "Type": "NodeText", + "Data": "​ to configure" + } + ] + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "Unsplit All" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "Go to " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Settings - Shortcuts" + }, + { + "Type": "NodeText", + "Data": "​ to configure" + } + ] + } + ] + }, { "Type": "NodeTableRow", "Data": "tr", diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy index e2e9b7a68..c94ead53f 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy @@ -7,7 +7,7 @@ "id": "20200813004551-gm0pbn1", "title": "快捷键", "type": "doc", - "updated": "20240517004202" + "updated": "20240523113529" }, "Children": [ { @@ -16,7 +16,7 @@ "HeadingLevel": 2, "Properties": { "id": "20240112150737-e41yt1y", - "updated": "20240517004202" + "updated": "20240523113529" }, "Children": [ { @@ -36,7 +36,7 @@ "Properties": { "colgroup": "||", "id": "20201227133317-ovwnk1y", - "updated": "20240517004202" + "updated": "20240523113529" }, "Children": [ { @@ -1294,6 +1294,96 @@ } ] }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "取消分屏" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "可前往 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "设置 - 快捷键" + }, + { + "Type": "NodeText", + "Data": "​ 中配置" + } + ] + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "取消全部分屏" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "可前往 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "设置 - 快捷键" + }, + { + "Type": "NodeText", + "Data": "​ 中配置" + } + ] + } + ] + }, { "Type": "NodeTableRow", "Data": "tr", diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy index 07864bcbb..760661345 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy @@ -7,7 +7,7 @@ "id": "20211226122549-jktxego", "title": "快捷鍵", "type": "doc", - "updated": "20240517004210" + "updated": "20240523113830" }, "Children": [ { @@ -16,7 +16,7 @@ "HeadingLevel": 2, "Properties": { "id": "20211226122652-0t4c1qf", - "updated": "20240517004210" + "updated": "20240523113830" }, "Children": [ { @@ -36,7 +36,7 @@ "Properties": { "colgroup": "||", "id": "20211226122652-4e9hm9i", - "updated": "20240517004210" + "updated": "20240523113830" }, "Children": [ { @@ -1288,6 +1288,96 @@ } ] }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "取消並排分頁" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "可前往 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "設置 - 快捷鍵" + }, + { + "Type": "NodeText", + "Data": "​ 中配置" + } + ] + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "取消全部並排分頁" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "-" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "可前往 " + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "設置 - 快捷鍵" + }, + { + "Type": "NodeText", + "Data": "​ 中配置" + } + ] + } + ] + }, { "Type": "NodeTableRow", "Data": "tr",