mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 03:11:34 +08:00
🎨 Improve find-replace of image/link elements https://github.com/siyuan-note/siyuan/issues/14049
This commit is contained in:
parent
d97899668b
commit
c36b2a4fdc
@ -118,7 +118,7 @@ func ListInvalidBlockRefs(page, pageSize int) (ret []*Block, matchedBlockCount,
|
||||
}
|
||||
|
||||
var toRemoves []string
|
||||
for defID, _ := range invalidDefIDs {
|
||||
for defID := range invalidDefIDs {
|
||||
if _, ok := blockMap[defID]; ok {
|
||||
toRemoves = append(toRemoves, defID)
|
||||
}
|
||||
@ -148,7 +148,7 @@ func ListInvalidBlockRefs(page, pageSize int) (ret []*Block, matchedBlockCount,
|
||||
delete(refBlockMap, toRemove)
|
||||
}
|
||||
|
||||
for refID, _ := range refBlockMap {
|
||||
for refID := range refBlockMap {
|
||||
invalidBlockIDs = append(invalidBlockIDs, refID)
|
||||
}
|
||||
invalidBlockIDs = gulu.Str.RemoveDuplicatedElem(invalidBlockIDs)
|
||||
@ -596,6 +596,9 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||
}
|
||||
|
||||
replaceNodeTokens(n, method, keyword, strings.TrimSpace(replacement), r)
|
||||
if 1 > len(n.Tokens) {
|
||||
unlinks = append(unlinks, n.Parent)
|
||||
}
|
||||
case ast.NodeLinkText:
|
||||
if !replaceTypes["imgText"] {
|
||||
return ast.WalkContinue
|
||||
@ -683,6 +686,10 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||
n.TextMarkAHref = r.ReplaceAllString(n.TextMarkAHref, strings.TrimSpace(replacement))
|
||||
}
|
||||
}
|
||||
|
||||
if "" == n.TextMarkAHref {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
}
|
||||
} else if n.IsTextMarkType("em") {
|
||||
if !replaceTypes["em"] {
|
||||
|
Loading…
Reference in New Issue
Block a user