Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Block hyperlinks do not point to regenerated block IDs when importing .sy.zip https://github.com/siyuan-note/siyuan/issues/9083

Danielb0e9c2d2b93c
diff --git a/kernel/model/import.go b/kernel/model/import.go
index 2b1cb866ad..aae449a397 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