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,9 @@
context('/examples/focus', () => {
before(() => {
cy.visit('/examples/focus')
})
it('should have class', () => {
cy.get('.ProseMirror p:first').should('have.class', 'has-focus')
})
})

View File

@@ -0,0 +1,59 @@
<template>
<div>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent } from '@tiptap/vue-starter-kit'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import Focus from '@tiptap/extension-focus'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
Document(),
Paragraph(),
Text(),
Focus({
className: 'has-focus',
nested: true,
}),
],
autoFocus: true,
content: `
<p>
The focus extension adds a class to the focused node only. That enables you to add a custom styling to just that node. By default, itll add <code>.has-focus</code>, even to nested nodes.
</p>
<p>
Nested elements will be focused with the default setting nested: true. Otherwise the whole item will get the focus class, even when just a single nested item is selected.
</p>
`,
})
},
beforeDestroy() {
this.editor.destroy()
},
}
</script>
<style lang="scss">
.has-focus {
border-radius: 3px;
box-shadow: 0 0 0 3px #68CEF8;
}
</style>

View File

@@ -0,0 +1,27 @@
context('/api/nodes/image', () => {
before(() => {
cy.visit('/api/nodes/image')
})
beforeEach(() => {
cy.get('.ProseMirror').then(([{ editor }]) => {
editor.setContent('<p>Example Text</p>')
editor.selectAll()
})
})
it('should add an img tag with the correct URL', () => {
cy.window().then(win => {
cy.stub(win, 'prompt').returns('foobar.png')
cy.get('.demo__preview button:first')
.click()
cy.window().its('prompt').should('be.called')
cy.get('.ProseMirror')
.find('img')
.should('have.attr', 'src', 'foobar.png')
})
})
})