mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-29 08:19:34 +08:00
write about the paragraph extension
This commit is contained in:
parent
ec81bb9bc0
commit
0efab21338
@ -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')
|
||||
})
|
||||
})
|
5
docs/src/demos/Extensions/Paragraph/index.spec.js
Normal file
5
docs/src/demos/Extensions/Paragraph/index.spec.js
Normal file
@ -0,0 +1,5 @@
|
||||
context('/api/extensions/paragraph', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/api/extensions/paragraph')
|
||||
})
|
||||
})
|
44
docs/src/demos/Extensions/Paragraph/index.vue
Normal file
44
docs/src/demos/Extensions/Paragraph/index.vue
Normal 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 it’s very likely you want to use it. It’s needed to write paragraphs of text. 🤓</p>
|
||||
`,
|
||||
})
|
||||
|
||||
window.editor = this.editor
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
}
|
||||
}
|
||||
</script>
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user