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

48 lines
803 B
Vue
Raw Normal View History

2018-09-07 04:58:54 +08:00
<template>
2018-11-09 05:03:10 +08:00
<div class="editor">
<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({
emptyClass: 'is-empty',
}),
],
}),
}
},
beforeDestroy() {
this.editor.destroy()
},
2018-09-07 04:58:54 +08:00
}
</script>
<style lang="scss">
.editor p.is-empty:first-child::before {
2018-11-09 05:03:10 +08:00
content: 'Start typing…';
float: left;
color: #aaa;
pointer-events: none;
height: 0;
font-style: italic;
2018-09-07 04:58:54 +08:00
}
</style>