write about the paragraph extension

This commit is contained in:
Hans Pagel 2020-09-09 16:12:39 +02:00
parent ec81bb9bc0
commit 0efab21338
4 changed files with 67 additions and 35 deletions

View File

@ -1,37 +1,5 @@
context('/api/extensions/bold', () => {
context('/api/extensions/document', () => {
beforeEach(() => {
cy.visit('/api/extensions/bold')
cy.get('.ProseMirror').window().then(window => {
const { editor } = window
editor.setContent('<p>Example Text</p>')
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')
})
cy.visit('/api/extensions/document')
})
})

View File

@ -0,0 +1,5 @@
context('/api/extensions/paragraph', () => {
beforeEach(() => {
cy.visit('/api/extensions/paragraph')
})
})

View File

@ -0,0 +1,44 @@
<template>
<div v-if="editor">
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
new Document(),
new Paragraph(),
new Text(),
],
content: `
<p>The Paragraph extension is not required, but its very likely you want to use it. Its needed to write paragraphs of text. 🤓</p>
`,
})
window.editor = this.editor
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>

View File

@ -1,2 +1,17 @@
# Paragraph
Enables you to use paragraphs in the editor.
Enables you to use paragraphs in the editor.
## Options
*None*
## Commands
*None*
## Keybindings
*None*
## Source Code
[packages/extension-paragraph/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-paragraph/)
## Usage
<demo name="Extensions/Paragraph" highlight="11,29" />