* Rewrite the value of every inline field named `key` on a single line, * leaving the key, surrounding text, and any `[...]`/`(...)` wrapper intact. * * This is the write-side counterpart to parseInlineContent: because * it reuses the same field boundaries, a full-line va
(line: string, key: string, newValue: string)
| 443 | * field matches. |
| 444 | */ |
| 445 | public replaceInlineFieldValue(line: string, key: string, newValue: string): string { |
| 446 | const matches = this.parseLineFields(line).filter(field => field.key === key); |
| 447 | if (matches.length === 0) return line; |
| 448 | |
| 449 | // Splice right-to-left so each field's offsets stay valid as we rewrite. |
| 450 | let result = line; |
| 451 | for (let i = matches.length - 1; i >= 0; i--) { |
| 452 | const field = matches[i]; |
| 453 | result = result.slice(0, field.sepEnd) + " " + newValue + result.slice(field.valueEnd); |
| 454 | } |
| 455 | return result; |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Rewrite inline field values in raw note content using the same readable-line |