mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-10 22:23:28 +08:00
🎨 桌面端支持搜索图片 OCR 文本 https://github.com/siyuan-note/siyuan/issues/3470
This commit is contained in:
parent
daa30de3c9
commit
d65bce4a17
@ -106,20 +106,34 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch n.Type {
|
switch n.Type {
|
||||||
case ast.NodeLinkText:
|
case ast.NodeImage:
|
||||||
buf.Write(n.Tokens)
|
linkDest := n.ChildByType(ast.NodeLinkDest)
|
||||||
|
var linkDestStr, ocrText string
|
||||||
if nil != n.Parent && ast.NodeImage == n.Parent.Type {
|
if nil != linkDest {
|
||||||
destNode := n.Parent.ChildByType(ast.NodeLinkDest)
|
linkDestStr = linkDest.TokensStr()
|
||||||
if nil != destNode {
|
ocrText = util2.GetAssetText(linkDestStr)
|
||||||
// 桌面端支持搜索图片 OCR 文本 https://github.com/siyuan-note/siyuan/issues/3470
|
|
||||||
if text := util2.GetAssetText(destNode.TokensStr()); "" != text {
|
|
||||||
buf.WriteByte(' ')
|
|
||||||
buf.WriteString(text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linkText := n.ChildByType(ast.NodeLinkText)
|
||||||
|
if nil != linkText {
|
||||||
|
buf.Write(linkText.Tokens)
|
||||||
|
buf.WriteByte(' ')
|
||||||
|
}
|
||||||
|
if "" != ocrText {
|
||||||
|
buf.WriteString(ocrText)
|
||||||
|
buf.WriteByte(' ')
|
||||||
|
}
|
||||||
|
if nil != linkDest {
|
||||||
|
buf.Write(n.Tokens)
|
||||||
|
buf.WriteByte(' ')
|
||||||
|
|
||||||
|
}
|
||||||
|
if linkTitle := n.ChildByType(ast.NodeLinkTitle); nil != linkTitle {
|
||||||
|
buf.Write(linkTitle.Tokens)
|
||||||
|
}
|
||||||
|
return ast.WalkSkipChildren
|
||||||
|
case ast.NodeLinkText:
|
||||||
|
buf.Write(n.Tokens)
|
||||||
buf.WriteByte(' ')
|
buf.WriteByte(' ')
|
||||||
case ast.NodeLinkDest:
|
case ast.NodeLinkDest:
|
||||||
buf.Write(n.Tokens)
|
buf.Write(n.Tokens)
|
||||||
|
Loading…
Reference in New Issue
Block a user