🐛 导入 .sy.zip 后查询嵌入块失效 Fix https://github.com/siyuan-note/siyuan/issues/5316

This commit is contained in:
Liang Ding 2022-06-29 18:12:34 +08:00
parent bde581c8ad
commit 8d933b5669
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -116,7 +116,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
trees[tree.ID] = tree
}
// 引用指向重新生成的块 ID
// 引用和嵌入指向重新生成的块 ID
for _, tree := range trees {
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
@ -129,6 +129,11 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
} else {
util.LogWarnf("not found def [" + n.TokensStr() + "]")
}
} else if ast.NodeBlockQueryEmbedScript == n.Type {
for oldID, newID := range blockIDs {
// 导入 `.sy.zip` 后查询嵌入块失效 https://github.com/siyuan-note/siyuan/issues/5316
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(oldID), []byte(newID))
}
}
return ast.WalkContinue
})