buttonDef

Release 2.4.0+

Definitions for plugin buttons exposed on the toolbar, menu, or balloon popups.

Common Keys

KeyTypeDescription
namestringButton name. Used when registering on editor.toolbar, editor.balloon, etc. — must be unique. If omitted in a single-button plugin, defaults to the plugin name; required when a plugin defines multiple buttons.
labelstringButton label — shown as a tooltip.
typestringRelease 2.7.0+ 'button' (default) or 'dropdown'.
iconSVGstringSVG markup or an <img> tag for the button icon.
iconNamestringReuses an icon already registered with the editor by name (used when iconSVG is not set).

label is shown as a tooltip on hover:

label_tooltip.gif

Button (type: 'button')

KeyTypeDescription
onClickFuncfunctionRuns when the button is clicked.
{
  onClickFunc: function (event) {
    // ...
  }
}

Release 2.7.0+

KeyTypeDescription
onClickFuncfunctionRuns when the dropdown is clicked. For a split-button dropdown (isSingle: false), runs on click of the leading button.
isSinglebooleantrue (default) — single dropdown. false — split-button dropdown.
useIconbooleanfalse (default) — text dropdown. true — icon dropdown.
dropdownItemsobject[]Dropdown items.

onClickFunc behavior:

dropdown_onclickfunc_a.gifdropdown_onclickfunc_b.gif

isSingle — single vs. split-button dropdown:

dropdown_issingle_a.gifdropdown_issingle_b.gif

useIcon — icon vs. text dropdown:

dropdown_useicon_a.gifdropdown_useicon_b.gif

dropdownItems example:

{
  type: 'dropdown',
  isSingle: true,
  useIcon: false,
  dropdownItems: [
    { label: 'Item 1' },
    { label: 'Item 2' },
    { label: 'Item 3' }
  ]
}

dropdownitems_example.png

KeyTypeDescription
labelstringItem label.
onClickFuncfunctionRuns when the item is clicked.
cssTextstringInline CSS applied to the item.

label rendering:

item_label_example.png

onClickFunc behavior:

item_onclickfunc_example.gif

cssText styling:

{
  dropdownItems: [
    { label: 'Item 1', cssText: 'font-size: 20px; color: orange;' },
    {
      label: 'Item 2',
      cssText: 'font-size: 15px; color: red;',
      onClickFunc: function () { /* ... */ }
    }
  ]
}

item_csstext_example.png