diff --git a/docs/src/demos/Extensions/Document/index.spec.js b/docs/src/demos/Extensions/Document/index.spec.js new file mode 100644 index 00000000..85a66e41 --- /dev/null +++ b/docs/src/demos/Extensions/Document/index.spec.js @@ -0,0 +1,37 @@ +context('/api/extensions/bold', () => { + beforeEach(() => { + cy.visit('/api/extensions/bold') + + cy.get('.ProseMirror').window().then(window => { + const { editor } = window + editor.setContent('

Example Text

') + editor.focus().selectAll() + }) + }) + + describe('bold', () => { + it('the button should make the selected text bold', () => { + cy.get('.demo__preview button:first').click({ force: true }) + cy.get('.ProseMirror').contains('strong', 'Example Text') + }) + + it('the button should toggle the selected text bold', () => { + cy.get('.demo__preview button:first').dblclick({ force: true }) + cy.get('.ProseMirror strong').should('not.exist') + }) + + it('the keyboard shortcut should make the selected text bold', () => { + const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b' + + cy.get('.ProseMirror').type(shortcut, {force: true}) + cy.get('.ProseMirror').contains('strong', 'Example Text') + }) + + it('the keyboard shortcut should toggle the selected text bold', () => { + const shortcut = Cypress.platform === 'darwin' ? '{meta}b' : '{ctrl}b' + + cy.get('.ProseMirror').type(shortcut, {force: true}).type(shortcut, {force: true}) + cy.get('.ProseMirror strong').should('not.exist') + }) + }) +}) \ No newline at end of file diff --git a/docs/src/demos/Extensions/Document/index.vue b/docs/src/demos/Extensions/Document/index.vue new file mode 100644 index 00000000..dfb3d3ea --- /dev/null +++ b/docs/src/demos/Extensions/Document/index.vue @@ -0,0 +1,44 @@ + + + \ No newline at end of file diff --git a/docs/src/docPages/api/extensions/document.md b/docs/src/docPages/api/extensions/document.md index eb9d8f65..017eec5b 100644 --- a/docs/src/docPages/api/extensions/document.md +++ b/docs/src/docPages/api/extensions/document.md @@ -1 +1,14 @@ -# Document \ No newline at end of file +# Document +**The `Document` extension is required**, no matter what you build with tiptap. It’s a so called “topNode”, a node that’s the home to all other nodes. Think of it like the `` tag for your document. + +The node is very tiny though. It defines a name of the node (`document`), is configured to be a top node (`topNode: true`) and that it can contain multiple other nodes (`block`). That’s all. But have a look yourself: + +:::warning Breaking Change from 1.x → 2.x +Tiptap 1 tried to hide that node from you, but it has always been there. A tiny, but important change though: **We renamed the default type from `doc` to `document`.** To keep it like that, use your own implementation of the `Document` node or migrate the stored JSON to use the new name. +::: + +## Source Code +[packages/extension-document/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-document/) + +## Usage + \ No newline at end of file diff --git a/docs/src/links.yaml b/docs/src/links.yaml index b3216fd1..31fce64b 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -128,7 +128,6 @@ # draft: true - title: Document link: /api/extensions/document - draft: true - title: Hardbreak link: /api/extensions/hard-break draft: true