Skip to content

Commit

Permalink
Fix headline rules ignoring level 1 headlines (#5890)
Browse files Browse the repository at this point in the history
* Fix input rules not honouring levels settings

* added changeset

---------

Co-authored-by: fridaystreet <[email protected]>
  • Loading branch information
bdbch and fridaystreet authored Nov 30, 2024
1 parent 2acf260 commit 01547d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-geckos-brush.md
Original file line number Diff line number Diff line change
@@ -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**
2 changes: 1 addition & 1 deletion packages/extension-heading/src/heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const Heading = Node.create<HeadingOptions>({
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,
Expand Down

0 comments on commit 01547d5

Please sign in to comment.