diff --git a/docs/src/demos/Extensions/ListItem/index.spec.js b/docs/src/demos/Extensions/ListItem/index.spec.js new file mode 100644 index 00000000..19aa202d --- /dev/null +++ b/docs/src/demos/Extensions/ListItem/index.spec.js @@ -0,0 +1,5 @@ +context('/api/extensions/list-item', () => { + before(() => { + cy.visit('/api/extensions/list-item') + }) +}) \ No newline at end of file diff --git a/docs/src/demos/Extensions/ListItem/index.vue b/docs/src/demos/Extensions/ListItem/index.vue new file mode 100644 index 00000000..531a5e13 --- /dev/null +++ b/docs/src/demos/Extensions/ListItem/index.vue @@ -0,0 +1,73 @@ + + + \ No newline at end of file diff --git a/docs/src/demos/Extensions/OrderedList/index.spec.js b/docs/src/demos/Extensions/OrderedList/index.spec.js new file mode 100644 index 00000000..aeab1b8b --- /dev/null +++ b/docs/src/demos/Extensions/OrderedList/index.spec.js @@ -0,0 +1,97 @@ +context('/api/extensions/ordered-list', () => { + before(() => { + cy.visit('/api/extensions/ordered-list') + }) + + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.setContent('

Example Text

') + editor.selectAll() + }) + }) + + it('the button should make the selected line a ordered list item', () => { + cy.get('.ProseMirror ol') + .should('not.exist') + + cy.get('.ProseMirror ol li') + .should('not.exist') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror') + .find('ol') + .should('contain', 'Example Text') + + cy.get('.ProseMirror') + .find('ol li') + .should('contain', 'Example Text') + }) + + it('the button should toggle the ordered list', () => { + cy.get('.ProseMirror ol') + .should('not.exist') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror') + .find('ol') + .should('contain', 'Example Text') + + cy.get('.demo__preview button:nth-child(1)') + .click() + + cy.get('.ProseMirror ol') + .should('not.exist') + }) + + it('should leave the list with double enter', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('1. List Item 1{enter}{enter}Paragraph') + + cy.get('.ProseMirror') + .find('li') + .its('length') + .should('eq', 1) + + cy.get('.ProseMirror') + .find('p') + .should('contain', 'Paragraph') + }) + + it('should make a ordered list from a number', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('1. List Item 1{enter}List Item 2') + + cy.get('.ProseMirror') + .find('li:nth-child(1)') + .should('contain', 'List Item 1') + + cy.get('.ProseMirror') + .find('li:nth-child(2)') + .should('contain', 'List Item 2') + }) + + it('should remove the ordered list after pressing backspace', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.clearContent() + }) + + cy.get('.ProseMirror') + .type('1. {backspace}Example') + + cy.get('.ProseMirror') + .find('p') + .should('contain', '1. Example') + }) +}) \ No newline at end of file diff --git a/docs/src/demos/Extensions/OrderedList/index.vue b/docs/src/demos/Extensions/OrderedList/index.vue new file mode 100644 index 00000000..181e8c00 --- /dev/null +++ b/docs/src/demos/Extensions/OrderedList/index.vue @@ -0,0 +1,53 @@ + + + \ No newline at end of file diff --git a/docs/src/docPages/api/extensions/list-item.md b/docs/src/docPages/api/extensions/list-item.md index dacf64ed..05ef5d8c 100644 --- a/docs/src/docPages/api/extensions/list-item.md +++ b/docs/src/docPages/api/extensions/list-item.md @@ -1,11 +1,11 @@ # ListItem -Enables you to use the `
  • ` HTML tag in the editor. - -::: warning Restrictions -This extensions is intended to be used with the `BulletList` or `OrderedList` extension. -::: +The ListItem extension adds support for the `
  • ` HTML tag. It’s used for bullet lists and ordered lists and can’t really be used without them. ## Installation +::: warning Restrictions +This extensions is intended to be used with the [`BulletList`](/api/extensions/bullet-list) or [`OrderedList`](/api/extensions/ordered-list) extension. It doesn’t work without at least using one of them. +::: + ```bash # With npm npm install @tiptap/extension-list-item @@ -17,4 +17,18 @@ yarn add @tiptap/extension-list-item ## Settings | Option | Type | Default | Description | | ------ | ------ | ------- | -------------------------------------------- | -| class | string | – | Add a custom class to the rendered HTML tag. | \ No newline at end of file +| class | string | – | Add a custom class to the rendered HTML tag. | + +## Commands +*None* + +## Keyboard shortcuts +* New list item: `Enter` +* Sink a list item: `Tab` +* Lift a list item: `Shift` + `Tab` + +## Source code +[packages/extension-list-item/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-list-item/) + +## Usage + \ No newline at end of file diff --git a/docs/src/docPages/api/extensions/ordered-list.md b/docs/src/docPages/api/extensions/ordered-list.md index b995d6ee..e7bf787f 100644 --- a/docs/src/docPages/api/extensions/ordered-list.md +++ b/docs/src/docPages/api/extensions/ordered-list.md @@ -1,5 +1,7 @@ # OrderedList -Enables you to use the `
      ` HTML tag in the editor. +This extension enables you to use ordered lists in the editor. They are rendered as `
        ` HTML tags, + +Type 1.  (or any other number followed by a dot) at the beginning of a new line and it will magically transform to a ordered list. ## Installation ::: warning Use with ListItem @@ -20,57 +22,15 @@ yarn add @tiptap/extension-ordered-list @tiptap/extension-list-item | class | string | – | Add a custom class to the rendered HTML tag. | ## Commands -| Command | Options | Description | -| ------------ | ------- | ----------------------- | -| ordered_list | — | Toggle an ordered list. | +| Command | Options | Description | +| ----------- | ------- | --------------------- | +| ordered_list | — | Toggle a ordered list. | ## Keyboard shortcuts * `Control` + `Shift` + `9` +## Source code +[packages/extension-ordered-list/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-ordered-list/) + ## Usage -```markup - - - -``` \ No newline at end of file + diff --git a/docs/src/links.yaml b/docs/src/links.yaml index 122a5f9a..13cc80dc 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -107,7 +107,6 @@ link: /api/extensions/bold - title: BulletList link: /api/extensions/bullet-list - draft: true - title: Code link: /api/extensions/code - title: CodeBlock @@ -135,13 +134,11 @@ draft: true - title: ListItem link: /api/extensions/list-item - draft: true # - title: Mention # link: /api/extensions/mention # draft: true - title: OrderedList link: /api/extensions/ordered-list - draft: true - title: Paragraph link: /api/extensions/paragraph # - title: Placeholder