mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-29 08:19:34 +08:00
make the bold extension example interactive
This commit is contained in:
parent
86ca94a61a
commit
161d110c3a
54
docs/src/demos/Extensions/Bold/index.vue
Normal file
54
docs/src/demos/Extensions/Bold/index.vue
Normal file
@ -0,0 +1,54 @@
|
||||
<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 isn’t 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, isn’t it!?</p>
|
||||
<p style="font-weight: 999">Up to font weight 999!!!</p>
|
||||
`,
|
||||
})
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
}
|
||||
}
|
||||
</script>
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user