Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/ui/editor/defaulttoolbar.js
4509 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Factory functions for creating a default editing toolbar.
9
*
10
* @see ../../demos/editor/editor.html
11
*/
12
13
goog.provide('goog.ui.editor.ButtonDescriptor');
14
goog.provide('goog.ui.editor.DefaultToolbar');
15
16
goog.require('goog.asserts');
17
goog.require('goog.dom');
18
goog.require('goog.dom.TagName');
19
goog.require('goog.dom.classlist');
20
goog.require('goog.editor.Command');
21
goog.require('goog.style');
22
goog.require('goog.ui.editor.ToolbarFactory');
23
goog.require('goog.ui.editor.messages');
24
goog.require('goog.userAgent');
25
goog.requireType('goog.ui.Button');
26
goog.requireType('goog.ui.ButtonRenderer');
27
goog.requireType('goog.ui.ColorMenuButtonRenderer');
28
goog.requireType('goog.ui.Control');
29
goog.requireType('goog.ui.ControlContent');
30
goog.requireType('goog.ui.MenuButtonRenderer');
31
goog.requireType('goog.ui.MenuItem');
32
goog.requireType('goog.ui.Select');
33
goog.requireType('goog.ui.Toolbar');
34
goog.requireType('goog.ui.ToolbarColorMenuButton');
35
36
// Font menu creation.
37
38
39
/** @desc Font menu item caption for the default sans-serif font. */
40
goog.ui.editor.DefaultToolbar.MSG_FONT_NORMAL = goog.getMsg('Normal');
41
42
43
/** @desc Font menu item caption for the default serif font. */
44
goog.ui.editor.DefaultToolbar.MSG_FONT_NORMAL_SERIF =
45
goog.getMsg('Normal / serif');
46
47
48
/**
49
* Common font descriptors for all locales. Each descriptor has the following
50
* attributes:
51
* <ul>
52
* <li>`caption` - Caption to show in the font menu (e.g. 'Tahoma')
53
* <li>`value` - Value for the corresponding 'font-family' CSS style
54
* (e.g. 'Tahoma, Arial, sans-serif')
55
* </ul>
56
* @type {!Array<{caption:string, value:string}>}
57
* @private
58
*/
59
goog.ui.editor.DefaultToolbar.FONTS_ = [
60
{
61
caption: goog.ui.editor.DefaultToolbar.MSG_FONT_NORMAL,
62
value: 'arial,sans-serif'
63
},
64
{
65
caption: goog.ui.editor.DefaultToolbar.MSG_FONT_NORMAL_SERIF,
66
value: 'times new roman,serif'
67
},
68
{caption: 'Courier New', value: 'courier new,monospace'},
69
{caption: 'Georgia', value: 'georgia,serif'},
70
{caption: 'Trebuchet', value: 'trebuchet ms,sans-serif'},
71
{caption: 'Verdana', value: 'verdana,sans-serif'}
72
];
73
74
75
/**
76
* Locale-specific font descriptors. The object is a map of locale strings to
77
* arrays of font descriptors.
78
* @type {!Object<!Array<{caption:string, value:string}>>}
79
* @private
80
*/
81
goog.ui.editor.DefaultToolbar.I18N_FONTS_ = {
82
'ja': [
83
{
84
caption: '\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af',
85
value: 'ms pgothic,sans-serif'
86
},
87
{caption: '\uff2d\uff33 \uff30\u660e\u671d', value: 'ms pmincho,serif'}, {
88
caption: '\uff2d\uff33 \u30b4\u30b7\u30c3\u30af',
89
value: 'ms gothic,monospace'
90
}
91
],
92
'ko': [
93
{caption: '\uad74\ub9bc', value: 'gulim,sans-serif'},
94
{caption: '\ubc14\ud0d5', value: 'batang,serif'},
95
{caption: '\uad74\ub9bc\uccb4', value: 'gulimche,monospace'}
96
],
97
'zh-tw': [
98
{caption: '\u65b0\u7d30\u660e\u9ad4', value: 'pmingliu,serif'},
99
{caption: '\u7d30\u660e\u9ad4', value: 'mingliu,serif'}
100
],
101
'zh-cn': [
102
{caption: '\u5b8b\u4f53', value: 'simsun,serif'},
103
{caption: '\u9ed1\u4f53', value: 'simhei,sans-serif'},
104
{caption: 'MS Song', value: 'ms song,monospace'}
105
]
106
};
107
108
109
/**
110
* Default locale for font names.
111
* @type {string}
112
* @private
113
*/
114
goog.ui.editor.DefaultToolbar.locale_ = 'en-us';
115
116
117
/**
118
* Sets the locale for the font names. If not set, defaults to 'en-us'.
119
* Used only for default creation of font names name. Must be set
120
* before font name menu is created.
121
* @param {string} locale Locale to use for the toolbar font names.
122
*/
123
goog.ui.editor.DefaultToolbar.setLocale = function(locale) {
124
'use strict';
125
goog.ui.editor.DefaultToolbar.locale_ = locale;
126
};
127
128
129
/**
130
* Initializes the given font menu button by adding default fonts to the menu.
131
* If goog.ui.editor.DefaultToolbar.setLocale was called to specify a locale
132
* for which locale-specific default fonts exist, those are added before
133
* common fonts.
134
* @param {!goog.ui.Select} button Font menu button.
135
*/
136
goog.ui.editor.DefaultToolbar.addDefaultFonts = function(button) {
137
'use strict';
138
// Normalize locale to lowercase, with a hyphen (see bug 1036165).
139
const locale =
140
goog.ui.editor.DefaultToolbar.locale_.replace(/_/, '-').toLowerCase();
141
// Add locale-specific default fonts, if any.
142
let fontlist = [];
143
144
if (locale in goog.ui.editor.DefaultToolbar.I18N_FONTS_) {
145
fontlist = goog.ui.editor.DefaultToolbar.I18N_FONTS_[locale];
146
}
147
if (fontlist.length) {
148
goog.ui.editor.ToolbarFactory.addFonts(button, fontlist);
149
}
150
// Add locale-independent default fonts.
151
goog.ui.editor.ToolbarFactory.addFonts(
152
button, goog.ui.editor.DefaultToolbar.FONTS_);
153
};
154
155
156
// Font size menu creation.
157
158
159
/** @desc Font size menu item caption for the 'Small' size. */
160
goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_SMALL = goog.getMsg('Small');
161
162
163
/** @desc Font size menu item caption for the 'Normal' size. */
164
goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_NORMAL = goog.getMsg('Normal');
165
166
167
/** @desc Font size menu item caption for the 'Large' size. */
168
goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_LARGE = goog.getMsg('Large');
169
170
171
/** @desc Font size menu item caption for the 'Huge' size. */
172
goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_HUGE = goog.getMsg('Huge');
173
174
175
/**
176
* Font size descriptors, each with the following attributes:
177
* <ul>
178
* <li>`caption` - Caption to show in the font size menu (e.g. 'Huge')
179
* <li>`value` - Value for the corresponding HTML font size (e.g. 6)
180
* </ul>
181
* @type {!Array<{caption:string, value:number}>}
182
* @private
183
*/
184
goog.ui.editor.DefaultToolbar.FONT_SIZES_ = [
185
{caption: goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_SMALL, value: 1},
186
{caption: goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_NORMAL, value: 2},
187
{caption: goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_LARGE, value: 4},
188
{caption: goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_HUGE, value: 6}
189
];
190
191
192
/**
193
* Initializes the given font size menu button by adding default font sizes to
194
* it.
195
* @param {!goog.ui.Select} button Font size menu button.
196
*/
197
goog.ui.editor.DefaultToolbar.addDefaultFontSizes = function(button) {
198
'use strict';
199
goog.ui.editor.ToolbarFactory.addFontSizes(
200
button, goog.ui.editor.DefaultToolbar.FONT_SIZES_);
201
};
202
203
204
// Header format menu creation.
205
206
207
/** @desc Caption for "Heading" block format option. */
208
goog.ui.editor.DefaultToolbar.MSG_FORMAT_HEADING = goog.getMsg('Heading');
209
210
211
/** @desc Caption for "Subheading" block format option. */
212
goog.ui.editor.DefaultToolbar.MSG_FORMAT_SUBHEADING = goog.getMsg('Subheading');
213
214
215
/** @desc Caption for "Minor heading" block format option. */
216
goog.ui.editor.DefaultToolbar.MSG_FORMAT_MINOR_HEADING =
217
goog.getMsg('Minor heading');
218
219
220
/** @desc Caption for "Normal" block format option. */
221
goog.ui.editor.DefaultToolbar.MSG_FORMAT_NORMAL = goog.getMsg('Normal');
222
223
224
/**
225
* Format option descriptors, each with the following attributes:
226
* <ul>
227
* <li>`caption` - Caption to show in the menu (e.g. 'Minor heading')
228
* <li>`command` - Corresponding {@link goog.dom.TagName} (e.g.
229
* 'H4')
230
* </ul>
231
* @type {!Array<{caption: string, command: !goog.dom.TagName}>}
232
* @private
233
*/
234
goog.ui.editor.DefaultToolbar.FORMAT_OPTIONS_ = [
235
{
236
caption: goog.ui.editor.DefaultToolbar.MSG_FORMAT_HEADING,
237
command: goog.dom.TagName.H2
238
},
239
{
240
caption: goog.ui.editor.DefaultToolbar.MSG_FORMAT_SUBHEADING,
241
command: goog.dom.TagName.H3
242
},
243
{
244
caption: goog.ui.editor.DefaultToolbar.MSG_FORMAT_MINOR_HEADING,
245
command: goog.dom.TagName.H4
246
},
247
{
248
caption: goog.ui.editor.DefaultToolbar.MSG_FORMAT_NORMAL,
249
command: goog.dom.TagName.P
250
}
251
];
252
253
254
/**
255
* Initializes the given "Format block" menu button by adding default format
256
* options to the menu.
257
* @param {!goog.ui.Select} button "Format block" menu button.
258
*/
259
goog.ui.editor.DefaultToolbar.addDefaultFormatOptions = function(button) {
260
'use strict';
261
goog.ui.editor.ToolbarFactory.addFormatOptions(
262
button, goog.ui.editor.DefaultToolbar.FORMAT_OPTIONS_);
263
};
264
265
266
/**
267
* Creates a {@link goog.ui.Toolbar} containing a default set of editor
268
* toolbar buttons, and renders it into the given parent element.
269
* @param {!Element} elem Toolbar parent element.
270
* @param {boolean=} opt_isRightToLeft Whether the editor chrome is
271
* right-to-left; defaults to the directionality of the toolbar parent
272
* element.
273
* @return {!goog.ui.Toolbar} Default editor toolbar, rendered into the given
274
* parent element.
275
* @see goog.ui.editor.DefaultToolbar.DEFAULT_BUTTONS
276
*/
277
goog.ui.editor.DefaultToolbar.makeDefaultToolbar = function(
278
elem, opt_isRightToLeft) {
279
'use strict';
280
const isRightToLeft = opt_isRightToLeft || goog.style.isRightToLeft(elem);
281
const buttons = isRightToLeft ?
282
goog.ui.editor.DefaultToolbar.DEFAULT_BUTTONS_RTL :
283
goog.ui.editor.DefaultToolbar.DEFAULT_BUTTONS;
284
return goog.ui.editor.DefaultToolbar.makeToolbar(
285
buttons, elem, opt_isRightToLeft);
286
};
287
288
289
/**
290
* Creates a {@link goog.ui.Toolbar} containing the specified set of
291
* toolbar buttons, and renders it into the given parent element. Each
292
* item in the `items` array must either be a
293
* {@link goog.editor.Command} (to create a built-in button) or a subclass
294
* of {@link goog.ui.Control} (to create a custom control).
295
* @param {!Array<string|goog.ui.Control>} items Toolbar items; each must
296
* be a {@link goog.editor.Command} or a {@link goog.ui.Control}.
297
* @param {!Element} elem Toolbar parent element.
298
* @param {boolean=} opt_isRightToLeft Whether the editor chrome is
299
* right-to-left; defaults to the directionality of the toolbar parent
300
* element.
301
* @return {!goog.ui.Toolbar} Editor toolbar, rendered into the given parent
302
* element.
303
*/
304
goog.ui.editor.DefaultToolbar.makeToolbar = function(
305
items, elem, opt_isRightToLeft) {
306
'use strict';
307
const domHelper = goog.dom.getDomHelper(elem);
308
const controls = [];
309
310
for (let i = 0, button; button = items[i]; i++) {
311
if (typeof button === 'string') {
312
button = goog.ui.editor.DefaultToolbar.makeBuiltInToolbarButton(
313
button, domHelper);
314
}
315
if (button) {
316
controls.push(button);
317
}
318
}
319
320
return goog.ui.editor.ToolbarFactory.makeToolbar(
321
controls, elem, opt_isRightToLeft);
322
};
323
324
325
/**
326
* Creates an instance of a subclass of {@link goog.ui.Button} for the given
327
* {@link goog.editor.Command}, or null if no built-in button exists for the
328
* command. Note that this function is only intended to create built-in
329
* buttons; please don't try to hack it!
330
* @param {string} command Editor command ID.
331
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
332
* creation; defaults to the current document if unspecified.
333
* @return {goog.ui.Button} Toolbar button (null if no built-in button exists
334
* for the command).
335
*/
336
goog.ui.editor.DefaultToolbar.makeBuiltInToolbarButton = function(
337
command, opt_domHelper) {
338
'use strict';
339
let button = null;
340
const descriptor = goog.ui.editor.DefaultToolbar.buttons_[command];
341
if (descriptor) {
342
// Default the factory method to makeToggleButton, since most built-in
343
// toolbar buttons are toggle buttons. See also
344
// goog.ui.editor.DefaultToolbar.button_list_.
345
/** @type {!Function} */
346
const factory =
347
descriptor.factory || goog.ui.editor.ToolbarFactory.makeToggleButton;
348
const id = descriptor.command;
349
const tooltip = descriptor.tooltip;
350
const caption = descriptor.caption;
351
const classNames = descriptor.classes;
352
// Default the DOM helper to the one for the current document.
353
const domHelper = opt_domHelper || goog.dom.getDomHelper();
354
// Instantiate the button based on the descriptor.
355
button = factory(id, tooltip, caption, classNames, null, domHelper);
356
// If this button's state should be queried when updating the toolbar,
357
// set the button object's queryable property to true.
358
if (descriptor.queryable) {
359
button.queryable = true;
360
}
361
}
362
return button;
363
};
364
365
366
/**
367
* A set of built-in buttons to display in the default editor toolbar.
368
* @type {!Array<string>}
369
*/
370
goog.ui.editor.DefaultToolbar.DEFAULT_BUTTONS = [
371
goog.editor.Command.IMAGE, goog.editor.Command.LINK, goog.editor.Command.BOLD,
372
goog.editor.Command.ITALIC, goog.editor.Command.UNORDERED_LIST,
373
goog.editor.Command.FONT_COLOR, goog.editor.Command.FONT_FACE,
374
goog.editor.Command.FONT_SIZE, goog.editor.Command.JUSTIFY_LEFT,
375
goog.editor.Command.JUSTIFY_CENTER, goog.editor.Command.JUSTIFY_RIGHT,
376
goog.editor.Command.EDIT_HTML
377
];
378
379
380
/**
381
* A set of built-in buttons to display in the default editor toolbar when
382
* the editor chrome is right-to-left (BiDi mode only).
383
* @type {!Array<string>}
384
*/
385
goog.ui.editor.DefaultToolbar.DEFAULT_BUTTONS_RTL = [
386
goog.editor.Command.IMAGE, goog.editor.Command.LINK, goog.editor.Command.BOLD,
387
goog.editor.Command.ITALIC, goog.editor.Command.UNORDERED_LIST,
388
goog.editor.Command.FONT_COLOR, goog.editor.Command.FONT_FACE,
389
goog.editor.Command.FONT_SIZE, goog.editor.Command.JUSTIFY_RIGHT,
390
goog.editor.Command.JUSTIFY_CENTER, goog.editor.Command.JUSTIFY_LEFT,
391
goog.editor.Command.DIR_RTL, goog.editor.Command.DIR_LTR,
392
goog.editor.Command.EDIT_HTML
393
];
394
395
396
/**
397
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
398
* any custom CSS class names to the button's caption element. This button
399
* is designed to be used as the RTL button.
400
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
401
* built-in buttons, anything else for custom buttons.
402
* @param {string} tooltip Tooltip to be shown on hover.
403
* @param {goog.ui.ControlContent} caption Button caption.
404
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
405
* element.
406
* @param {goog.ui.ButtonRenderer=} opt_renderer Button renderer; defaults to
407
* {@link goog.ui.ToolbarButtonRenderer} if unspecified.
408
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
409
* creation; defaults to the current document if unspecified.
410
* @return {!goog.ui.Button} A toolbar button.
411
* @private
412
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
413
*/
414
goog.ui.editor.DefaultToolbar.rtlButtonFactory_ = function(
415
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
416
'use strict';
417
const button = goog.ui.editor.ToolbarFactory.makeToggleButton(
418
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
419
button.updateFromValue = function(value) {
420
'use strict';
421
// Enable/disable right-to-left text editing mode in the toolbar.
422
const isRtl = !!value;
423
// Enable/disable a marker class on the toolbar's root element; the rest is
424
// done using CSS scoping in editortoolbar.css. This changes
425
// direction-senitive toolbar icons (like indent/outdent)
426
goog.dom.classlist.enable(
427
goog.asserts.assert(button.getParent().getElement()),
428
goog.getCssName('tr-rtl-mode'), isRtl);
429
button.setChecked(isRtl);
430
};
431
return button;
432
};
433
434
435
/**
436
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
437
* any custom CSS class names to the button's caption element. Designed to
438
* be used to create undo and redo buttons.
439
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
440
* built-in buttons, anything else for custom buttons.
441
* @param {string} tooltip Tooltip to be shown on hover.
442
* @param {goog.ui.ControlContent} caption Button caption.
443
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
444
* element.
445
* @param {goog.ui.ButtonRenderer=} opt_renderer Button renderer; defaults to
446
* {@link goog.ui.ToolbarButtonRenderer} if unspecified.
447
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
448
* creation; defaults to the current document if unspecified.
449
* @return {!goog.ui.Button} A toolbar button.
450
* @private
451
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
452
*/
453
goog.ui.editor.DefaultToolbar.undoRedoButtonFactory_ = function(
454
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
455
'use strict';
456
const button = goog.ui.editor.ToolbarFactory.makeButton(
457
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
458
button.updateFromValue = function(value) {
459
'use strict';
460
button.setEnabled(value);
461
};
462
return button;
463
};
464
465
466
/**
467
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
468
* any custom CSS class names to the button's caption element. Used to create
469
* a font face button, filled with default fonts.
470
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
471
* built-in buttons, anything else for custom buttons.
472
* @param {string} tooltip Tooltip to be shown on hover.
473
* @param {goog.ui.ControlContent} caption Button caption.
474
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
475
* element.
476
* @param {goog.ui.MenuButtonRenderer=} opt_renderer Button renderer; defaults
477
* to {@link goog.ui.ToolbarMenuButtonRenderer} if unspecified.
478
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
479
* creation; defaults to the current document if unspecified.
480
* @return {!goog.ui.Button} A toolbar button.
481
* @private
482
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
483
*/
484
goog.ui.editor.DefaultToolbar.fontFaceFactory_ = function(
485
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
486
'use strict';
487
const button = goog.ui.editor.ToolbarFactory.makeSelectButton(
488
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
489
goog.ui.editor.DefaultToolbar.addDefaultFonts(button);
490
button.setDefaultCaption(goog.ui.editor.DefaultToolbar.MSG_FONT_NORMAL);
491
// Font options don't have keyboard accelerators.
492
goog.dom.classlist.add(
493
goog.asserts.assert(button.getMenu().getContentElement()),
494
goog.getCssName('goog-menu-noaccel'));
495
496
// How to update this button's state.
497
button.updateFromValue = function(value) {
498
'use strict';
499
// Normalize value to null or a non-empty string (sometimes we get
500
// the empty string, sometimes we get false...), extract the substring
501
// up to the first comma to get the primary font name, and normalize
502
// to lowercase. This allows us to map a font spec like "Arial,
503
// Helvetica, sans-serif" to a font menu item.
504
// TODO (attila): Try to make this more robust.
505
let item = null;
506
if (value && value.length > 0) {
507
item = /** @type {goog.ui.MenuItem} */ (button.getMenu().getChild(
508
goog.ui.editor.ToolbarFactory.getPrimaryFont(value)));
509
}
510
const selectedItem = button.getSelectedItem();
511
if (item != selectedItem) {
512
button.setSelectedItem(item);
513
}
514
};
515
return button;
516
};
517
518
519
/**
520
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
521
* any custom CSS class names to the button's caption element. Use to create a
522
* font size button, filled with default font sizes.
523
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
524
* built-in buttons, anything else for custom buttons.
525
* @param {string} tooltip Tooltip to be shown on hover.
526
* @param {goog.ui.ControlContent} caption Button caption.
527
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
528
* element.
529
* @param {goog.ui.MenuButtonRenderer=} opt_renderer Button renderer; defaults
530
* to {@link goog.ui.ToolbarMebuButtonRenderer} if unspecified.
531
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
532
* creation; defaults to the current document if unspecified.
533
* @return {!goog.ui.Button} A toolbar button.
534
* @private
535
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
536
*/
537
goog.ui.editor.DefaultToolbar.fontSizeFactory_ = function(
538
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
539
'use strict';
540
const button = goog.ui.editor.ToolbarFactory.makeSelectButton(
541
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
542
goog.ui.editor.DefaultToolbar.addDefaultFontSizes(button);
543
button.setDefaultCaption(goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_NORMAL);
544
// Font size options don't have keyboard accelerators.
545
goog.dom.classlist.add(
546
goog.asserts.assert(button.getMenu().getContentElement()),
547
goog.getCssName('goog-menu-noaccel'));
548
// How to update this button's state.
549
button.updateFromValue = function(value) {
550
'use strict';
551
// Webkit pre-534.7 returns a string like '32px' instead of the equivalent
552
// integer, so normalize that first.
553
// NOTE(user): Gecko returns "6" so can't just normalize all
554
// strings, only ones ending in "px".
555
if (typeof value === 'string' && goog.style.getLengthUnits(value) == 'px') {
556
value = goog.ui.editor.ToolbarFactory.getLegacySizeFromPx(
557
parseInt(value, 10));
558
}
559
// Normalize value to null or a positive integer (sometimes we get
560
// the empty string, sometimes we get false, or -1 if the above
561
// normalization didn't match to a particular 0-7 size)
562
value = value > 0 ? value : null;
563
if (value != button.getValue()) {
564
button.setValue(value);
565
}
566
};
567
return button;
568
};
569
570
571
/**
572
* Function to update the state of a color menu button.
573
* @param {goog.ui.ToolbarColorMenuButton} button The button to which the
574
* color menu is attached.
575
* @param {number} color Color value to update to.
576
* @private
577
*/
578
goog.ui.editor.DefaultToolbar.colorUpdateFromValue_ = function(button, color) {
579
'use strict';
580
let value = color;
581
582
try {
583
if (goog.userAgent.IE) {
584
// IE returns a number that, converted to hex, is a BGR color.
585
// Convert from decimal to BGR to RGB.
586
const hex = '000000' + value.toString(16);
587
const bgr = hex.slice(-6);
588
value =
589
'#' + bgr.substring(4, 6) + bgr.substring(2, 4) + bgr.substring(0, 2);
590
}
591
if (value != button.getValue()) {
592
button.setValue(/** @type {string} */ (value));
593
}
594
} catch (ex) {
595
// TODO(attila): Find out when/why this happens.
596
}
597
};
598
599
600
/**
601
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
602
* any custom CSS class names to the button's caption element. Use to create
603
* a font color button.
604
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
605
* built-in buttons, anything else for custom buttons.
606
* @param {string} tooltip Tooltip to be shown on hover.
607
* @param {goog.ui.ControlContent} caption Button caption.
608
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
609
* element.
610
* @param {goog.ui.ColorMenuButtonRenderer=} opt_renderer Button renderer;
611
* defaults to {@link goog.ui.ToolbarColorMenuButtonRenderer} if
612
* unspecified.
613
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
614
* creation; defaults to the current document if unspecified.
615
* @return {!goog.ui.Button} A toolbar button.
616
* @private
617
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
618
*/
619
goog.ui.editor.DefaultToolbar.fontColorFactory_ = function(
620
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
621
'use strict';
622
const button = goog.ui.editor.ToolbarFactory.makeColorMenuButton(
623
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
624
// Initialize default foreground color.
625
button.setSelectedColor('#000');
626
button.updateFromValue = goog.partial(
627
goog.ui.editor.DefaultToolbar.colorUpdateFromValue_,
628
/** @type {!goog.ui.ToolbarColorMenuButton} */ (button));
629
return button;
630
};
631
632
633
/**
634
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
635
* any custom CSS class names to the button's caption element. Use to create
636
* a font background color button.
637
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
638
* built-in buttons, anything else for custom buttons.
639
* @param {string} tooltip Tooltip to be shown on hover.
640
* @param {goog.ui.ControlContent} caption Button caption.
641
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
642
* element.
643
* @param {goog.ui.ColorMenuButtonRenderer=} opt_renderer Button renderer;
644
* defaults to {@link goog.ui.ToolbarColorMenuButtonRenderer} if
645
* unspecified.
646
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
647
* creation; defaults to the current document if unspecified.
648
* @return {!goog.ui.Button} A toolbar button.
649
* @private
650
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
651
*/
652
goog.ui.editor.DefaultToolbar.backgroundColorFactory_ = function(
653
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
654
'use strict';
655
const button = goog.ui.editor.ToolbarFactory.makeColorMenuButton(
656
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
657
// Initialize default background color.
658
button.setSelectedColor('#FFF');
659
button.updateFromValue = goog.partial(
660
goog.ui.editor.DefaultToolbar.colorUpdateFromValue_,
661
/** @type {!goog.ui.ToolbarColorMenuButton} */ (button));
662
return button;
663
};
664
665
666
/**
667
* Creates a toolbar button with the given ID, tooltip, and caption. Applies
668
* any custom CSS class names to the button's caption element. Use to create
669
* the format menu, prefilled with default formats.
670
* @param {string} id Button ID; must equal a {@link goog.editor.Command} for
671
* built-in buttons, anything else for custom buttons.
672
* @param {string} tooltip Tooltip to be shown on hover.
673
* @param {goog.ui.ControlContent} caption Button caption.
674
* @param {string=} opt_classNames CSS class name(s) to apply to the caption
675
* element.
676
* @param {goog.ui.MenuButtonRenderer=} opt_renderer Button renderer;
677
* defaults to
678
* {@link goog.ui.ToolbarMenuButtonRenderer} if unspecified.
679
* @param {goog.dom.DomHelper=} opt_domHelper DOM helper, used for DOM
680
* creation; defaults to the current document if unspecified.
681
* @return {!goog.ui.Button} A toolbar button.
682
* @private
683
* @suppress {strictMissingProperties} Part of the go/strict_warnings_migration
684
*/
685
goog.ui.editor.DefaultToolbar.formatBlockFactory_ = function(
686
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper) {
687
'use strict';
688
const button = goog.ui.editor.ToolbarFactory.makeSelectButton(
689
id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper);
690
goog.ui.editor.DefaultToolbar.addDefaultFormatOptions(button);
691
button.setDefaultCaption(goog.ui.editor.DefaultToolbar.MSG_FORMAT_NORMAL);
692
// Format options don't have keyboard accelerators.
693
goog.dom.classlist.add(
694
goog.asserts.assert(button.getMenu().getContentElement()),
695
goog.getCssName('goog-menu-noaccel'));
696
// How to update this button.
697
button.updateFromValue = function(value) {
698
'use strict';
699
// Normalize value to null or a nonempty string (sometimes we get
700
// the empty string, sometimes we get false...)
701
value = value && value.length > 0 ? value : null;
702
if (value != button.getValue()) {
703
button.setValue(value);
704
}
705
};
706
return button;
707
};
708
709
710
// Messages used for tooltips and captions.
711
712
713
/** @desc Format menu tooltip. */
714
goog.ui.editor.DefaultToolbar.MSG_FORMAT_BLOCK_TITLE = goog.getMsg('Format');
715
716
717
/** @desc Format menu caption. */
718
goog.ui.editor.DefaultToolbar.MSG_FORMAT_BLOCK_CAPTION = goog.getMsg('Format');
719
720
721
/** @desc Undo button tooltip. */
722
goog.ui.editor.DefaultToolbar.MSG_UNDO_TITLE = goog.getMsg('Undo');
723
724
725
/** @desc Redo button tooltip. */
726
goog.ui.editor.DefaultToolbar.MSG_REDO_TITLE = goog.getMsg('Redo');
727
728
729
/** @desc Font menu tooltip. */
730
goog.ui.editor.DefaultToolbar.MSG_FONT_FACE_TITLE = goog.getMsg('Font');
731
732
733
/** @desc Font size menu tooltip. */
734
goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_TITLE = goog.getMsg('Font size');
735
736
737
/** @desc Text foreground color menu tooltip. */
738
goog.ui.editor.DefaultToolbar.MSG_FONT_COLOR_TITLE = goog.getMsg('Text color');
739
740
741
/** @desc Bold button tooltip. */
742
goog.ui.editor.DefaultToolbar.MSG_BOLD_TITLE = goog.getMsg('Bold');
743
744
745
/** @desc Italic button tooltip. */
746
goog.ui.editor.DefaultToolbar.MSG_ITALIC_TITLE = goog.getMsg('Italic');
747
748
749
/** @desc Underline button tooltip. */
750
goog.ui.editor.DefaultToolbar.MSG_UNDERLINE_TITLE = goog.getMsg('Underline');
751
752
753
/** @desc Text background color menu tooltip. */
754
goog.ui.editor.DefaultToolbar.MSG_BACKGROUND_COLOR_TITLE =
755
goog.getMsg('Text background color');
756
757
758
/** @desc Link button tooltip. */
759
goog.ui.editor.DefaultToolbar.MSG_LINK_TITLE =
760
goog.getMsg('Add or remove link');
761
762
763
/** @desc Numbered list button tooltip. */
764
goog.ui.editor.DefaultToolbar.MSG_ORDERED_LIST_TITLE =
765
goog.getMsg('Numbered list');
766
767
768
/** @desc Bullet list button tooltip. */
769
goog.ui.editor.DefaultToolbar.MSG_UNORDERED_LIST_TITLE =
770
goog.getMsg('Bullet list');
771
772
773
/** @desc Outdent button tooltip. */
774
goog.ui.editor.DefaultToolbar.MSG_OUTDENT_TITLE =
775
goog.getMsg('Decrease indent');
776
777
778
/** @desc Indent button tooltip. */
779
goog.ui.editor.DefaultToolbar.MSG_INDENT_TITLE = goog.getMsg('Increase indent');
780
781
782
/** @desc Align left button tooltip. */
783
goog.ui.editor.DefaultToolbar.MSG_ALIGN_LEFT_TITLE = goog.getMsg('Align left');
784
785
786
/** @desc Align center button tooltip. */
787
goog.ui.editor.DefaultToolbar.MSG_ALIGN_CENTER_TITLE =
788
goog.getMsg('Align center');
789
790
791
/** @desc Align right button tooltip. */
792
goog.ui.editor.DefaultToolbar.MSG_ALIGN_RIGHT_TITLE =
793
goog.getMsg('Align right');
794
795
796
/** @desc Justify button tooltip. */
797
goog.ui.editor.DefaultToolbar.MSG_JUSTIFY_TITLE = goog.getMsg('Justify');
798
799
800
/** @desc Remove formatting button tooltip. */
801
goog.ui.editor.DefaultToolbar.MSG_REMOVE_FORMAT_TITLE =
802
goog.getMsg('Remove formatting');
803
804
805
/** @desc Insert image button tooltip. */
806
goog.ui.editor.DefaultToolbar.MSG_IMAGE_TITLE = goog.getMsg('Insert image');
807
808
809
/** @desc Strike through button tooltip. */
810
goog.ui.editor.DefaultToolbar.MSG_STRIKE_THROUGH_TITLE =
811
goog.getMsg('Strikethrough');
812
813
814
/** @desc Left-to-right button tooltip. */
815
goog.ui.editor.DefaultToolbar.MSG_DIR_LTR_TITLE = goog.getMsg('Left-to-right');
816
817
818
/** @desc Right-to-left button tooltip. */
819
goog.ui.editor.DefaultToolbar.MSG_DIR_RTL_TITLE = goog.getMsg('Right-to-left');
820
821
822
/** @desc Blockquote button tooltip. */
823
goog.ui.editor.DefaultToolbar.MSG_BLOCKQUOTE_TITLE = goog.getMsg('Quote');
824
825
826
/** @desc Edit HTML button tooltip. */
827
goog.ui.editor.DefaultToolbar.MSG_EDIT_HTML_TITLE =
828
goog.getMsg('Edit HTML source');
829
830
831
/** @desc Subscript button tooltip. */
832
goog.ui.editor.DefaultToolbar.MSG_SUBSCRIPT = goog.getMsg('Subscript');
833
834
835
/** @desc Superscript button tooltip. */
836
goog.ui.editor.DefaultToolbar.MSG_SUPERSCRIPT = goog.getMsg('Superscript');
837
838
839
/** @desc Edit HTML button caption. */
840
goog.ui.editor.DefaultToolbar.MSG_EDIT_HTML_CAPTION = goog.getMsg('Edit HTML');
841
842
843
/**
844
* Map of `goog.editor.Command`s to toolbar button descriptor objects,
845
* each of which has the following attributes:
846
* <ul>
847
* <li>`command` - The command corresponding to the
848
* button (mandatory)
849
* <li>`tooltip` - Tooltip text (optional); if unspecified, the button
850
* has no hover text
851
* <li>`caption` - Caption to display on the button (optional); if
852
* unspecified, the button has no text caption
853
* <li>`classes` - CSS class name(s) to be applied to the button's
854
* element when rendered (optional); if unspecified, defaults to
855
* 'tr-icon'
856
* plus 'tr-' followed by the command ID, but without any leading '+'
857
* character (e.g. if the command ID is '+undo', then `classes`
858
* defaults to 'tr-icon tr-undo')
859
* <li>`factory` - factory function used to create the button, which
860
* must accept `id`, `tooltip`, `caption`, and
861
* `classes` as arguments, and must return an instance of
862
* {@link goog.ui.Button} or an appropriate subclass (optional); if
863
* unspecified, defaults to
864
* {@link goog.ui.editor.DefaultToolbar.makeToggleButton},
865
* since most built-in toolbar buttons are toggle buttons
866
* <li>(@code queryable} - Whether the button's state should be queried
867
* when updating the toolbar (optional).
868
* </ul>
869
* Note that this object is only used for creating toolbar buttons for
870
* built-in editor commands; custom buttons aren't listed here. Please don't
871
* try to hack this!
872
* @private {!Object<string, !goog.ui.editor.ButtonDescriptor>}.
873
*/
874
goog.ui.editor.DefaultToolbar.buttons_ = {};
875
876
877
/**
878
* @typedef {{
879
* command: string,
880
* tooltip: (undefined|string),
881
* caption: (undefined|goog.ui.ControlContent),
882
* classes: (undefined|string),
883
* factory: (undefined|!Function),
884
* queryable:(undefined|boolean)}}
885
*/
886
goog.ui.editor.ButtonDescriptor;
887
888
889
/**
890
* Built-in toolbar button descriptors. See
891
* {@link goog.ui.editor.DefaultToolbar.buttons_} for details on button
892
* descriptor objects. This array is processed at JS parse time; each item is
893
* inserted into {@link goog.ui.editor.DefaultToolbar.buttons_}, and the array
894
* itself is deleted and (hopefully) garbage-collected.
895
* @private {Array<!goog.ui.editor.ButtonDescriptor>}
896
*/
897
goog.ui.editor.DefaultToolbar.button_list_ = [
898
{
899
command: goog.editor.Command.UNDO,
900
tooltip: goog.ui.editor.DefaultToolbar.MSG_UNDO_TITLE,
901
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-undo'),
902
factory: goog.ui.editor.DefaultToolbar.undoRedoButtonFactory_,
903
queryable: true
904
},
905
{
906
command: goog.editor.Command.REDO,
907
tooltip: goog.ui.editor.DefaultToolbar.MSG_REDO_TITLE,
908
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-redo'),
909
factory: goog.ui.editor.DefaultToolbar.undoRedoButtonFactory_,
910
queryable: true
911
},
912
{
913
command: goog.editor.Command.FONT_FACE,
914
tooltip: goog.ui.editor.DefaultToolbar.MSG_FONT_FACE_TITLE,
915
classes: goog.getCssName('tr-fontName'),
916
factory: goog.ui.editor.DefaultToolbar.fontFaceFactory_,
917
queryable: true
918
},
919
{
920
command: goog.editor.Command.FONT_SIZE,
921
tooltip: goog.ui.editor.DefaultToolbar.MSG_FONT_SIZE_TITLE,
922
classes: goog.getCssName('tr-fontSize'),
923
factory: goog.ui.editor.DefaultToolbar.fontSizeFactory_,
924
queryable: true
925
},
926
{
927
command: goog.editor.Command.BOLD,
928
tooltip: goog.ui.editor.DefaultToolbar.MSG_BOLD_TITLE,
929
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-bold'),
930
queryable: true
931
},
932
{
933
command: goog.editor.Command.ITALIC,
934
tooltip: goog.ui.editor.DefaultToolbar.MSG_ITALIC_TITLE,
935
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-italic'),
936
queryable: true
937
},
938
{
939
command: goog.editor.Command.UNDERLINE,
940
tooltip: goog.ui.editor.DefaultToolbar.MSG_UNDERLINE_TITLE,
941
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-underline'),
942
queryable: true
943
},
944
{
945
command: goog.editor.Command.FONT_COLOR,
946
tooltip: goog.ui.editor.DefaultToolbar.MSG_FONT_COLOR_TITLE,
947
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-foreColor'),
948
factory: goog.ui.editor.DefaultToolbar.fontColorFactory_,
949
queryable: true
950
},
951
{
952
command: goog.editor.Command.BACKGROUND_COLOR,
953
tooltip: goog.ui.editor.DefaultToolbar.MSG_BACKGROUND_COLOR_TITLE,
954
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-backColor'),
955
factory: goog.ui.editor.DefaultToolbar.backgroundColorFactory_,
956
queryable: true
957
},
958
{
959
command: goog.editor.Command.LINK,
960
tooltip: goog.ui.editor.DefaultToolbar.MSG_LINK_TITLE,
961
caption: goog.ui.editor.messages.MSG_LINK_CAPTION,
962
classes: goog.getCssName('tr-link'),
963
queryable: true
964
},
965
{
966
command: goog.editor.Command.ORDERED_LIST,
967
tooltip: goog.ui.editor.DefaultToolbar.MSG_ORDERED_LIST_TITLE,
968
classes: goog.getCssName('tr-icon') + ' ' +
969
goog.getCssName('tr-insertOrderedList'),
970
queryable: true
971
},
972
{
973
command: goog.editor.Command.UNORDERED_LIST,
974
tooltip: goog.ui.editor.DefaultToolbar.MSG_UNORDERED_LIST_TITLE,
975
classes: goog.getCssName('tr-icon') + ' ' +
976
goog.getCssName('tr-insertUnorderedList'),
977
queryable: true
978
},
979
{
980
command: goog.editor.Command.OUTDENT,
981
tooltip: goog.ui.editor.DefaultToolbar.MSG_OUTDENT_TITLE,
982
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-outdent'),
983
factory: goog.ui.editor.ToolbarFactory.makeButton
984
},
985
{
986
command: goog.editor.Command.INDENT,
987
tooltip: goog.ui.editor.DefaultToolbar.MSG_INDENT_TITLE,
988
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-indent'),
989
factory: goog.ui.editor.ToolbarFactory.makeButton
990
},
991
{
992
command: goog.editor.Command.JUSTIFY_LEFT,
993
tooltip: goog.ui.editor.DefaultToolbar.MSG_ALIGN_LEFT_TITLE,
994
classes:
995
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-justifyLeft'),
996
queryable: true
997
},
998
{
999
command: goog.editor.Command.JUSTIFY_CENTER,
1000
tooltip: goog.ui.editor.DefaultToolbar.MSG_ALIGN_CENTER_TITLE,
1001
classes:
1002
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-justifyCenter'),
1003
queryable: true
1004
},
1005
{
1006
command: goog.editor.Command.JUSTIFY_RIGHT,
1007
tooltip: goog.ui.editor.DefaultToolbar.MSG_ALIGN_RIGHT_TITLE,
1008
classes:
1009
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-justifyRight'),
1010
queryable: true
1011
},
1012
{
1013
command: goog.editor.Command.JUSTIFY_FULL,
1014
tooltip: goog.ui.editor.DefaultToolbar.MSG_JUSTIFY_TITLE,
1015
classes:
1016
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-justifyFull'),
1017
queryable: true
1018
},
1019
{
1020
command: goog.editor.Command.REMOVE_FORMAT,
1021
tooltip: goog.ui.editor.DefaultToolbar.MSG_REMOVE_FORMAT_TITLE,
1022
classes:
1023
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-removeFormat'),
1024
factory: goog.ui.editor.ToolbarFactory.makeButton
1025
},
1026
{
1027
command: goog.editor.Command.IMAGE,
1028
tooltip: goog.ui.editor.DefaultToolbar.MSG_IMAGE_TITLE,
1029
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-image'),
1030
factory: goog.ui.editor.ToolbarFactory.makeButton
1031
},
1032
{
1033
command: goog.editor.Command.STRIKE_THROUGH,
1034
tooltip: goog.ui.editor.DefaultToolbar.MSG_STRIKE_THROUGH_TITLE,
1035
classes:
1036
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-strikeThrough'),
1037
queryable: true
1038
},
1039
{
1040
command: goog.editor.Command.SUBSCRIPT,
1041
tooltip: goog.ui.editor.DefaultToolbar.MSG_SUBSCRIPT,
1042
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-subscript'),
1043
queryable: true
1044
},
1045
{
1046
command: goog.editor.Command.SUPERSCRIPT,
1047
tooltip: goog.ui.editor.DefaultToolbar.MSG_SUPERSCRIPT,
1048
classes:
1049
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-superscript'),
1050
queryable: true
1051
},
1052
{
1053
command: goog.editor.Command.DIR_LTR,
1054
tooltip: goog.ui.editor.DefaultToolbar.MSG_DIR_LTR_TITLE,
1055
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-ltr'),
1056
queryable: true
1057
},
1058
{
1059
command: goog.editor.Command.DIR_RTL,
1060
tooltip: goog.ui.editor.DefaultToolbar.MSG_DIR_RTL_TITLE,
1061
classes: goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-rtl'),
1062
factory: goog.ui.editor.DefaultToolbar.rtlButtonFactory_,
1063
queryable: true
1064
},
1065
{
1066
command: goog.editor.Command.BLOCKQUOTE,
1067
tooltip: goog.ui.editor.DefaultToolbar.MSG_BLOCKQUOTE_TITLE,
1068
classes:
1069
goog.getCssName('tr-icon') + ' ' + goog.getCssName('tr-BLOCKQUOTE'),
1070
queryable: true
1071
},
1072
{
1073
command: goog.editor.Command.FORMAT_BLOCK,
1074
tooltip: goog.ui.editor.DefaultToolbar.MSG_FORMAT_BLOCK_TITLE,
1075
caption: goog.ui.editor.DefaultToolbar.MSG_FORMAT_BLOCK_CAPTION,
1076
classes: goog.getCssName('tr-formatBlock'),
1077
factory: goog.ui.editor.DefaultToolbar.formatBlockFactory_,
1078
queryable: true
1079
},
1080
{
1081
command: goog.editor.Command.EDIT_HTML,
1082
tooltip: goog.ui.editor.DefaultToolbar.MSG_EDIT_HTML_TITLE,
1083
caption: goog.ui.editor.DefaultToolbar.MSG_EDIT_HTML_CAPTION,
1084
classes: goog.getCssName('tr-editHtml'),
1085
factory: goog.ui.editor.ToolbarFactory.makeButton
1086
}
1087
];
1088
1089
1090
(function() {
1091
'use strict';
1092
// Create the goog.ui.editor.DefaultToolbar.buttons_ map from
1093
// goog.ui.editor.DefaultToolbar.button_list_.
1094
for (let i = 0, button; button = goog.ui.editor.DefaultToolbar.button_list_[i];
1095
i++) {
1096
goog.ui.editor.DefaultToolbar.buttons_[button.command] = button;
1097
}
1098
1099
// goog.ui.editor.DefaultToolbar.button_list_ is no longer needed
1100
// once the map is ready.
1101
goog.ui.editor.DefaultToolbar.button_list_ = null;
1102
})();
1103
1104