add node demos
This commit is contained in:
15
demos/src/Nodes/ListItem/Vue/index.html
Normal file
15
demos/src/Nodes/ListItem/Vue/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module">
|
||||
import setup from '../../../../setup/vue.ts'
|
||||
import source from '@source'
|
||||
setup('Nodes/ListItem', source)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
49
demos/src/Nodes/ListItem/Vue/index.spec.js
Normal file
49
demos/src/Nodes/ListItem/Vue/index.spec.js
Normal file
@@ -0,0 +1,49 @@
|
||||
context('/demos/Nodes/ListItem', () => {
|
||||
before(() => {
|
||||
cy.visit('/demos/Nodes/ListItem')
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
cy.get('.ProseMirror').then(([{ editor }]) => {
|
||||
editor.commands.setContent('<ul><li>Example Text</li></ul>')
|
||||
})
|
||||
})
|
||||
|
||||
it('should add a new list item on Enter', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('{enter}2nd Item')
|
||||
|
||||
cy.get('.ProseMirror')
|
||||
.find('li:nth-child(1)')
|
||||
.should('contain', 'Example Text')
|
||||
|
||||
cy.get('.ProseMirror')
|
||||
.find('li:nth-child(2)')
|
||||
.should('contain', '2nd Item')
|
||||
})
|
||||
|
||||
it('should sink the list item on Tab', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('{enter}')
|
||||
.trigger('keydown', { key: 'Tab' })
|
||||
|
||||
cy.get('.ProseMirror').type('2nd Level')
|
||||
|
||||
cy.get('.ProseMirror')
|
||||
.find('li:nth-child(1) li')
|
||||
.should('contain', '2nd Level')
|
||||
})
|
||||
|
||||
it('should lift the list item on Shift+Tab', () => {
|
||||
cy.get('.ProseMirror')
|
||||
.type('{enter}')
|
||||
.trigger('keydown', { key: 'Tab' })
|
||||
.trigger('keydown', { shiftKey: true, key: 'Tab' })
|
||||
|
||||
cy.get('.ProseMirror').type('1st Level')
|
||||
|
||||
cy.get('.ProseMirror')
|
||||
.find('li:nth-child(2)')
|
||||
.should('contain', '1st Level')
|
||||
})
|
||||
})
|
||||
86
demos/src/Nodes/ListItem/Vue/index.vue
Normal file
86
demos/src/Nodes/ListItem/Vue/index.vue
Normal file
@@ -0,0 +1,86 @@
|
||||
<template>
|
||||
<div v-if="editor">
|
||||
<button @click="editor.chain().focus().toggleBulletList().run()" :class="{ 'is-active': editor.isActive('bulletList') }">
|
||||
bullet list
|
||||
</button>
|
||||
<button @click="editor.chain().focus().toggleOrderedList().run()" :class="{ 'is-active': editor.isActive('orderedList') }">
|
||||
ordered list
|
||||
</button>
|
||||
|
||||
<editor-content :editor="editor" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Editor, EditorContent } from '@tiptap/vue-3'
|
||||
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 OrderedList from '@tiptap/extension-ordered-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,
|
||||
OrderedList,
|
||||
ListItem,
|
||||
],
|
||||
content: `
|
||||
<p>
|
||||
I like lists. Let’s add one:
|
||||
</p>
|
||||
<ul>
|
||||
<li>This is a bullet list.</li>
|
||||
<li>And it has three list items.</li>
|
||||
<li>Here is the third one.</li>
|
||||
</ul>
|
||||
<p>
|
||||
Do you want to see one more? I bet! Here is another one:
|
||||
</p>
|
||||
<ol>
|
||||
<li>That’s a different list, actually it’s an ordered list.</li>
|
||||
<li>It also has three list items.</li>
|
||||
<li>And all of them are numbered.</li>
|
||||
</ol>
|
||||
<p>
|
||||
Lists would be nothing without list items.
|
||||
</p>
|
||||
`,
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/* Basic editor styles */
|
||||
.ProseMirror {
|
||||
> * + * {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user