Fix h1-h4 regression
This commit is contained in:
parent
c1c54c07cf
commit
3eec0758e7
@ -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") {
|
||||
|
@ -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",
|
||||
|
@ -3,6 +3,6 @@ tags: template
|
||||
description: Make this a level 1 heading
|
||||
hooks.snippet:
|
||||
slashCommand: h1
|
||||
match: "^#*\\s*"
|
||||
matchRegex: "^#*\\s*"
|
||||
---
|
||||
#
|
@ -3,6 +3,6 @@ tags: template
|
||||
description: Make this a level 2 heading
|
||||
hooks.snippet:
|
||||
slashCommand: h2
|
||||
match: "^#*\\s*"
|
||||
matchRegex: "^#*\\s*"
|
||||
---
|
||||
##
|
@ -3,6 +3,6 @@ tags: template
|
||||
description: Make this a level 3 heading
|
||||
hooks.snippet:
|
||||
slashCommand: h3
|
||||
match: "^#*\\s*"
|
||||
matchRegex: "^#*\\s*"
|
||||
---
|
||||
###
|
@ -3,6 +3,6 @@ tags: template
|
||||
description: Make this a level 4 heading
|
||||
hooks.snippet:
|
||||
slashCommand: h4
|
||||
match: "^#*\\s*"
|
||||
matchRegex: "^#*\\s*"
|
||||
---
|
||||
####
|
Loading…
Reference in New Issue
Block a user