Merge branch 'main' of github.com:ueberdosis/tiptap-next into main
This commit is contained in:
55
docs/src/demos/Examples/VModel/Editor.vue
Normal file
55
docs/src/demos/Examples/VModel/Editor.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<editor-content :editor="editor" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { Editor } from '@tiptap/core'
|
||||
import { EditorContent } from '@tiptap/vue'
|
||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
EditorContent,
|
||||
},
|
||||
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(value) {
|
||||
const isSame = this.editor.getHTML() === value
|
||||
|
||||
if (isSame) {
|
||||
return
|
||||
}
|
||||
|
||||
this.editor.commands.setContent(this.value, false)
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.editor = new Editor({
|
||||
extensions: defaultExtensions(),
|
||||
content: this.value,
|
||||
})
|
||||
|
||||
this.editor.on('update', () => {
|
||||
this.$emit('input', this.editor.getHTML())
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -1,26 +1,50 @@
|
||||
<template>
|
||||
<div>
|
||||
<full-editor v-model="content" :extensions="extensions" />
|
||||
<div>
|
||||
{{ content }}
|
||||
<editor v-model="content" />
|
||||
|
||||
<div class="content">
|
||||
<h3>Content</h3>
|
||||
<pre><code>{{ content }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { FullEditor } from '@tiptap/vue'
|
||||
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||
import Editor from './Editor'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FullEditor,
|
||||
Editor,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
extensions: defaultExtensions(),
|
||||
content: '<p>A Vue.js wrapper component for tiptap to use <code>v-model</code>.</p>',
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
padding: 1rem 0 0;
|
||||
|
||||
h3 {
|
||||
margin: 1rem 0 0.5rem;
|
||||
}
|
||||
|
||||
pre {
|
||||
border-radius: 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
code {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
font-size: 0.8rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background-color:#e9ecef;
|
||||
color: #495057;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user