add a demo to the bullet list extension page

This commit is contained in:
Hans Pagel 2020-09-15 16:50:54 +02:00
parent a917264057
commit f7f3d29fe5
3 changed files with 71 additions and 43 deletions

View File

@ -0,0 +1,12 @@
context('/api/extensions/bullet-list', () => {
before(() => {
cy.visit('/api/extensions/bullet-list')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
editor.selectAll()
})
})
})

View File

@ -0,0 +1,55 @@
<template>
<div v-if="editor">
<!-- <button @click="editor.focus().bulletList()" :class="{ 'is-active': editor.isActive('bulletList') }">
bullet list
</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 BulletList from '@tiptap/extension-bullet-list'
import ListItem from '@tiptap/extension-list-item'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
BulletList(),
ListItem(),
],
content: `
<ul>
<li>A list item</li>
<li>And another one</li>
</ul>
`,
})
window.editor = this.editor
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>

View File

@ -18,47 +18,8 @@ Its intended to be used with the `ListItem` extension.
## Keyboard shortcuts
* `Control` + `Shift` + `8`
## Source Code
[packages/extension-bullet-list/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-bullet-list/)
## Usage
```markup
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<button type="button" :class="{ 'is-active': isActive.bullet_list() }" @click="commands.bullet_list">
Bullet List
</button>
</editor-menu-bar>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { BulletList } from 'tiptap-extensions'
export default {
components: {
EditorMenuBar,
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
BulletList(),
],
content: `
<ul>
<li>A list item</li>
<li>And another one</li>
</ul>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>
```
<demo name="Extensions/BulletList" highlight="3-5,17-18,37-38" />