2018-08-23 01:28:57 +08:00
|
|
|
<template>
|
2018-11-09 05:03:10 +08:00
|
|
|
<div class="editor">
|
2018-12-20 06:00:13 +08:00
|
|
|
<div class="checkbox">
|
|
|
|
<input type="checkbox" id="editable" v-model="editable" />
|
|
|
|
<label for="editable">editable</label>
|
|
|
|
</div>
|
|
|
|
|
2018-11-09 05:03:10 +08:00
|
|
|
<editor-content class="editor__content" :editor="editor" />
|
|
|
|
</div>
|
2018-08-23 01:28:57 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-10-24 04:50:12 +08:00
|
|
|
import { Editor, EditorContent } from 'tiptap'
|
2018-08-24 04:08:19 +08:00
|
|
|
import {
|
2018-11-09 05:03:10 +08:00
|
|
|
HardBreak,
|
|
|
|
Heading,
|
|
|
|
Bold,
|
|
|
|
Code,
|
|
|
|
Italic,
|
|
|
|
Link,
|
2018-08-24 04:08:19 +08:00
|
|
|
} from 'tiptap-extensions'
|
2018-08-23 01:28:57 +08:00
|
|
|
|
|
|
|
export default {
|
2018-11-09 05:03:10 +08:00
|
|
|
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>
|
|
|
|
`,
|
|
|
|
}),
|
2018-12-20 06:00:13 +08:00
|
|
|
editable: false,
|
2018-11-09 05:03:10 +08:00
|
|
|
}
|
|
|
|
},
|
2018-12-20 06:00:13 +08:00
|
|
|
watch: {
|
|
|
|
editable() {
|
|
|
|
this.editor.setOptions({
|
|
|
|
editable: this.editable,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
2018-11-09 05:03:10 +08:00
|
|
|
beforeDestroy() {
|
|
|
|
this.editor.destroy()
|
|
|
|
},
|
2018-08-23 01:28:57 +08:00
|
|
|
}
|
2018-11-09 05:03:10 +08:00
|
|
|
</script>
|
2018-12-20 06:00:13 +08:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.checkbox {
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|