make the bold extension example interactive

This commit is contained in:
Hans Pagel
2020-08-20 18:11:35 +02:00
parent 86ca94a61a
commit 161d110c3a
2 changed files with 55 additions and 44 deletions

View File

@@ -18,48 +18,5 @@ The extension will generate the corresponding `<strong>` HTML tags when reading
* macOS: `Command` + `B`
## Usage
```markup
<template>
<div>
<editor-menu-bar :editor="editor" v-slot="{ commands, isActive }">
<button type="button" :class="{ 'is-active': isActive.bold() }" @click="commands.bold">
Bold
</button>
</editor-menu-bar>
<editor-content :editor="editor" />
</div>
</template>
<script>
import { Editor, EditorContent, EditorMenuBar } from 'tiptap'
import { Bold } from 'tiptap-extensions'
export default {
components: {
EditorMenuBar,
EditorContent,
},
data() {
return {
editor: new Editor({
extensions: [
new Bold(),
],
content: `
<p><strong>This is strong</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! Right!?</p>
<p style="font-weight: 999">Up to 999!!!</p>
`,
}),
}
},
beforeDestroy() {
this.editor.destroy()
}
}
</script>
```
<Demo name="Extensions/Bold" />