2018-09-01 02:42:13 +08:00
|
|
|
<template>
|
2018-10-23 03:46:45 +08:00
|
|
|
<div class="editor">
|
|
|
|
<menu-bar class="menubar" :editor="editor">
|
|
|
|
<template slot-scope="{ nodes }">
|
|
|
|
<button
|
|
|
|
class="menubar__button"
|
|
|
|
@click="showImagePrompt(nodes.image.command)"
|
|
|
|
>
|
|
|
|
<icon name="image" />
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</menu-bar>
|
|
|
|
|
|
|
|
<editor-content class="editor__content" :editor="editor" />
|
2018-09-01 02:42:13 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-30 04:49:38 +08:00
|
|
|
import Icon from 'Components/Icon'
|
2018-10-23 03:46:45 +08:00
|
|
|
import { Editor, EditorContent, MenuBar } from 'tiptap'
|
2018-09-01 02:42:13 +08:00
|
|
|
import {
|
|
|
|
HardBreakNode,
|
|
|
|
HeadingNode,
|
|
|
|
ImageNode,
|
|
|
|
BoldMark,
|
|
|
|
CodeMark,
|
|
|
|
ItalicMark,
|
|
|
|
} from 'tiptap-extensions'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
2018-09-30 04:49:38 +08:00
|
|
|
Icon,
|
2018-10-23 03:46:45 +08:00
|
|
|
EditorContent,
|
|
|
|
MenuBar,
|
2018-09-01 02:42:13 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-10-23 03:46:45 +08:00
|
|
|
editor: new Editor({
|
|
|
|
extensions: [
|
|
|
|
new HardBreakNode(),
|
|
|
|
new HeadingNode({ maxLevel: 3 }),
|
|
|
|
new ImageNode(),
|
|
|
|
new BoldMark(),
|
|
|
|
new CodeMark(),
|
|
|
|
new ItalicMark(),
|
|
|
|
],
|
|
|
|
content: `
|
|
|
|
<h2>
|
|
|
|
Images
|
|
|
|
</h2>
|
|
|
|
<p>
|
|
|
|
This is basic example of implementing images. Try to drop new images here. Reordering also works.
|
|
|
|
</p>
|
|
|
|
<img src="https://ljdchost.com/8I2DeFn.gif" />
|
|
|
|
`,
|
|
|
|
}),
|
2018-09-01 02:42:13 +08:00
|
|
|
}
|
|
|
|
},
|
2018-09-30 04:49:38 +08:00
|
|
|
methods: {
|
|
|
|
showImagePrompt(command) {
|
|
|
|
const src = prompt('Enter the url of your image here')
|
|
|
|
if (src !== null) {
|
|
|
|
command({ src })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2018-09-01 02:42:13 +08:00
|
|
|
}
|
|
|
|
</script>
|