🎨 Find-replace support file annotation ref elements https://github.com/siyuan-note/siyuan/issues/13013

This commit is contained in:
Daniel 2024-11-04 10:50:31 +08:00
parent 4e6651c46e
commit fa2f8ed7e5
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
16 changed files with 58 additions and 26 deletions

View File

@ -134,6 +134,7 @@
"inlineMath": "Inline-Formel", "inlineMath": "Inline-Formel",
"inlineMemo": "Inline-Notiz", "inlineMemo": "Inline-Notiz",
"blockRef": "Referenz-Ankertext", "blockRef": "Referenz-Ankertext",
"fileAnnotationRef": "PDF-Anmerkungsankertext",
"kbd": "Tastatur", "kbd": "Tastatur",
"mark": "Markierung", "mark": "Markierung",
"s": "Durchgestrichen", "s": "Durchgestrichen",

View File

@ -134,6 +134,7 @@
"inlineMath": "Inline formula", "inlineMath": "Inline formula",
"inlineMemo": "Inline memo", "inlineMemo": "Inline memo",
"blockRef": "Ref anchor text", "blockRef": "Ref anchor text",
"fileAnnotationRef": "PDF annotation anchor text",
"kbd": "Keyboard", "kbd": "Keyboard",
"mark": "Mark", "mark": "Mark",
"s": "Strikethrough", "s": "Strikethrough",

View File

@ -133,7 +133,8 @@
"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", "blockRef": "Texto de anclaje de referencia",
"fileAnnotationRef": "Texto de anclaje de la anotación PDF",
"kbd": "Teclado", "kbd": "Teclado",
"mark": "Marca", "mark": "Marca",
"s": "Tachado", "s": "Tachado",

View File

@ -133,7 +133,8 @@
"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", "blockRef": "Texte d'ancrage de référence",
"fileAnnotationRef": "Texte d'ancrage de l'annotation PDF",
"kbd": "Clavier", "kbd": "Clavier",
"mark": "Marquer", "mark": "Marquer",
"s": "Barré", "s": "Barré",

View File

@ -134,6 +134,7 @@
"inlineMath": "מתמטיקה פנימית", "inlineMath": "מתמטיקה פנימית",
"inlineMemo": "הערה פנימית", "inlineMemo": "הערה פנימית",
"blockRef": "טקסט עוגן ייחוס", "blockRef": "טקסט עוגן ייחוס",
"fileAnnotationRef": "טקסט עוגן של הערת PDF",
"kbd": "מקלדת", "kbd": "מקלדת",
"mark": "ציון", "mark": "ציון",
"s": "קו מחיקה", "s": "קו מחיקה",

View File

@ -134,6 +134,7 @@
"inlineMath": "Formula in linea", "inlineMath": "Formula in linea",
"inlineMemo": "Memo in linea", "inlineMemo": "Memo in linea",
"blockRef": "Testo ancora di riferimento", "blockRef": "Testo ancora di riferimento",
"fileAnnotationRef": "Testo di ancoraggio dell'annotazione PDF",
"kbd": "Tastiera", "kbd": "Tastiera",
"mark": "Evidenzia", "mark": "Evidenzia",
"s": "Barrato", "s": "Barrato",

View File

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

View File

@ -134,6 +134,7 @@
"inlineMath": "Formuła w linii", "inlineMath": "Formuła w linii",
"inlineMemo": "Notatka w linii", "inlineMemo": "Notatka w linii",
"blockRef": "Tekst zakotwiczenia ref", "blockRef": "Tekst zakotwiczenia ref",
"fileAnnotationRef": "Odnośnik do adnotacji PDF",
"kbd": "Klawiatura", "kbd": "Klawiatura",
"mark": "Zaznacz", "mark": "Zaznacz",
"s": "Przekreślenie", "s": "Przekreślenie",

View File

@ -134,6 +134,7 @@
"inlineMath": "Встраиваемая формула", "inlineMath": "Встраиваемая формула",
"inlineMemo": "Встраиваемая заметка", "inlineMemo": "Встраиваемая заметка",
"blockRef": "Текст анкора ссылки", "blockRef": "Текст анкора ссылки",
"fileAnnotationRef": "Анкор текста аннотации PDF",
"kbd": "Клавиатура", "kbd": "Клавиатура",
"mark": "Знак", "mark": "Знак",
"s": "Перечеркнуто", "s": "Перечеркнуто",

View File

@ -134,6 +134,7 @@
"inlineMath": "行級公式", "inlineMath": "行級公式",
"inlineMemo": "行級備註", "inlineMemo": "行級備註",
"blockRef": "引用錨文本", "blockRef": "引用錨文本",
"fileAnnotationRef": "PDF 標註錨文本",
"kbd": "鍵盤", "kbd": "鍵盤",
"mark": "高亮", "mark": "高亮",
"s": "刪除", "s": "刪除",

View File

@ -134,6 +134,7 @@
"inlineMath": "行级公式", "inlineMath": "行级公式",
"inlineMemo": "行级备注", "inlineMemo": "行级备注",
"blockRef": "引用锚文本", "blockRef": "引用锚文本",
"fileAnnotationRef": "PDF 标注锚文本",
"kbd": "键盘", "kbd": "键盘",
"mark": "高亮", "mark": "高亮",
"s": "删除", "s": "删除",

View File

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

View File

@ -2138,6 +2138,10 @@ declare namespace Config {
* @default false * @default false
*/ */
blockRef?: boolean; blockRef?: boolean;
/**
* Replace file annotation refs
*/
fileAnnotationRef?: boolean;
/** /**
* Replace kdb elements * Replace kdb elements
* @default true * @default true

View File

@ -122,7 +122,7 @@ func findReplace(c *gin.Context) {
} }
replaceTypes := map[string]bool{} replaceTypes := map[string]bool{}
// text, imgText, imgTitle, imgSrc, aText, aTitle, aHref, code, em, strong, inlineMath, inlineMemo, kbd, mark, s, sub, sup, tag, u // text, imgText, imgTitle, imgSrc, aText, aTitle, aHref, code, em, strong, inlineMath, inlineMemo, blockRef, fileAnnotationRef kbd, mark, s, sub, sup, tag, u
// docTitle, codeBlock, mathBlock, htmlBlock // docTitle, codeBlock, mathBlock, htmlBlock
if nil != arg["replaceTypes"] { if nil != arg["replaceTypes"] {
replaceTypesArg := arg["replaceTypes"].(map[string]interface{}) replaceTypesArg := arg["replaceTypes"].(map[string]interface{})

View File

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

View File

@ -195,29 +195,31 @@ type CriterionTypes struct {
} }
type CriterionReplaceTypes struct { type CriterionReplaceTypes struct {
Text bool `json:"text"` Text bool `json:"text"`
ImgText bool `json:"imgText"` ImgText bool `json:"imgText"`
ImgTitle bool `json:"imgTitle"` ImgTitle bool `json:"imgTitle"`
ImgSrc bool `json:"imgSrc"` ImgSrc bool `json:"imgSrc"`
AText bool `json:"aText"` AText bool `json:"aText"`
ATitle bool `json:"aTitle"` ATitle bool `json:"aTitle"`
AHref bool `json:"aHref"` AHref bool `json:"aHref"`
Code bool `json:"code"` Code bool `json:"code"`
Em bool `json:"em"` Em bool `json:"em"`
Strong bool `json:"strong"` Strong bool `json:"strong"`
InlineMath bool `json:"inlineMath"` InlineMath bool `json:"inlineMath"`
InlineMemo bool `json:"inlineMemo"` InlineMemo bool `json:"inlineMemo"`
Kbd bool `json:"kbd"` BlockRef bool `json:"blockRef"`
Mark bool `json:"mark"` FileAnnotationRef bool `json:"fileAnnotationRef"`
S bool `json:"s"` Kbd bool `json:"kbd"`
Sub bool `json:"sub"` Mark bool `json:"mark"`
Sup bool `json:"sup"` S bool `json:"s"`
Tag bool `json:"tag"` Sub bool `json:"sub"`
U bool `json:"u"` Sup bool `json:"sup"`
DocTitle bool `json:"docTitle"` Tag bool `json:"tag"`
CodeBlock bool `json:"codeBlock"` U bool `json:"u"`
MathBlock bool `json:"mathBlock"` DocTitle bool `json:"docTitle"`
HtmlBlock bool `json:"htmlBlock"` CodeBlock bool `json:"codeBlock"`
MathBlock bool `json:"mathBlock"`
HtmlBlock bool `json:"htmlBlock"`
} }
var criteriaLock = sync.Mutex{} var criteriaLock = sync.Mutex{}