add missing emoji demo

This commit is contained in:
Philipp Kühn 2021-08-25 23:12:53 +02:00
parent d050ee164f
commit acbaa41ee0
3 changed files with 138 additions and 0 deletions

View 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/Emoji', source)
</script>
</body>
</html>

View File

@ -0,0 +1,58 @@
context('/demos/Nodes/Paragraph', () => {
before(() => {
cy.visit('/demos/Nodes/Paragraph')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.clearContent()
})
})
it('should parse paragraphs correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.commands.setContent('<p>Example Text</p>')
expect(editor.getHTML()).to.eq('<p>Example Text</p>')
editor.commands.setContent('<p><x-unknown>Example Text</x-unknown></p>')
expect(editor.getHTML()).to.eq('<p>Example Text</p>')
editor.commands.setContent('<p style="display: block;">Example Text</p>')
expect(editor.getHTML()).to.eq('<p>Example Text</p>')
})
})
it('text should be wrapped in a paragraph by default', () => {
cy.get('.ProseMirror')
.type('Example Text')
.find('p')
.should('contain', 'Example Text')
})
it('enter should make a new paragraph', () => {
cy.get('.ProseMirror')
.type('First Paragraph{enter}Second Paragraph')
.find('p')
.should('have.length', 2)
cy.get('.ProseMirror')
.find('p:first')
.should('contain', 'First Paragraph')
cy.get('.ProseMirror')
.find('p:nth-child(2)')
.should('contain', 'Second Paragraph')
})
it('backspace should remove the second paragraph', () => {
cy.get('.ProseMirror')
.type('{enter}')
.find('p')
.should('have.length', 2)
cy.get('.ProseMirror')
.type('{backspace}')
.find('p')
.should('have.length', 1)
})
})

View File

@ -0,0 +1,65 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus().insertContent('✨').run()">
</button>
<button @click="editor.chain().focus().insertContent('😅').run()">
😅
</button>
<button @click="editor.chain().focus().insertContent('🎉').run()">
🎉
</button>
<button @click="editor.chain().focus().insertContent('💖').run()">
💖
</button>
<button @click="editor.chain().focus().insertContent('👀').run()">
👀
</button>
<button @click="editor.chain().focus().insertContent('👍️').run()">
👍
</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'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document,
Paragraph,
Text,
],
})
},
beforeUnmount() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
}
</style>