🎨 Ignore assets associated with the custom-data-assets block attribute when cleaning unreferenced assets https://github.com/siyuan-note/siyuan/issues/12574

This commit is contained in:
Daniel 2024-09-24 23:20:22 +08:00
parent 0cd17327bc
commit 150aa2a7bf
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 16 additions and 1 deletions

View file

@ -992,6 +992,21 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
func assetsLinkDestsInNode(node *ast.Node) (ret []string) {
ret = []string{}
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
if n.IsBlock() {
// 以 custom-data-assets 开头的块属性值可能是多个资源文件链接,需要计入
// Ignore assets associated with the `custom-data-assets` block attribute when cleaning unreferenced assets https://github.com/siyuan-note/siyuan/issues/12574
for _, kv := range n.KramdownIAL {
k := kv[0]
if strings.HasPrefix(k, "custom-data-assets") {
dest := kv[1]
if "" == dest || !treenode.IsRelativePath([]byte(dest)) {
continue
}
ret = append(ret, dest)
}
}
}
// 修改以下代码时需要同时修改 database 构造行级元素实现,增加必要的类型
if !entering || (ast.NodeLinkDest != n.Type && ast.NodeHTMLBlock != n.Type && ast.NodeInlineHTML != n.Type &&
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type &&