From b0e9c2d2b93c7545e148f6442a71a8b26c0ac1f6 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 1 Sep 2023 09:39:05 +0800 Subject: [PATCH] :bug: Block hyperlinks do not point to regenerated block IDs when importing .sy.zip https://github.com/siyuan-note/siyuan/issues/9083 --- kernel/model/import.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/model/import.go b/kernel/model/import.go index 2b1cb866a..aae449a39 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -170,6 +170,13 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { if "" != newDefID { n.TextMarkBlockRefID = newDefID } + } else if ast.NodeTextMark == n.Type && n.IsTextMarkType("a") && strings.HasPrefix(n.TextMarkAHref, "siyuan://blocks/") { + // Block hyperlinks do not point to regenerated block IDs when importing .sy.zip https://github.com/siyuan-note/siyuan/issues/9083 + defID := strings.TrimPrefix(n.TextMarkAHref, "siyuan://blocks/") + newDefID := blockIDs[defID] + if "" != newDefID { + n.TextMarkAHref = "siyuan://blocks/" + newDefID + } } else if ast.NodeBlockQueryEmbedScript == n.Type { for oldID, newID := range blockIDs { // 导入 `.sy.zip` 后查询嵌入块失效 https://github.com/siyuan-note/siyuan/issues/5316