🎨 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", "strong": "Bold",
"inlineMath": "Inline formula", "inlineMath": "Inline formula",
"inlineMemo": "Inline memo", "inlineMemo": "Inline memo",
"blockRef": "Ref anchor text",
"kbd": "Keyboard", "kbd": "Keyboard",
"mark": "Mark", "mark": "Mark",
"s": "Strikethrough", "s": "Strikethrough",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2105,6 +2105,11 @@ declare namespace Config {
* @default true * @default true
*/ */
inlineMemo?: boolean; inlineMemo?: boolean;
/**
* Replace block refs
* @default false
*/
blockRef?: boolean;
/** /**
* Replace kdb elements * Replace kdb elements
* @default true * @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") 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 return ast.WalkContinue