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

51 lines
987 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">
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({
emptyNodeClass: 'is-empty',
2018-12-20 04:54:37 +08:00
emptyNodeText: 'Write something …',
showOnlyWhenEditable: 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">
.editor p.is-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>