add (broken) focus example
This commit is contained in:
13
docs/src/demos/Focus/index.spec.js
Normal file
13
docs/src/demos/Focus/index.spec.js
Normal file
@@ -0,0 +1,13 @@
|
||||
context('read-only', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('/examples/focus')
|
||||
})
|
||||
|
||||
describe('editable', () => {
|
||||
it('should have class', () => {
|
||||
cy.get('.ProseMirror').window().then(window => {
|
||||
cy.get('.ProseMirror p:first').should('have.class', 'has-focus')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
82
docs/src/demos/Focus/index.vue
Normal file
82
docs/src/demos/Focus/index.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="editor">
|
||||
<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 History from '@tiptap/extension-history'
|
||||
import Bold from '@tiptap/extension-bold'
|
||||
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'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
EditorContent,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: [
|
||||
new Document(),
|
||||
new History(),
|
||||
new Paragraph(),
|
||||
new Text(),
|
||||
new Bold(),
|
||||
new Italic(),
|
||||
new Code(),
|
||||
new CodeBlock(),
|
||||
new Heading(),
|
||||
// new Focus({
|
||||
// className: 'has-focus',
|
||||
// nested: true,
|
||||
// }),
|
||||
],
|
||||
// autoFocus: true,
|
||||
content: `
|
||||
<p>
|
||||
With the focus extension you can add custom classes to focused nodes. Default options:
|
||||
</p>
|
||||
<pre><code>{\n className: 'has-focus',\n nested: true,\n}</code></pre>
|
||||
<ul>
|
||||
<li>
|
||||
When set <code>nested</code> to <code>true</code> also nested elements like this list item will be captured.
|
||||
</li>
|
||||
<li>
|
||||
Otherwise only the wrapping list will get this class.
|
||||
</li>
|
||||
</ul>
|
||||
`,
|
||||
})
|
||||
|
||||
window.editor = this.editor
|
||||
},
|
||||
|
||||
watch: {
|
||||
editable() {
|
||||
this.editor.setOptions({
|
||||
editable: this.editable,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" src="./style.scss">
|
||||
4
docs/src/demos/Focus/style.scss
Normal file
4
docs/src/demos/Focus/style.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
.has-focus {
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 0 0 3px #3ea4ffe6;
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
# Focus
|
||||
# Focus
|
||||
|
||||
<demo name="Focus" highlight="18,43-46,48" />
|
||||
Reference in New Issue
Block a user