The goog.ui.editor.ToolbarFactory Namespace

.addFont(button, caption, value)

Adds a menu item to the given font menu button. The first font listed in the {@code value} argument is considered the font ID, so adding two items whose CSS style starts with the same font may lead to unpredictable results.

button {!goog.ui.Select}
Font menu button.
caption {string}
Caption to show for the font menu.
value {string}
Value for the corresponding 'font-family' CSS style.

.addFontSize(button, caption, value)

Adds a menu item to the given font size menu button. The {@code value} argument must be a legacy HTML font size in the 0-7 range.

button {!goog.ui.Select}
Font size menu button.
caption {string}
Caption to show in the font size menu.
value {number}
Value for the corresponding HTML font size.

.addFontSizes(button, sizes)

Bulk-adds font sizes to the given font size menu button. The argument must be an array of font size descriptor objects, each of which must have the following attributes:

button {!goog.ui.Select}
Font size menu button.
sizes {!Array.<{caption: string, value:number}>}
Array of font size descriptors.

.addFonts(button, fonts)

Bulk-adds fonts to the given font menu button. The argument must be an array of font descriptor objects, each of which must have the following attributes:

button {!goog.ui.Select}
Font menu button.
fonts {!Array.<{caption: string, value: string}>}
Array of font descriptors.

.addFormatOption(button, caption, tag)

Adds a menu item to the given "Format block" menu button.

button {!goog.ui.Select}
"Format block" menu button.
caption {string}
Caption to show in the menu.
tag {goog.dom.TagName}
Corresponding block format tag.

.addFormatOptions(button, formats)

Bulk-adds format options to the given "Format block" menu button. The argument must be an array of format option descriptor objects, each of which must have the following attributes:

button {!goog.ui.Select}
"Format block" menu button.
formats {!Array.<{caption: string, command: goog.dom.TagName}>}
Array of format option descriptors.

.getLegacySizeFromPx(px)

Converts a pixel font size specification into an equivalent legacy size. For example, {@code font-size: 32px;} is {@code <font size="6">}, etc. If the given pixel size doesn't exactly match one of the legacy sizes, -1 is returned.

px {number}
Pixel font size.
returns {number}
Equivalent legacy size spec in the 0-7 range, or -1 if none exists.

.getPrimaryFont(fontSpec)

Takes a font spec (e.g. "Arial, Helvetica, sans-serif") and returns the primary font name, normalized to lowercase (e.g. "arial").

fontSpec {string}
Font specification.
returns {string}
The primary font name, in lowercase.

.getPxFromLegacySize(fontSize)

Converts a legacy font size specification into an equivalent pixel size. For example, {@code <font size="6">} is {@code font-size: 32px;}, etc.

fontSize {number}
Legacy font size spec in the 0-7 range.
returns {number}
Equivalent pixel size.

.makeButton(id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper)

Creates a toolbar button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element.

id {string}
Button ID; must equal a {@link goog.editor.Command} for built-in buttons, anything else for custom buttons.
tooltip {string}
Tooltip to be shown on hover.
caption {goog.ui.ControlContent}
Button caption.
opt_classNames {string=}
CSS class name(s) to apply to the caption element.
opt_renderer {goog.ui.ButtonRenderer=}
Button renderer; defaults to {@link goog.ui.ToolbarButtonRenderer} if unspecified.
opt_domHelper {goog.dom.DomHelper=}
DOM helper, used for DOM creation; defaults to the current document if unspecified.
returns {!goog.ui.Button}
A toolbar button.

.makeColorMenuButton(id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper)

Creates a color menu button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button is created with a default color menu containing standard color palettes.

id {string}
Button ID; must equal a {@link goog.editor.Command} for built-in toolbar buttons, but can be anything else for custom buttons.
tooltip {string}
Tooltip to be shown on hover.
caption {goog.ui.ControlContent}
Button caption.
opt_classNames {string=}
CSS class name(s) to apply to the caption element.
opt_renderer {goog.ui.ColorMenuButtonRenderer=}
Button renderer; defaults to {@link goog.ui.ToolbarColorMenuButtonRenderer} if unspecified.
opt_domHelper {goog.dom.DomHelper=}
DOM helper, used for DOM creation; defaults to the current document if unspecified.
returns {!goog.ui.ColorMenuButton}
A color menu button.

.makeMenuButton(id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper)

Creates a menu button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button returned doesn't have an actual menu attached; use {@link goog.ui.MenuButton#setMenu} to attach a {@link goog.ui.Menu} to the button.

id {string}
Button ID; must equal a {@link goog.editor.Command} for built-in buttons, anything else for custom buttons.
tooltip {string}
Tooltip to be shown on hover.
caption {goog.ui.ControlContent}
Button caption.
opt_classNames {string=}
CSS class name(s) to apply to the caption element.
opt_renderer {goog.ui.ButtonRenderer=}
Button renderer; defaults to {@link goog.ui.ToolbarMenuButtonRenderer} if unspecified.
opt_domHelper {goog.dom.DomHelper=}
DOM helper, used for DOM creation; defaults to the current document if unspecified.
returns {!goog.ui.MenuButton}
A menu button.

.makeSelectButton(id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper)

Creates a select button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's root element. The button returned doesn't have an actual menu attached; use {@link goog.ui.Select#setMenu} to attach a {@link goog.ui.Menu} containing {@link goog.ui.Option}s to the select button.

id {string}
Button ID; must equal a {@link goog.editor.Command} for built-in buttons, anything else for custom buttons.
tooltip {string}
Tooltip to be shown on hover.
caption {goog.ui.ControlContent}
Button caption; used as the default caption when nothing is selected.
opt_classNames {string=}
CSS class name(s) to apply to the button's root element.
opt_renderer {goog.ui.MenuButtonRenderer=}
Button renderer; defaults to {@link goog.ui.ToolbarMenuButtonRenderer} if unspecified.
opt_domHelper {goog.dom.DomHelper=}
DOM helper, used for DOM creation; defaults to the current document if unspecified.
returns {!goog.ui.Select}
A select button.

.makeToggleButton(id, tooltip, caption, opt_classNames, opt_renderer, opt_domHelper)

Creates a toggle button with the given ID, tooltip, and caption. Applies any custom CSS class names to the button's caption element. The button returned has checkbox-like toggle semantics.

id {string}
Button ID; must equal a {@link goog.editor.Command} for built-in buttons, anything else for custom buttons.
tooltip {string}
Tooltip to be shown on hover.
caption {goog.ui.ControlContent}
Button caption.
opt_classNames {string=}
CSS class name(s) to apply to the caption element.
opt_renderer {goog.ui.ButtonRenderer=}
Button renderer; defaults to {@link goog.ui.ToolbarButtonRenderer} if unspecified.
opt_domHelper {goog.dom.DomHelper=}
DOM helper, used for DOM creation; defaults to the current document if unspecified.
returns {!goog.ui.Button}
A toggle button.

.makeToolbar(items, elem, opt_isRightToLeft)

Creates a {@link goog.ui.Toolbar} containing the specified set of toolbar buttons, and renders it into the given parent element. Each item in the {@code items} array must a {@link goog.ui.Control}.

items {!Array.<goog.ui.Control>}
Toolbar items; each must be a {@link goog.ui.Control}.
elem {!Element}
Toolbar parent element.
opt_isRightToLeft {boolean=}
Whether the editor chrome is right-to-left; defaults to the directionality of the toolbar parent element.
returns {!goog.ui.Toolbar}
Editor toolbar, rendered into the given parent element.