Sfoglia il codice sorgente

:art: 改进建立引用索引 https://github.com/siyuan-note/siyuan/issues/7320

Liang Ding 2 anni fa
parent
commit
7bdff9eaeb
3 ha cambiato i file con 7 aggiunte e 9 eliminazioni
  1. 1 1
      kernel/model/export.go
  2. 2 4
      kernel/model/index.go
  3. 4 4
      kernel/model/search.go

+ 1 - 1
kernel/model/export.go

@@ -1362,7 +1362,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
 			if n.IsTextMarkType("inline-math") {
 				n.TextMarkInlineMathContent = strings.TrimSpace(n.TextMarkInlineMathContent)
 				return ast.WalkContinue
-			} else if n.IsTextMarkType("file-annotation-ref") {
+			} else if treenode.IsFileAnnotationRef(n) {
 				refID := n.TextMarkFileAnnotationRefID
 				status := processFileAnnotationRef(refID, n, fileAnnotationRefMode)
 				unlinks = append(unlinks, n)

+ 2 - 4
kernel/model/index.go

@@ -172,10 +172,8 @@ func IndexRefs() {
 						return ast.WalkContinue
 					}
 
-					if n.IsTextMarkType("block-ref") {
-						defBlockIDs = append(defBlockIDs, n.TextMarkBlockRefID)
-					} else if n.IsTextMarkType("file-annotation-ref") {
-						defBlockIDs = append(defBlockIDs, n.TextMarkFileAnnotationRefID)
+					if treenode.IsBlockRef(n) || treenode.IsFileAnnotationRef(n) {
+						defBlockIDs = append(defBlockIDs, tree.Root.ID)
 					}
 					return ast.WalkContinue
 				})

+ 4 - 4
kernel/model/search.go

@@ -943,19 +943,19 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS
 					c.TextMarkTextContent = string(c.Tokens)
 					if n.IsTextMarkType("a") {
 						c.TextMarkAHref, c.TextMarkATitle = n.TextMarkAHref, n.TextMarkATitle
-					} else if n.IsTextMarkType("block-ref") {
+					} else if treenode.IsBlockRef(n) {
 						c.TextMarkBlockRefID = n.TextMarkBlockRefID
 						c.TextMarkBlockRefSubtype = n.TextMarkBlockRefSubtype
-					} else if n.IsTextMarkType("file-annotation-ref") {
+					} else if treenode.IsFileAnnotationRef(n) {
 						c.TextMarkFileAnnotationRefID = n.TextMarkFileAnnotationRefID
 					}
 				} else if ast.NodeTextMark == c.Type {
 					if n.IsTextMarkType("a") {
 						c.TextMarkAHref, c.TextMarkATitle = n.TextMarkAHref, n.TextMarkATitle
-					} else if n.IsTextMarkType("block-ref") {
+					} else if treenode.IsBlockRef(n) {
 						c.TextMarkBlockRefID = n.TextMarkBlockRefID
 						c.TextMarkBlockRefSubtype = n.TextMarkBlockRefSubtype
-					} else if n.IsTextMarkType("file-annotation-ref") {
+					} else if treenode.IsFileAnnotationRef(n) {
 						c.TextMarkFileAnnotationRefID = n.TextMarkFileAnnotationRefID
 					}
 				}