🎨 Support find replace block ref anchor text https://github.com/siyuan-note/siyuan/issues/11978

This commit is contained in:
Daniel 2024-07-15 12:18:44 +08:00
parent 498cb1ba85
commit 509beee56d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
9 changed files with 28 additions and 0 deletions

View file

@ -112,6 +112,7 @@
"strong": "Bold",
"inlineMath": "Inline formula",
"inlineMemo": "Inline memo",
"blockRef": "Ref anchor text",
"kbd": "Keyboard",
"mark": "Mark",
"s": "Strikethrough",

View file

@ -112,6 +112,7 @@
"strong": "negrita",
"inlineMath": "Fórmula en línea",
"inlineMemo": "Nota en línea",
"blockRef": "texto de anclaje de referencia",
"kbd": "Teclado",
"mark": "Marca",
"s": "Tachado",

View file

@ -112,6 +112,7 @@
"strong": "Audacieux",
"inlineMath": "Formule en ligne",
"inlineMemo": "Mémo en ligne",
"blockRef": "texte d'ancrage de référence",
"kbd": "Clavier",
"mark": "Marquer",
"s": "Barré",

View file

@ -112,6 +112,7 @@
"strong": "太字",
"inlineMath": "インライン数式",
"inlineMemo": "インラインメモ",
"blockRef": "アンカー テキストを引用する",
"kbd": "キーボード",
"mark": "ハイライト",
"s": "取り消し線",

View file

@ -112,6 +112,7 @@
"strong": "粗體",
"inlineMath": "行級公式",
"inlineMemo": "行級備註",
"blockRef": "引用錨文本",
"kbd": "鍵盤",
"mark": "高亮",
"s": "刪除",

View file

@ -112,6 +112,7 @@
"strong": "粗体",
"inlineMath": "行级公式",
"inlineMemo": "行级备注",
"blockRef": "引用锚文本",
"kbd": "键盘",
"mark": "高亮",
"s": "删除",

View file

@ -612,6 +612,7 @@ export abstract class Constants {
"strong": true,
"inlineMath": false,
"inlineMemo": true,
"blockRef": false,
"kbd": true,
"mark": true,
"s": true,

View file

@ -2105,6 +2105,11 @@ declare namespace Config {
* @default true
*/
inlineMemo?: boolean;
/**
* Replace block refs
* @default false
*/
blockRef?: boolean;
/**
* Replace kdb elements
* @default true

View file

@ -747,6 +747,22 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
}
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "text")
} else if n.IsTextMarkType("block-ref") {
if !replaceTypes["blockRef"] {
return ast.WalkContinue
}
if 0 == method {
if strings.Contains(n.TextMarkTextContent, keyword) {
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement)
n.TextMarkBlockRefSubtype = "s"
}
} else if 3 == method {
if nil != r && r.MatchString(n.TextMarkTextContent) {
n.TextMarkTextContent = r.ReplaceAllString(n.TextMarkTextContent, replacement)
n.TextMarkBlockRefSubtype = "s"
}
}
}
}
return ast.WalkContinue