Days
Hours
Minutes
Seconds
x
Skip to content

Custom Elements

Custom Dropdown

The following example shows how to create a custom dropdown for the editor:

  1. Define an icon.
  2. Define a dropdown button.
  3. Set a title.
  4. Mark the button as a dropdown.
  5. Specify the icon for the button. If this option is not specified, the button name will be used.
  6. Options for the dropdown.
  7. If present, the options property will be ignored.
    It can be used to define a custom HTML for the dropdown.
    The current context is the editor instance.
  8. Save the dropdown action into undo stack.
  9. Focus inside the editor before callback.
  10. Refresh the button state after the callback.
  11. Add a callback.
    The current context is the editor instance.
  12. Call a function when the dropdown button state might have changed.
    The current context is the editor instance.
  13. Call a function when the dropdown is shown.
    The current context is the editor instance.
  14. console.log (this.selection.element()); } })

Your final code should look like this:

For a working example please refer to the Custom Dropdown Example

Note: Once a command is defined it can be included in the buttons options: imageAltButtons, imageEditButtons, imageInsertButtons, imageSizeButtons, linkEditButtons, linkInsertButtons, tableColorsButtons, tableEditButtons, tableInsertButtons, toolbarButtons, toolbarButtonsMD, toolbarButtonsSM, toolbarButtonsXS, videoEditButtons, videoInsertButtons or videoSizeButtons.

Do you think we can improve this article? Let us know.