Skip to content

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

:bug: PDF 标注预览失效 Fix https://github.com/siyuan-note/siyuan/issues/5934

Liang Ding6560b0ce9672
diff --git a/kernel/sql/database.go b/kernel/sql/database.go
index 3cd38af356..45037f38db 100644
--- a/kernel/sql/database.go
+++ b/kernel/sql/database.go
@@ -300,6 +300,34 @@ func refsFromTree(tree *parse.Tree) (refs []*Ref, fileAnnotationRefs []*FileAnno
Type: treenode.TypeAbbr(n.Type.String()),
}
fileAnnotationRefs = append(fileAnnotationRefs, ref)
+ } else if ast.NodeTextMark == n.Type && n.IsTextMarkType("file-annotation-ref") {
+ pathID := n.TextMarkFileAnnotationRefID
+ idx := strings.LastIndex(pathID, "/")
+ if -1 == idx {
+ return ast.WalkContinue
+ }
+
+ filePath := pathID[:idx]
+ annotationID := pathID[idx+1:]
+
+ anchor := n.TextMarkTextContent
+ text := filePath
+ if "" != anchor {
+ text = anchor
+ }
+ parentBlock := treenode.ParentBlock(n)
+ ref := &FileAnnotationRef{
+ ID: ast.NewNodeID(),
+ FilePath: filePath,
+ AnnotationID: annotationID,
+ BlockID: parentBlock.ID,
+ RootID: tree.ID,
+ Box: tree.Box,
+ Path: tree.Path,
+ Content: text,
+ Type: treenode.TypeAbbr(n.Type.String()),
+ }
+ fileAnnotationRefs = append(fileAnnotationRefs, ref)
}
return ast.WalkContinue
})