add title to menu items

This commit is contained in:
Hans Pagel
2020-12-01 12:53:24 +01:00
parent 4f8413863f
commit 2a3d08d6f1
2 changed files with 27 additions and 0 deletions

View File

@@ -24,101 +24,122 @@ export default {
items: [ items: [
{ {
icon: 'bold', icon: 'bold',
title: 'Bold',
action: () => this.editor.chain().focus().toggleBold().run(), action: () => this.editor.chain().focus().toggleBold().run(),
isActive: () => this.editor.isActive('bold'), isActive: () => this.editor.isActive('bold'),
}, },
{ {
icon: 'italic', icon: 'italic',
title: 'Italic',
action: () => this.editor.chain().focus().toggleItalic().run(), action: () => this.editor.chain().focus().toggleItalic().run(),
isActive: () => this.editor.isActive('italic'), isActive: () => this.editor.isActive('italic'),
}, },
{ {
icon: 'strikethrough', icon: 'strikethrough',
title: 'Strike',
action: () => this.editor.chain().focus().toggleStrike().run(), action: () => this.editor.chain().focus().toggleStrike().run(),
isActive: () => this.editor.isActive('strike'), isActive: () => this.editor.isActive('strike'),
}, },
{ {
icon: 'code-view', icon: 'code-view',
title: 'Code',
action: () => this.editor.chain().focus().toggleCode().run(), action: () => this.editor.chain().focus().toggleCode().run(),
isActive: () => this.editor.isActive('code'), isActive: () => this.editor.isActive('code'),
}, },
{ {
icon: 'format-clear', icon: 'format-clear',
title: 'Clear Inline Format',
action: () => this.editor.chain().focus().unsetAllMarks().run(), action: () => this.editor.chain().focus().unsetAllMarks().run(),
}, },
{ {
icon: 'eraser-line', icon: 'eraser-line',
title: 'Reset Format',
action: () => this.editor.chain().focus().clearNodes().run(), action: () => this.editor.chain().focus().clearNodes().run(),
}, },
{ {
icon: 'paragraph', icon: 'paragraph',
title: 'Paragraph',
action: () => this.editor.chain().focus().setParagraph().run(), action: () => this.editor.chain().focus().setParagraph().run(),
isActive: () => this.editor.isActive('paragraph'), isActive: () => this.editor.isActive('paragraph'),
}, },
{ {
icon: 'h-1', icon: 'h-1',
title: 'Heading 1',
action: () => this.editor.chain().focus().toggleHeading({ level: 1 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 1 }).run(),
isActive: () => this.editor.isActive('heading', { level: 1 }), isActive: () => this.editor.isActive('heading', { level: 1 }),
}, },
{ {
icon: 'h-2', icon: 'h-2',
title: 'Heading 2',
action: () => this.editor.chain().focus().toggleHeading({ level: 2 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 2 }).run(),
isActive: () => this.editor.isActive('heading', { level: 2 }), isActive: () => this.editor.isActive('heading', { level: 2 }),
}, },
{ {
icon: 'h-3', icon: 'h-3',
title: 'Heading 3',
action: () => this.editor.chain().focus().toggleHeading({ level: 3 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 3 }).run(),
isActive: () => this.editor.isActive('heading', { level: 3 }), isActive: () => this.editor.isActive('heading', { level: 3 }),
}, },
{ {
icon: 'h-4', icon: 'h-4',
title: 'Heading 4',
action: () => this.editor.chain().focus().toggleHeading({ level: 4 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 4 }).run(),
isActive: () => this.editor.isActive('heading', { level: 4 }), isActive: () => this.editor.isActive('heading', { level: 4 }),
}, },
{ {
icon: 'h-5', icon: 'h-5',
title: 'Heading 5',
action: () => this.editor.chain().focus().toggleHeading({ level: 5 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 5 }).run(),
isActive: () => this.editor.isActive('heading', { level: 5 }), isActive: () => this.editor.isActive('heading', { level: 5 }),
}, },
{ {
icon: 'h-6', icon: 'h-6',
title: 'Heading 6',
action: () => this.editor.chain().focus().toggleHeading({ level: 6 }).run(), action: () => this.editor.chain().focus().toggleHeading({ level: 6 }).run(),
isActive: () => this.editor.isActive('heading', { level: 6 }), isActive: () => this.editor.isActive('heading', { level: 6 }),
}, },
{ {
icon: 'list-unordered', icon: 'list-unordered',
title: 'Bullet List',
action: () => this.editor.chain().focus().toggleBulletList().run(), action: () => this.editor.chain().focus().toggleBulletList().run(),
isActive: () => this.editor.isActive('bulletList'), isActive: () => this.editor.isActive('bulletList'),
}, },
{ {
icon: 'list-ordered', icon: 'list-ordered',
title: 'Ordered List',
action: () => this.editor.chain().focus().toggleOrderedList().run(), action: () => this.editor.chain().focus().toggleOrderedList().run(),
isActive: () => this.editor.isActive('orderedList'), isActive: () => this.editor.isActive('orderedList'),
}, },
{ {
icon: 'code-box-line', icon: 'code-box-line',
title: 'Code Block',
action: () => this.editor.chain().focus().toggleCodeBlock().run(), action: () => this.editor.chain().focus().toggleCodeBlock().run(),
isActive: () => this.editor.isActive('codeBlock'), isActive: () => this.editor.isActive('codeBlock'),
}, },
{ {
icon: 'double-quotes-l', icon: 'double-quotes-l',
title: 'Blockquote',
action: () => this.editor.chain().focus().toggleBlockquote().run(), action: () => this.editor.chain().focus().toggleBlockquote().run(),
isActive: () => this.editor.isActive('blockquote'), isActive: () => this.editor.isActive('blockquote'),
}, },
{ {
icon: 'separator', icon: 'separator',
title: 'Horizontal Rule',
action: () => this.editor.chain().focus().setHorizontalRule().run(), action: () => this.editor.chain().focus().setHorizontalRule().run(),
}, },
{ {
icon: 'text-wrap', icon: 'text-wrap',
title: 'Hard Break',
action: () => this.editor.chain().focus().setHardBreak().run(), action: () => this.editor.chain().focus().setHardBreak().run(),
}, },
{ {
icon: 'arrow-go-back-line', icon: 'arrow-go-back-line',
title: 'Undo',
action: () => this.editor.chain().focus().undo().run(), action: () => this.editor.chain().focus().undo().run(),
}, },
{ {
icon: 'arrow-go-forward-line', icon: 'arrow-go-forward-line',
title: 'Redo',
action: () => this.editor.chain().focus().redo().run(), action: () => this.editor.chain().focus().redo().run(),
}, },
], ],

View File

@@ -3,6 +3,7 @@
class="menu-item" class="menu-item"
:class="{ 'is-active': isActive ? isActive(): null }" :class="{ 'is-active': isActive ? isActive(): null }"
@click="action" @click="action"
:title="title"
> >
<svg class="remix"> <svg class="remix">
<use :xlink:href="require('../../../../../node_modules/remixicon/fonts/remixicon.symbol.svg') + `#ri-${icon}`" /> <use :xlink:href="require('../../../../../node_modules/remixicon/fonts/remixicon.symbol.svg') + `#ri-${icon}`" />
@@ -18,6 +19,11 @@ export default {
required: true, required: true,
}, },
title: {
type: String,
required: true,
},
action: { action: {
type: Function, type: Function,
required: true, required: true,