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

48 lines
774 B
Vue
Raw Normal View History

2018-09-07 04:58:54 +08:00
<template>
2018-10-24 04:50:12 +08:00
<div class="editor">
<editor-content class="editor__content" :editor="editor" />
2018-09-07 04:58:54 +08:00
</div>
</template>
<script>
2018-10-24 04:50:12 +08:00
import { Editor, EditorContent } from 'tiptap'
2018-09-14 05:57:55 +08:00
import {
BulletListNode,
ListItemNode,
PlaceholderExtension,
} from 'tiptap-extensions'
2018-09-07 04:58:54 +08:00
export default {
components: {
2018-10-24 04:50:12 +08:00
EditorContent,
2018-09-07 04:58:54 +08:00
},
data() {
return {
2018-10-24 04:50:12 +08:00
editor: new Editor({
extensions: [
new BulletListNode(),
new ListItemNode(),
new PlaceholderExtension({
emptyNodeClass: 'is-empty',
}),
],
}),
2018-09-07 04:58:54 +08:00
}
},
2018-10-24 04:50:12 +08:00
beforeDestroy() {
this.editor.destroy()
},
2018-09-07 04:58:54 +08:00
}
</script>
<style lang="scss">
.editor p.is-empty:first-child::before {
content: 'Start typing…';
float: left;
color: #aaa;
pointer-events: none;
height: 0;
font-style: italic;
}
</style>