mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
69 lines
1.3 KiB
Vue
69 lines
1.3 KiB
Vue
<template>
|
|
<div class="editor">
|
|
<div class="checkbox">
|
|
<input type="checkbox" id="editable" v-model="editable" />
|
|
<label for="editable">editable</label>
|
|
</div>
|
|
|
|
<editor-content class="editor__content" :editor="editor" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { Editor, EditorContent } from 'tiptap'
|
|
import {
|
|
HardBreak,
|
|
Heading,
|
|
Bold,
|
|
Code,
|
|
Italic,
|
|
Link,
|
|
} from 'tiptap-extensions'
|
|
|
|
export default {
|
|
components: {
|
|
EditorContent,
|
|
},
|
|
data() {
|
|
return {
|
|
editor: new Editor({
|
|
editable: false,
|
|
extensions: [
|
|
new HardBreak(),
|
|
new Heading({ levels: [1, 2, 3] }),
|
|
new Bold(),
|
|
new Code(),
|
|
new Italic(),
|
|
new Link(),
|
|
],
|
|
content: `
|
|
<h2>
|
|
Read-Only
|
|
</h2>
|
|
<p>
|
|
This text is <strong>read-only</strong>. You are not able to edit something. <a href="https://scrumpy.io/">Links to fancy websites</a> are still working.
|
|
</p>
|
|
`,
|
|
}),
|
|
editable: false,
|
|
}
|
|
},
|
|
watch: {
|
|
editable() {
|
|
this.editor.setOptions({
|
|
editable: this.editable,
|
|
})
|
|
},
|
|
},
|
|
beforeDestroy() {
|
|
this.editor.destroy()
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.checkbox {
|
|
margin-bottom: 1rem;
|
|
}
|
|
</style>
|