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,86 @@
context('/api/marks/strike', () => {
before(() => {
cy.visit('/api/marks/strike')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
editor.selectAll()
})
})
it('should parse s tags correctly', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p><s>Example Text</s></p>')
expect(editor.getHTML()).to.eq('<p><s>Example Text</s></p>')
})
})
it('should transform del tags to s tags', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p><del>Example Text</del></p>')
expect(editor.getHTML()).to.eq('<p><s>Example Text</s></p>')
})
})
it('should transform strike tags to s tags', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p><strike>Example Text</strike></p>')
expect(editor.getHTML()).to.eq('<p><s>Example Text</s></p>')
})
})
it('should transform any tag with text decoration line through to s tags', () => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p><span style="text-decoration: line-through">Example Text</span></p>')
expect(editor.getHTML()).to.eq('<p><s>Example Text</s></p>')
})
})
it('the button should strike the selected text', () => {
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror')
.find('s')
.should('contain', 'Example Text')
})
it('the button should toggle the selected text striked', () => {
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror')
.type('{selectall}')
cy.get('.demo__preview button:first')
.click()
cy.get('.ProseMirror')
.find('s')
.should('not.exist')
})
it('the keyboard shortcut should strike the selected text', () => {
cy.get('.ProseMirror')
.trigger('keydown', { modKey: true, key: 'd' })
.find('s')
.should('contain', 'Example Text')
})
it('the keyboard shortcut should toggle the selected text striked', () => {
cy.get('.ProseMirror')
.trigger('keydown', { modKey: true, key: 'd' })
.trigger('keydown', { modKey: true, key: 'd' })
.find('s')
.should('not.exist')
})
it('should make a striked text from the markdown shortcut', () => {
cy.get('.ProseMirror')
.type('~~Strike~~')
.find('s')
.should('contain', 'Strike')
})
})

View File

@@ -0,0 +1,52 @@
<template>
<div v-if="editor">
<button @click="editor.chain().focus().strike().run()" :class="{ 'is-active': editor.isActive('strike') }">
strike
</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 Strike from '@tiptap/extension-strike'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
Strike(),
],
content: `
<p>This isnt striked through.</s></p>
<p><s>But thats striked through.</s></p>
<p><del>And this.</del></p>
<p><strike>This too.</strike></p>
<p style="text-decoration: line-through">This as well.</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>