Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-12-07 12:29:18 +08:00
commit ec5b3e3de9
4 changed files with 17 additions and 10 deletions

View File

@ -1120,7 +1120,7 @@ func getDoc(c *gin.Context) {
highlight = highlightArg.(bool) highlight = highlightArg.(bool)
} }
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, keywords, err :=
model.GetDoc(startID, endID, id, index, query, queryTypes, queryMethod, mode, size, isBacklink, highlight) model.GetDoc(startID, endID, id, index, query, queryTypes, queryMethod, mode, size, isBacklink, highlight)
if model.ErrBlockNotFound == err { if model.ErrBlockNotFound == err {
ret.Code = 3 ret.Code = 3
@ -1151,6 +1151,7 @@ func getDoc(c *gin.Context) {
"path": docPath, "path": docPath,
"isSyncing": isSyncing, "isSyncing": isSyncing,
"isBacklinkExpand": isBacklinkExpand, "isBacklinkExpand": isBacklinkExpand,
"keywords": keywords,
} }
} }

View File

@ -267,17 +267,23 @@ func getNodeRefText(node *ast.Node) string {
return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen) return getNodeRefText0(node, Conf.Editor.BlockRefDynamicAnchorTextMaxLen)
} }
func getNodeAvBlockText(node *ast.Node) string { func getNodeAvBlockText(node *ast.Node) (ret string) {
if nil == node { if nil == node {
return "" return ""
} }
if ret := node.IALAttr("name"); "" != ret { if name := node.IALAttr("name"); "" != name {
ret = strings.TrimSpace(ret) name = strings.TrimSpace(name)
ret = util.EscapeHTML(ret) name = util.EscapeHTML(name)
return ret ret = name
} else {
ret = getNodeRefText0(node, 1024)
} }
return getNodeRefText0(node, 1024)
//if icon := node.IALAttr("icon"); "" != icon {
// ret = icon + " " + ret
//}
return
} }
func getNodeRefText0(node *ast.Node, maxLen int) string { func getNodeRefText0(node *ast.Node, maxLen int) string {

View File

@ -599,7 +599,8 @@ func StatTree(id string) (ret *util.BlockStatResult) {
} }
} }
func GetDoc(startID, endID, id string, index int, query string, queryTypes map[string]bool, queryMethod, mode int, size int, isBacklink, highlight bool) (blockCount int, dom, parentID, parent2ID, rootID, typ string, eof, scroll bool, boxID, docPath string, isBacklinkExpand bool, err error) { func GetDoc(startID, endID, id string, index int, query string, queryTypes map[string]bool, queryMethod, mode int, size int, isBacklink, highlight bool) (
blockCount int, dom, parentID, parent2ID, rootID, typ string, eof, scroll bool, boxID, docPath string, isBacklinkExpand bool, keywords []string, err error) {
//os.MkdirAll("pprof", 0755) //os.MkdirAll("pprof", 0755)
//cpuProfile, _ := os.Create("pprof/GetDoc") //cpuProfile, _ := os.Create("pprof/GetDoc")
//pprof.StartCPUProfile(cpuProfile) //pprof.StartCPUProfile(cpuProfile)
@ -800,7 +801,6 @@ func GetDoc(startID, endID, id string, index int, query string, queryTypes map[s
subTree := &parse.Tree{ID: rootID, Root: &ast.Node{Type: ast.NodeDocument}, Marks: tree.Marks} subTree := &parse.Tree{ID: rootID, Root: &ast.Node{Type: ast.NodeDocument}, Marks: tree.Marks}
var keywords []string
if "" != query && (0 == queryMethod || 1 == queryMethod || 3 == queryMethod) { // 只有关键字、查询语法和正则表达式搜索支持高亮 if "" != query && (0 == queryMethod || 1 == queryMethod || 3 == queryMethod) { // 只有关键字、查询语法和正则表达式搜索支持高亮
if 0 == queryMethod { if 0 == queryMethod {
query = stringQuery(query) query = stringQuery(query)

View File

@ -269,7 +269,7 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
for _, blockValue := range blockValues.Values { for _, blockValue := range blockValues.Values {
if blockValue.Block.ID == updatedDefNode.ID { if blockValue.Block.ID == updatedDefNode.ID {
newContent := getNodeRefText(updatedDefNode) newContent := getNodeAvBlockText(updatedDefNode)
if newContent != blockValue.Block.Content { if newContent != blockValue.Block.Content {
blockValue.Block.Content = newContent blockValue.Block.Content = newContent
changedAv = true changedAv = true