tinymcetinymce-plugins

Remove the menu from insertdatetime splitbutton


I've added an insertdatetime button to my toolbar, which has an icon + a drop-down menu.

I've removed all the menu options, because I only want a single-click button, that inserts current date/time.

Is it possible to remove the drop-down (menu) part of the button?


Solution

  • This isn't possible out of the box, as the default button in the Insert Date/Time plugin will always use a split toolbar button. If you want just a regular toolbar button you'd need to create a custom button. Here's an example to show how this can be done by making use of the mceInsertDate command provided by the Insert Date/Time plugin: https://fiddle.tiny.cloud/9Phaab

    editor.ui.registry.addButton('insertdate', {
      icon: 'insert-time',
      tooltip: 'Insert date',
      onAction: () => editor.execCommand('mceInsertDate')
    });
    

    More information can be found in the TinyMCE documentation: