An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: 复制含链接的块为引用块异常 Fix https://github.com/siyuan-note/siyuan/issues/7426
Liang Ding6faff1109c5e
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex d09f566c6d..08e56d4951 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -63,7 +63,7 @@ func SetBlockReminder(id string, timed string) (err error) {if ast.NodeDocument != node.Type && node.IsContainerBlock() {node = treenode.FirstLeafBlock(node)}- content := treenode.NodeStaticContent(node, nil)+ content := treenode.NodeStaticContent(node, nil, false)content = gulu.Str.SubStr(content, 128)err = SetCloudBlockReminder(id, content, timedMills)if nil != err {diff --git a/kernel/model/render.go b/kernel/model/render.goindex 73047513c5..10198ea25f 100644--- a/kernel/model/render.go+++ b/kernel/model/render.go@@ -78,7 +78,7 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {}func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {- ret = treenode.NodeStaticContent(node, excludeTypes)+ ret = treenode.NodeStaticContent(node, excludeTypes, false)ret = strings.TrimSpace(ret)ret = strings.ReplaceAll(ret, "\n", "")ret = util.EscapeHTML(ret)@@ -141,7 +141,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {buf := bytes.Buffer{}for _, n := range subNodes {- buf.WriteString(treenode.NodeStaticContent(n, nil))+ buf.WriteString(treenode.NodeStaticContent(n, nil, false))}return buf.String()}diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.goindex f16defad25..0130b1469c 100644--- a/kernel/model/virutalref.go+++ b/kernel/model/virutalref.go@@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {return ast.WalkContinue}- content := treenode.NodeStaticContent(n, nil)+ content := treenode.NodeStaticContent(n, nil, false)buf.WriteString(content)return ast.WalkContinue})diff --git a/kernel/sql/database.go b/kernel/sql/database.goindex 0187e20cd3..502a87eb48 100644--- a/kernel/sql/database.go+++ b/kernel/sql/database.go@@ -699,9 +699,10 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributesfcontent = contentlength = utf8.RuneCountInString(fcontent)} else if n.IsContainerBlock() {- markdown, content = treenode.NodeStaticMdContent(n, luteEngine)+ markdown = treenode.ExportNodeStdMd(n, luteEngine)+ content = treenode.NodeStaticContent(n, nil, true)fc := treenode.FirstLeafBlock(n)- fcontent = treenode.NodeStaticContent(fc, nil)+ fcontent = treenode.NodeStaticContent(fc, nil, false)parentID = n.Parent.ID// 将标题块作为父节点if h := heading(n); nil != h {@@ -709,7 +710,8 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes}length = utf8.RuneCountInString(fcontent)} else {- markdown, content = treenode.NodeStaticMdContent(n, luteEngine)+ markdown = treenode.ExportNodeStdMd(n, luteEngine)+ content = treenode.NodeStaticContent(n, nil, true)parentID = n.Parent.ID// 将标题块作为父节点if h := heading(n); nil != h {diff --git a/kernel/treenode/node.go b/kernel/treenode/node.goindex d94b5eda8f..e2eb2528ab 100644--- a/kernel/treenode/node.go+++ b/kernel/treenode/node.go@@ -114,12 +114,6 @@ func IsEmbedBlockRef(n *ast.Node) bool {return "" != GetEmbedBlockRef(n)}-func NodeStaticMdContent(node *ast.Node, luteEngine *lute.Lute) (md, content string) {- md = ExportNodeStdMd(node, luteEngine)- content = NodeStaticContent(node, nil)- return-}-func FormatNode(node *ast.Node, luteEngine *lute.Lute) string {markdown, err := lute.FormatNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)if nil != err {@@ -138,7 +132,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {return markdown}-func NodeStaticContent(node *ast.Node, excludeTypes []string) string {+func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL bool) string {if nil == node {return ""}@@ -225,7 +219,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string) string {if n.IsTextMarkType("tag") {buf.WriteByte('#')}- if n.IsTextMarkType("a") {+ if n.IsTextMarkType("a") && includeTextMarkATitleURL {// 搜索不到超链接元素的 URL 和标题 https://github.com/siyuan-note/siyuan/issues/7352if "" != n.TextMarkATitle {buf.WriteString(" " + n.TextMarkATitle)