Fix headline rules ignoring level 1 headlines (#5890)
Some checks are pending
build / lint (20) (push) Waiting to run
build / test (20, map[name:Demos/Examples spec:./demos/src/Examples/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Experiments spec:./demos/src/Experiments/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Extensions spec:./demos/src/Extensions/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/GuideContent spec:./demos/src/GuideContent/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/GuideGettingStarted spec:./demos/src/GuideGettingStarted/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Marks spec:./demos/src/Marks/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Nodes spec:./demos/src/Nodes/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Integration spec:./tests/cypress/integration/**/*.spec.{js,ts}]) (push) Waiting to run
build / build (20) (push) Blocked by required conditions
Publish / Release (20) (push) Waiting to run

* Fix input rules not honouring levels settings

* added changeset

---------

Co-authored-by: fridaystreet <paultrappitt@gmail.com>
This commit is contained in:
bdbch 2024-11-30 08:44:51 +01:00 committed by GitHub
parent 2acf260f85
commit 01547d5b2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -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**

View File

@ -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,