mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
add missing emoji demo
This commit is contained in:
parent
d050ee164f
commit
acbaa41ee0
15
demos/src/Nodes/Emoji/Vue/index.html
Normal file
15
demos/src/Nodes/Emoji/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/Emoji', source)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
58
demos/src/Nodes/Emoji/Vue/index.spec.js
Normal file
58
demos/src/Nodes/Emoji/Vue/index.spec.js
Normal 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)
|
||||
})
|
||||
})
|
65
demos/src/Nodes/Emoji/Vue/index.vue
Normal file
65
demos/src/Nodes/Emoji/Vue/index.vue
Normal 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>
|
Loading…
Reference in New Issue
Block a user