diff --git a/docs/src/demos/Extensions/Heading/index.spec.js b/docs/src/demos/Extensions/Heading/index.spec.js index 9fbac6c5..0dc1ca49 100644 --- a/docs/src/demos/Extensions/Heading/index.spec.js +++ b/docs/src/demos/Extensions/Heading/index.spec.js @@ -45,4 +45,33 @@ context('/api/extensions/heading', () => { .find('h3') .should('contain', 'Example Text') }) + + it('the button should toggle the headline', () => { + cy.get('.ProseMirror h1') + .should('not.exist') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror') + .find('h1') + .should('contain', 'Example Text') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror h1') + .should('not.exist') + }) + + it('should make a headline from the default markdown shortcut', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('# Headline') + .find('h1') + .should('contain', 'Headline') + }) }) \ No newline at end of file diff --git a/docs/src/docPages/api/extensions/heading.md b/docs/src/docPages/api/extensions/heading.md index 755edcc4..a6087725 100644 --- a/docs/src/docPages/api/extensions/heading.md +++ b/docs/src/docPages/api/extensions/heading.md @@ -1,5 +1,5 @@ # Heading -The Heading extension adds support for headlines. Headlines are rendered with `

` to `

` HTML tags. By default six headline levels are enabled, but you can pass an array to only allow a few levels, see an example below. +The Heading extension adds support for headings of different levels. Headings are rendered with `

`, `

`, `

`, `

`, `

` or `
` HTML tags. By default all six headline levels are enabled, but you can pass an array to only allow a few levels. Check the usage example to see how this is done. Type `# ​` at the beginning of a new line and it will be magically transformed to a headline, same for `## ​`, `### ​`, `#### ​`, `##### ​` and `###### ​`. diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 73558365..ae749cc2 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -136,7 +136,6 @@ link: /api/extensions/hard-break - title: Heading link: /api/extensions/heading - draft: true - title: History link: /api/extensions/history - title: HorizontalRule diff --git a/packages/extension-heading/index.ts b/packages/extension-heading/index.ts index 509027c9..f29fd39a 100644 --- a/packages/extension-heading/index.ts +++ b/packages/extension-heading/index.ts @@ -41,6 +41,7 @@ export default new Node() next() }, })) + // TODO: Keyboard Shortcuts .inputRules(({ options, type }) => { return options.levels.map((level: Level) => { return textblockTypeInputRule(new RegExp(`^(#{1,${level}})\\s$`), type, { level })