Files
tiptap/docs/src/demos/Extensions/Bold/index.vue
2020-09-02 15:20:23 +02:00

56 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div v-if="editor">
<button @click="editor.focus().bold()" :class="{ 'is-active': editor.isActive('bold') }">
bold
</button>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor } from '@tiptap/core'
import { EditorContent } from '@tiptap/vue'
import Document from '@tiptap/extension-document'
import Paragraph from '@tiptap/extension-paragraph'
import Text from '@tiptap/extension-text'
import Bold from '@tiptap/extension-bold'
export default {
components: {
EditorContent,
},
data() {
return {
editor: null,
}
},
mounted() {
this.editor = new Editor({
extensions: [
new Document(),
new Paragraph(),
new Text(),
new Bold(),
],
content: `
<p>This isnt bold.</p>
<p><strong>This is bold.</strong></p>
<p><b>And this.</b></p>
<p style="font-weight: bold">This as well.</p>
<p style="font-weight: bolder">Oh, and this!</p>
<p style="font-weight: 500">Cool, isnt it!?</p>
<p style="font-weight: 999">Up to font weight 999!!!</p>
`,
})
window.editor = this.editor
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>