docs: update content

This commit is contained in:
Hans Pagel
2021-03-30 20:45:48 +02:00
parent 2d74694067
commit 8fcfaef4f1
8 changed files with 156 additions and 14 deletions

View File

@@ -52,12 +52,12 @@ export default {
}
/* Placeholder (on every new line) */
// .ProseMirror p.is-empty::before {
// content: attr(data-placeholder);
// float: left;
// color: #ced4da;
// pointer-events: none;
// height: 0;
// }
/*.ProseMirror p.is-empty::before {
content: attr(data-placeholder);
float: left;
color: #ced4da;
pointer-events: none;
height: 0;
}*/
}
</style>

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,75 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus(). insertText('✨').run()">
</button>
<button @click="editor.chain().focus(). insertText('😅').run()">
😅
</button>
<button @click="editor.chain().focus(). insertText('🎉').run()">
🎉
</button>
<button @click="editor.chain().focus(). insertText('💖').run()">
💖
</button>
<button @click="editor.chain().focus(). insertText('👀').run()">
👀
</button>
<button @click="editor.chain().focus(). insertText('👍️').run()">
👍
</button>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-2'
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,
],
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
/* Basic editor styles */
.ProseMirror {
> * + * {
margin-top: 0.75em;
}
font-size: 3rem;
}
button {
margin: 0.125rem;
width: 2rem;
height: 2rem;
text-align: center;
line-height: 2rem;
}
</style>