diff --git a/plugs/template/snippet.ts b/plugs/template/snippet.ts index d372437..0856265 100644 --- a/plugs/template/snippet.ts +++ b/plugs/template/snippet.ts @@ -107,10 +107,12 @@ export async function insertSnippetTemplate(slashCompletion: SlashCompletion) { cursorPos = await editor.getCursor(); - if (snippetTemplate.matchRegex) { + if (snippetTemplate.match || snippetTemplate.matchRegex) { const pageText = await editor.getText(); // Regex matching mode - const matchRegex = new RegExp(snippetTemplate.matchRegex); + const matchRegex = new RegExp( + (snippetTemplate.match || snippetTemplate.matchRegex)!, + ); let startOfLine = cursorPos; while (startOfLine > 0 && pageText[startOfLine - 1] !== "\n") { diff --git a/plugs/template/types.ts b/plugs/template/types.ts index 80022da..85a63ca 100644 --- a/plugs/template/types.ts +++ b/plugs/template/types.ts @@ -36,6 +36,8 @@ export const SnippetConfig = refineCommand( slashCommand: z.string(), // trigger // Regex match to apply (implicitly makes the body the regex replacement) matchRegex: z.string().optional(), + // Deprecated: use matchRegex instead (for backwards compatibility) + match: z.string().optional(), insertAt: z.enum([ "cursor", "line-start", diff --git a/website/Library/Core/Snippet/h1.md b/website/Library/Core/Snippet/h1.md index 0b4a3d0..55fc849 100644 --- a/website/Library/Core/Snippet/h1.md +++ b/website/Library/Core/Snippet/h1.md @@ -3,6 +3,6 @@ tags: template description: Make this a level 1 heading hooks.snippet: slashCommand: h1 - match: "^#*\\s*" + matchRegex: "^#*\\s*" --- # \ No newline at end of file diff --git a/website/Library/Core/Snippet/h2.md b/website/Library/Core/Snippet/h2.md index b8c31ae..e2b5a4e 100644 --- a/website/Library/Core/Snippet/h2.md +++ b/website/Library/Core/Snippet/h2.md @@ -3,6 +3,6 @@ tags: template description: Make this a level 2 heading hooks.snippet: slashCommand: h2 - match: "^#*\\s*" + matchRegex: "^#*\\s*" --- ## \ No newline at end of file diff --git a/website/Library/Core/Snippet/h3.md b/website/Library/Core/Snippet/h3.md index b918906..5c23af5 100644 --- a/website/Library/Core/Snippet/h3.md +++ b/website/Library/Core/Snippet/h3.md @@ -3,6 +3,6 @@ tags: template description: Make this a level 3 heading hooks.snippet: slashCommand: h3 - match: "^#*\\s*" + matchRegex: "^#*\\s*" --- ### \ No newline at end of file diff --git a/website/Library/Core/Snippet/h4.md b/website/Library/Core/Snippet/h4.md index c0761eb..f9a47fc 100644 --- a/website/Library/Core/Snippet/h4.md +++ b/website/Library/Core/Snippet/h4.md @@ -3,6 +3,6 @@ tags: template description: Make this a level 4 heading hooks.snippet: slashCommand: h4 - match: "^#*\\s*" + matchRegex: "^#*\\s*" --- #### \ No newline at end of file