2018-09-07 04:58:54 +08:00
|
|
|
<template>
|
2018-11-09 05:03:10 +08:00
|
|
|
<div class="editor">
|
2019-04-25 23:29:52 +08:00
|
|
|
<input type="text" v-model="editor.extensions.options.placeholder.emptyNodeText">
|
2018-11-09 05:03:10 +08:00
|
|
|
<editor-content class="editor__content" :editor="editor" />
|
|
|
|
</div>
|
2018-09-07 04:58:54 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-10-24 04:50:12 +08:00
|
|
|
import { Editor, EditorContent } from 'tiptap'
|
2018-09-14 05:57:55 +08:00
|
|
|
import {
|
2018-11-09 05:03:10 +08:00
|
|
|
BulletList,
|
|
|
|
ListItem,
|
|
|
|
Placeholder,
|
2018-09-14 05:57:55 +08:00
|
|
|
} from 'tiptap-extensions'
|
2018-09-07 04:58:54 +08:00
|
|
|
|
|
|
|
export default {
|
2018-11-09 05:03:10 +08:00
|
|
|
components: {
|
|
|
|
EditorContent,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
editor: new Editor({
|
|
|
|
extensions: [
|
|
|
|
new BulletList(),
|
|
|
|
new ListItem(),
|
|
|
|
new Placeholder({
|
2019-12-03 06:05:03 +08:00
|
|
|
emptyEditorClass: 'is-editor-empty',
|
2019-06-02 00:24:32 +08:00
|
|
|
emptyNodeClass: 'is-empty',
|
2018-12-20 04:54:37 +08:00
|
|
|
emptyNodeText: 'Write something …',
|
2019-02-06 18:28:40 +08:00
|
|
|
showOnlyWhenEditable: true,
|
2019-12-03 06:05:03 +08:00
|
|
|
showOnlyCurrent: true,
|
2018-11-09 05:03:10 +08:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.editor.destroy()
|
|
|
|
},
|
2018-09-07 04:58:54 +08:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2019-12-03 06:05:03 +08:00
|
|
|
.editor p.is-editor-empty:first-child::before {
|
2018-12-15 18:48:18 +08:00
|
|
|
content: attr(data-empty-text);
|
2018-11-09 05:03:10 +08:00
|
|
|
float: left;
|
|
|
|
color: #aaa;
|
|
|
|
pointer-events: none;
|
|
|
|
height: 0;
|
|
|
|
font-style: italic;
|
2018-09-07 04:58:54 +08:00
|
|
|
}
|
|
|
|
</style>
|