2018-08-22 22:34:04 +08:00
|
|
|
<template>
|
2018-10-24 04:50:12 +08:00
|
|
|
<div class="editor">
|
|
|
|
<editor-content class="editor__content" :editor="editor" />
|
2018-08-22 22:34:04 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Icon from 'Components/Icon'
|
2018-10-24 04:50:12 +08:00
|
|
|
import { Editor, EditorContent } from 'tiptap'
|
2018-08-24 04:08:19 +08:00
|
|
|
import {
|
2018-10-24 13:46:47 +08:00
|
|
|
Blockquote,
|
|
|
|
BulletList,
|
|
|
|
CodeBlock,
|
|
|
|
HardBreak,
|
|
|
|
Heading,
|
|
|
|
ListItem,
|
|
|
|
OrderedList,
|
|
|
|
TodoItem,
|
|
|
|
TodoList,
|
|
|
|
Bold,
|
|
|
|
Code,
|
|
|
|
Italic,
|
|
|
|
Link,
|
|
|
|
History,
|
2018-08-24 04:08:19 +08:00
|
|
|
} from 'tiptap-extensions'
|
2018-08-22 22:34:04 +08:00
|
|
|
|
|
|
|
export default {
|
2018-08-22 22:46:30 +08:00
|
|
|
components: {
|
2018-10-24 04:50:12 +08:00
|
|
|
EditorContent,
|
2018-08-22 22:46:30 +08:00
|
|
|
Icon,
|
|
|
|
},
|
2018-08-24 04:08:19 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2018-10-24 04:50:12 +08:00
|
|
|
editor: new Editor({
|
|
|
|
extensions: [
|
2018-10-24 13:46:47 +08:00
|
|
|
new Blockquote(),
|
|
|
|
new BulletList(),
|
|
|
|
new CodeBlock(),
|
|
|
|
new HardBreak(),
|
2018-10-24 13:58:08 +08:00
|
|
|
new Heading({ levels: [1, 2, 3] }),
|
2018-10-24 13:46:47 +08:00
|
|
|
new ListItem(),
|
|
|
|
new OrderedList(),
|
|
|
|
new TodoItem(),
|
|
|
|
new TodoList(),
|
|
|
|
new Bold(),
|
|
|
|
new Code(),
|
|
|
|
new Italic(),
|
|
|
|
new Link(),
|
|
|
|
new History(),
|
2018-10-24 04:50:12 +08:00
|
|
|
],
|
|
|
|
content: `
|
|
|
|
<h2>
|
2018-10-24 13:46:47 +08:00
|
|
|
down Shortcuts
|
2018-10-24 04:50:12 +08:00
|
|
|
</h2>
|
|
|
|
<p>
|
|
|
|
Start a new line and type <code>#</code> followed by a <code>space</code> and you will get an H1 headline.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
This feature is called <strong>input rules</strong>. There are some of these shortcuts for the most basic nodes enabled by default. Try <code>#, ##, ###, …</code> for headlines, <code>></code> for blockquotes, <code>- or +</code> for bullet lists. And of course you can add your own input rules.
|
|
|
|
</p>
|
|
|
|
`,
|
|
|
|
}),
|
2018-08-24 04:08:19 +08:00
|
|
|
}
|
|
|
|
},
|
2018-10-24 04:50:12 +08:00
|
|
|
beforeDestroy() {
|
|
|
|
this.editor.destroy()
|
|
|
|
},
|
2018-08-22 22:34:04 +08:00
|
|
|
}
|
|
|
|
</script>
|