add basic text align extension
This commit is contained in:
18
docs/src/demos/Extensions/TextAlign/index.spec.js
Normal file
18
docs/src/demos/Extensions/TextAlign/index.spec.js
Normal file
@@ -0,0 +1,18 @@
|
||||
context('/api/extensions/text', () => {
|
||||
before(() => {
|
||||
cy.visit('/api/extensions/text')
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||
editor.clearContent()
|
||||
})
|
||||
})
|
||||
|
||||
it('text should be wrapped in a paragraph by default', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('Example Text')
|
||||
.find('p')
|
||||
.should('contain', 'Example Text')
|
||||
})
|
||||
})
|
||||
54
docs/src/demos/Extensions/TextAlign/index.vue
Normal file
54
docs/src/demos/Extensions/TextAlign/index.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div v-if="editor">
|
||||
<button @click="editor.chain().focus().setAttributes({ align: 'left' }).run()">
|
||||
left
|
||||
</button>
|
||||
<button @click="editor.chain().focus().setAttributes({ align: 'center' }).run()">
|
||||
center
|
||||
</button>
|
||||
<button @click="editor.chain().focus().setAttributes({ align: 'right' }).run()">
|
||||
right
|
||||
</button>
|
||||
<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'
|
||||
import TextAlign from '@tiptap/extension-text-align'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
EditorContent,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: [
|
||||
Document(),
|
||||
Paragraph(),
|
||||
Text(),
|
||||
TextAlign(),
|
||||
],
|
||||
content: `
|
||||
<p>first paragraph</p>
|
||||
<p>second paragraph</p>
|
||||
`,
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
16
docs/src/docPages/api/extensions/text-align.md
Normal file
16
docs/src/docPages/api/extensions/text-align.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Text Align
|
||||
|
||||
## Installation
|
||||
```bash
|
||||
# With npm
|
||||
npm install @tiptap/extension-text-align
|
||||
|
||||
# Or: With Yarn
|
||||
yarn add @tiptap/extension-text-align
|
||||
```
|
||||
|
||||
## Source code
|
||||
[packages/extension-text-align/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-text-align/)
|
||||
|
||||
## Usage
|
||||
<demo name="Extensions/TextAlign" highlight="12,30" />
|
||||
@@ -161,6 +161,8 @@
|
||||
# draft: true
|
||||
- title: Text
|
||||
link: /api/extensions/text
|
||||
- title: Text Align
|
||||
link: /api/extensions/text-align
|
||||
# - title: TodoItem
|
||||
# link: /api/extensions/todo-item
|
||||
# draft: true
|
||||
|
||||
Reference in New Issue
Block a user