diff --git a/.changeset/few-geckos-brush.md b/.changeset/few-geckos-brush.md new file mode 100644 index 000000000..d0643beb7 --- /dev/null +++ b/.changeset/few-geckos-brush.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-heading": patch +--- + +Fixed a bug causing the levels rule to be ignored if a level of 1 was **not allowed** diff --git a/packages/extension-heading/src/heading.ts b/packages/extension-heading/src/heading.ts index ff417a304..61c88e5a2 100644 --- a/packages/extension-heading/src/heading.ts +++ b/packages/extension-heading/src/heading.ts @@ -117,7 +117,7 @@ export const Heading = Node.create({ addInputRules() { return this.options.levels.map(level => { return textblockTypeInputRule({ - find: new RegExp(`^(#{1,${level}})\\s$`), + find: new RegExp(`^(#{${Math.min(...this.options.levels)},${level}})\\s$`), type: this.type, getAttributes: { level,