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,58 @@
context('/api/nodes/hard-break', () => {
before(() => {
cy.visit('/api/nodes/hard-break')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
})
})
it('should parse hard breaks correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example<br>Text</p>')
expect(editor.getHTML()).to.eq('<p>Example<br>Text</p>')
})
})
it('should parse hard breaks with self-closing tag correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example<br />Text</p>')
expect(editor.getHTML()).to.eq('<p>Example<br>Text</p>')
})
})
it('the button should add a line break', () => {
cy.get('.ProseMirror br')
.should('not.exist')
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror br')
.should('exist')
})
it.skip('the default keyboard shortcut should add a line break', () => {
cy.get('.ProseMirror br')
.should('not.exist')
cy.get('.ProseMirror')
.trigger('keydown', { shiftKey: true, key: 'Enter' })
cy.get('.ProseMirror br')
.should('exist')
})
it('the alternative keyboard shortcut should add a line break', () => {
cy.get('.ProseMirror br')
.should('not.exist')
cy.get('.ProseMirror')
.trigger('keydown', { modKey: true, key: 'Enter' })
cy.get('.ProseMirror br')
.should('exist')
})
})

View File

@@ -0,0 +1,57 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus().hardBreak().run()">
hardBreak
</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 HardBreak from '@tiptap/extension-hard-break'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
HardBreak(),
],
content: `
<p>
This<br>
is<br>
a<br>
single<br>
paragraph<br>
with<br>
line<br>
breaks.
</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>