tiptap/examples/Components/Routes/ReadOnly/index.vue

49 lines
891 B
Vue
Raw Normal View History

2018-08-23 01:28:57 +08:00
<template>
2018-10-24 04:50:12 +08:00
<div class="editor">
<editor-content class="editor__content" :editor="editor" />
2018-08-23 01:28:57 +08:00
</div>
</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-08-27 01:43:02 +08:00
HardBreakNode,
HeadingNode,
BoldMark,
CodeMark,
ItalicMark,
LinkMark,
2018-08-24 04:08:19 +08:00
} from 'tiptap-extensions'
2018-08-23 01:28:57 +08:00
export default {
components: {
2018-10-24 04:50:12 +08:00
EditorContent,
2018-08-23 01:28:57 +08:00
},
2018-08-24 04:08:19 +08:00
data() {
return {
2018-10-24 04:50:12 +08:00
editor: new Editor({
editable: false,
extensions: [
new HardBreakNode(),
new HeadingNode({ maxLevel: 3 }),
new BoldMark(),
new CodeMark(),
new ItalicMark(),
new LinkMark(),
],
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-08-24 04:08:19 +08:00
}
},
2018-10-24 04:50:12 +08:00
beforeDestroy() {
this.editor.destroy()
},
2018-08-23 01:28:57 +08:00
}
</script>