Skip to content

Commit 933b47b

Browse files
committed
implement #372
1 parent 8d09e7c commit 933b47b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

packages/core/src/config/ButtonConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface ReplaceSelfButtonAction {
8787
export interface RegexpReplaceInNoteButtonAction {
8888
type: ButtonActionType.REGEXP_REPLACE_IN_NOTE;
8989
regexp: string;
90+
regexpFlags?: string;
9091
replacement: string;
9192
}
9293

packages/core/src/config/ButtonConfigValidators.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ export const V_RegexpReplaceInNoteButtonAction = schemaForType<RegexpReplaceInNo
138138
z.object({
139139
type: z.literal(ButtonActionType.REGEXP_REPLACE_IN_NOTE),
140140
regexp: stringValidator('regexpReplaceInNote', 'regexp', 'search regular expression'),
141+
regexpFlags: stringValidator(
142+
'regexpReplaceInNote',
143+
'regexpFlags',
144+
'regular expression flags string',
145+
).optional(),
141146
replacement: stringValidator('regexpReplaceInNote', 'replacement', 'replacement string'),
142147
}),
143148
);

packages/core/src/fields/button/ButtonActionRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ export class ButtonActionRunner {
385385

386386
let content = await this.plugin.internal.readFilePath(filePath);
387387

388-
content = content.replace(new RegExp(action.regexp, 'g'), action.replacement);
388+
content = content.replace(new RegExp(action.regexp, action.regexpFlags ?? 'g'), action.replacement);
389389

390390
await this.plugin.internal.writeFilePath(filePath, content);
391391
}

0 commit comments

Comments
 (0)