1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <template>
- <div class="editor editor-squished">
- <basic-menu :editor="editor" />
- <bubble-menu :editor="editor" />
- <editor-content
- class="editor__content"
- :editor="editor"
- />
- </div>
- </template>
- <script>
- import { Editor, EditorContent } from "tiptap"
- import BubbleMenu from '~/components/editor/BubbleMenu'
- import BasicMenu from '~/components/editor/BasicMenu'
- import {
- Heading,
- Bold,
- Code,
- Italic,
- Strike,
- Underline,
- History,
- Blockquote,
- HorizontalRule,
- OrderedList,
- BulletList,
- ListItem,
- CodeBlockHighlight
- } from 'tiptap-extensions'
- import javascript from 'highlight.js/lib/languages/javascript'
- import css from 'highlight.js/lib/languages/css'
- export default {
- components: {
- EditorContent,
- BubbleMenu,
- BasicMenu
- },
- data(){
- return {
- editor: null
- }
- },
- // This is called only on client (in browser)
- mounted(){
- this.editor = new Editor({
- extensions: [
- new Heading({ levels: [1, 2, 3]}),
- new Bold(),
- new Code(),
- new Italic(),
- new Strike(),
- new Underline(),
- new History(),
- new Blockquote(),
- new HorizontalRule(),
- new OrderedList(),
- new BulletList(),
- new ListItem(),
- new CodeBlockHighlight({
- languages: {
- javascript,
- css,
- }
- })
- ]
- })
- },
- beforeDestroy(){
- // Always destroy your editor instance when it's no longer needed
- this.editor && this.editor.destroy()
- }
- }
- </script>
|