|
1 | 1 | import { getEventKey } from '../../utils/event' |
2 | 2 | import { getToolbar, getFonts } from './editor-utils' |
3 | | -import { buttons } from './editor-definitions' |
4 | 3 | import { Caret } from './editor-caret' |
5 | 4 | import extend from '../../utils/extend' |
6 | 5 | import FullscreenMixin from '../../mixins/fullscreen' |
@@ -64,10 +63,57 @@ export default { |
64 | 63 | compact: true |
65 | 64 | } |
66 | 65 | }, |
| 66 | + buttonDef () { |
| 67 | + const e = this.$q.i18n.editor |
| 68 | + |
| 69 | + return { |
| 70 | + bold: {cmd: 'bold', icon: 'format_bold', tip: e.bold, key: 66}, |
| 71 | + italic: {cmd: 'italic', icon: 'format_italic', tip: e.italic, key: 73}, |
| 72 | + strike: {cmd: 'strikeThrough', icon: 'strikethrough_s', tip: e.strikethrough, key: 83}, |
| 73 | + underline: {cmd: 'underline', icon: 'format_underlined', tip: e.underline, key: 85}, |
| 74 | + unordered: {cmd: 'insertUnorderedList', icon: 'format_list_bulleted', tip: e.unorderedList}, |
| 75 | + ordered: {cmd: 'insertOrderedList', icon: 'format_list_numbered', tip: e.orderedList}, |
| 76 | + subscript: {cmd: 'subscript', icon: 'vertical_align_bottom', tip: e.subscript, htmlTip: 'x<subscript>2</subscript>'}, |
| 77 | + superscript: {cmd: 'superscript', icon: 'vertical_align_top', tip: e.superscript, htmlTip: 'x<superscript>2</superscript>'}, |
| 78 | + link: {cmd: 'link', icon: 'link', tip: e.hyperlink, key: 76}, |
| 79 | + fullscreen: {cmd: 'fullscreen', icon: 'fullscreen', tip: e.toggleFullscreen, key: 70}, |
| 80 | + |
| 81 | + quote: {cmd: 'formatBlock', param: 'BLOCKQUOTE', icon: 'format_quote', tip: e.quote, key: 81}, |
| 82 | + left: {cmd: 'justifyLeft', icon: 'format_align_left', tip: e.left}, |
| 83 | + center: {cmd: 'justifyCenter', icon: 'format_align_center', tip: e.center}, |
| 84 | + right: {cmd: 'justifyRight', icon: 'format_align_right', tip: e.right}, |
| 85 | + justify: {cmd: 'justifyFull', icon: 'format_align_justify', tip: e.justify}, |
| 86 | + |
| 87 | + print: {type: 'no-state', cmd: 'print', icon: 'print', tip: e.print, key: 80}, |
| 88 | + outdent: {type: 'no-state', disable: vm => vm.caret && !vm.caret.can('outdent'), cmd: 'outdent', icon: 'format_indent_decrease', tip: e.outdent}, |
| 89 | + indent: {type: 'no-state', disable: vm => vm.caret && !vm.caret.can('indent'), cmd: 'indent', icon: 'format_indent_increase', tip: e.indent}, |
| 90 | + removeFormat: {type: 'no-state', cmd: 'removeFormat', icon: 'format_clear', tip: e.removeFormat}, |
| 91 | + hr: {type: 'no-state', cmd: 'insertHorizontalRule', icon: 'remove', tip: e.hr}, |
| 92 | + undo: {type: 'no-state', cmd: 'undo', icon: 'undo', tip: e.undo, key: 90}, |
| 93 | + redo: {type: 'no-state', cmd: 'redo', icon: 'redo', tip: e.redo, key: 89}, |
| 94 | + |
| 95 | + h1: {cmd: 'formatBlock', param: 'H1', icon: 'format_size', tip: e.header1, htmlTip: `<h1>${e.header1}</h1>`}, |
| 96 | + h2: {cmd: 'formatBlock', param: 'H2', icon: 'format_size', tip: e.header2, htmlTip: `<h2>${e.header2}</h2>`}, |
| 97 | + h3: {cmd: 'formatBlock', param: 'H3', icon: 'format_size', tip: e.header3, htmlTip: `<h3>${e.header3}</h3>`}, |
| 98 | + h4: {cmd: 'formatBlock', param: 'H4', icon: 'format_size', tip: e.header4, htmlTip: `<h4>${e.header4}</h4>`}, |
| 99 | + h5: {cmd: 'formatBlock', param: 'H5', icon: 'format_size', tip: e.header5, htmlTip: `<h5>${e.header5}</h5>`}, |
| 100 | + h6: {cmd: 'formatBlock', param: 'H6', icon: 'format_size', tip: e.header6, htmlTip: `<h6>${e.header6}</h6>`}, |
| 101 | + p: {cmd: 'formatBlock', param: 'DIV', icon: 'format_size', tip: e.paragraph}, |
| 102 | + code: {cmd: 'formatBlock', param: 'PRE', icon: 'code', tip: `<code>${e.code}</code>`}, |
| 103 | + |
| 104 | + 'size-1': {cmd: 'fontSize', param: '1', icon: 'filter_1', tip: e.size1, htmlTip: `<font size="1">${e.size1}</font>`}, |
| 105 | + 'size-2': {cmd: 'fontSize', param: '2', icon: 'filter_2', tip: e.size2, htmlTip: `<font size="2">${e.size2}</font>`}, |
| 106 | + 'size-3': {cmd: 'fontSize', param: '3', icon: 'filter_3', tip: e.size3, htmlTip: `<font size="3">${e.size3}</font>`}, |
| 107 | + 'size-4': {cmd: 'fontSize', param: '4', icon: 'filter_4', tip: e.size4, htmlTip: `<font size="4">${e.size4}</font>`}, |
| 108 | + 'size-5': {cmd: 'fontSize', param: '5', icon: 'filter_5', tip: e.size5, htmlTip: `<font size="5">${e.size5}</font>`}, |
| 109 | + 'size-6': {cmd: 'fontSize', param: '6', icon: 'filter_6', tip: e.size6, htmlTip: `<font size="6">${e.size6}</font>`}, |
| 110 | + 'size-7': {cmd: 'fontSize', param: '7', icon: 'filter_7', tip: e.size7, htmlTip: `<font size="7">${e.size7}</font>`} |
| 111 | + } |
| 112 | + }, |
67 | 113 | buttons () { |
68 | 114 | let def = this.definitions || this.fonts |
69 | | - ? extend(true, {}, buttons, this.definitions || {}, getFonts(this.defaultFont, this.fonts)) |
70 | | - : buttons |
| 115 | + ? extend(true, {}, this.buttonDef, this.definitions || {}, getFonts(this.defaultFont, this.$q.i18n.editor.defaultFont, this.fonts)) |
| 116 | + : this.buttonDef |
71 | 117 |
|
72 | 118 | return this.toolbar.map( |
73 | 119 | group => group.map(token => { |
|
0 commit comments