add focus extension

This commit is contained in:
Philipp Kühn
2020-08-21 17:32:47 +02:00
parent 0513fd6ce2
commit 71c3927b28
6 changed files with 112 additions and 14 deletions

View File

@@ -6,6 +6,9 @@ context('focus', () => {
describe('focus class', () => {
it('should have class', () => {
cy.get('.ProseMirror').window().then(window => {
const { editor } = window
editor.focus('start')
cy.get('.ProseMirror p:first').should('have.class', 'has-focus')
})
})

View File

@@ -15,7 +15,7 @@ import Italic from '@tiptap/extension-italic'
import Code from '@tiptap/extension-code'
import CodeBlock from '@tiptap/extension-codeblock'
import Heading from '@tiptap/extension-heading'
// import Focus from '@tiptap/extension-focus'
import Focus from '@tiptap/extension-focus'
export default {
components: {
@@ -40,12 +40,12 @@ export default {
new Code(),
new CodeBlock(),
new Heading(),
// new Focus({
// className: 'has-focus',
// nested: true,
// }),
new Focus({
className: 'has-focus',
nested: true,
}),
],
// autoFocus: true,
autoFocus: true,
content: `
<p>
With the focus extension you can add custom classes to focused nodes. Default options:
@@ -65,14 +65,6 @@ export default {
window.editor = this.editor
},
watch: {
editable() {
this.editor.setOptions({
editable: this.editable,
})
},
},
beforeDestroy() {
this.editor.destroy()
},