From 6f898a004b35a5213e268056d2dbb3cbdd19c81b Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 10 Sep 2020 12:55:15 +0200 Subject: [PATCH] add a demo and tests to the horizontal rule extension --- .../Extensions/HorizontalRule/index.spec.js | 40 ++++++++++++++ .../demos/Extensions/HorizontalRule/index.vue | 54 +++++++++++++++++++ .../src/docPages/api/extensions/blockquote.md | 2 +- .../api/extensions/horizontal-rule.md | 12 ++++- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 docs/src/demos/Extensions/HorizontalRule/index.spec.js create mode 100644 docs/src/demos/Extensions/HorizontalRule/index.vue diff --git a/docs/src/demos/Extensions/HorizontalRule/index.spec.js b/docs/src/demos/Extensions/HorizontalRule/index.spec.js new file mode 100644 index 00000000..96c0fdb7 --- /dev/null +++ b/docs/src/demos/Extensions/HorizontalRule/index.spec.js @@ -0,0 +1,40 @@ +context('/api/extensions/horizontal-rule', () => { + beforeEach(() => { + cy.visit('/api/extensions/horizontal-rule') + + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.setContent('

Example Text

') + }) + }) + + describe('horizontal-rule', () => { + it('the button should add a horizontal rule', () => { + cy.get('.ProseMirror hr').should('not.exist') + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror hr').should('exist') + }) + + it('the default markdown shortcut should add a horizontal rule', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.clearContent() + + cy.get('.ProseMirror hr').should('not.exist') + cy.get('.ProseMirror').type('---', {force: true}) + cy.get('.ProseMirror hr').should('exist') + }) + }) + + it('the alternative markdown shortcut should add a horizontal rule', () => { + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.clearContent() + + cy.get('.ProseMirror hr').should('not.exist') + cy.get('.ProseMirror').type('___ ', {force: true}) + cy.get('.ProseMirror hr').should('exist') + }) + }) + }) +}) \ No newline at end of file diff --git a/docs/src/demos/Extensions/HorizontalRule/index.vue b/docs/src/demos/Extensions/HorizontalRule/index.vue new file mode 100644 index 00000000..563169fe --- /dev/null +++ b/docs/src/demos/Extensions/HorizontalRule/index.vue @@ -0,0 +1,54 @@ + + + \ No newline at end of file diff --git a/docs/src/docPages/api/extensions/blockquote.md b/docs/src/docPages/api/extensions/blockquote.md index b6d4e9c8..392fb229 100644 --- a/docs/src/docPages/api/extensions/blockquote.md +++ b/docs/src/docPages/api/extensions/blockquote.md @@ -1,7 +1,7 @@ # Blockquote The Blockquote extension enables you to use the `
` HTML tag in the editor. This is great – you might have guessed – to use quotes in the editor. -Type `> ` on the beginning of a new line and it will be magically transformed to a blockquote. +Type `> ` at the beginning of a new line and it will be magically transformed to a blockquote. ## Options | Option | Type | Default | Description | diff --git a/docs/src/docPages/api/extensions/horizontal-rule.md b/docs/src/docPages/api/extensions/horizontal-rule.md index 5c64e87f..616ada6e 100644 --- a/docs/src/docPages/api/extensions/horizontal-rule.md +++ b/docs/src/docPages/api/extensions/horizontal-rule.md @@ -1,5 +1,7 @@ # HorizontalRule -Enables you to use the `
` HTML tag in the editor. +Use this extension to render a `
` HTML tag. If you pass `
` in the editor’s initial content, it’ll be rendered accordingly. + +Type `---` (three dashes) or `___ ` (three underscores and a space) at the beginning of a new line and it will be magically transformed to a horizontal rule. ## Options | Option | Type | Default | Description | @@ -9,11 +11,17 @@ Enables you to use the `
` HTML tag in the editor. ## Commands | Command | Options | Description | | --------------- | ------- | ------------------------- | -| horizontal_rule | — | Create a horizontal rule. | +| horizontalRule | — | Create a horizontal rule. | ## Keyboard shortcuts *None* +## Source Code +[packages/extension-horizontal-rule/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-horizontal-rule/) + +## Usage + + ## Usage ```markup