move everything around, add more content and a first test for images

This commit is contained in:
Hans Pagel
2020-11-03 16:43:35 +01:00
parent 9bcdb57f14
commit 34a3a7fe26
64 changed files with 177 additions and 70 deletions

View File

@@ -0,0 +1,66 @@
context('/api/nodes/horizontal-rule', () => {
before(() => {
cy.visit('/api/nodes/horizontal-rule')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
})
})
it('should parse horizontal rules correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p><hr>')
expect(editor.getHTML()).to.eq('<p>Example Text</p><hr>')
})
})
it('should parse horizontal rules with self-closing tag correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p><hr />')
expect(editor.getHTML()).to.eq('<p>Example Text</p><hr>')
})
})
it('the button should add a horizontal rule', () => {
cy.get('.ProseMirror hr')
.should('not.exist')
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror hr')
.should('exist')
})
it('the default markdown shortcut should add a horizontal rule', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.clearContent()
cy.get('.ProseMirror hr')
.should('not.exist')
cy.get('.ProseMirror')
.type('---')
cy.get('.ProseMirror hr')
.should('exist')
})
})
it('the alternative markdown shortcut should add a horizontal rule', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.clearContent()
cy.get('.ProseMirror hr')
.should('not.exist')
cy.get('.ProseMirror')
.type('___ ')
cy.get('.ProseMirror hr')
.should('exist')
})
})
})

View File

@@ -0,0 +1,52 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus().horizontalRule().run()">
horizontalRule
</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 HorizontalRule from '@tiptap/extension-horizontal-rule'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
HorizontalRule(),
],
content: `
<p>This is a paragraph.</p>
<hr>
<p>And this is another paragraph.</p>
<hr>
<p>But between those paragraphs are horizontal rules.</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>