From 8d933b5669c785eaf3d62a3c0ee7f1d52bfd1395 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 29 Jun 2022 18:12:34 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=AF=BC=E5=85=A5=20`.sy.zip`=20?= =?UTF-8?q?=E5=90=8E=E6=9F=A5=E8=AF=A2=E5=B5=8C=E5=85=A5=E5=9D=97=E5=A4=B1?= =?UTF-8?q?=E6=95=88=20Fix=20https://github.com/siyuan-note/siyuan/issues/?= =?UTF-8?q?5316?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/import.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/model/import.go b/kernel/model/import.go index f5aabfae6..a103a5144 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -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 })