Jump to content

Recommended Posts

Posted

TinyMCE Module looks great. One item I can't see is the ability to group related toolbar icons with a pipe.

The official docs on TinyMCE mention to use a pipe  but I can't see how to apply it to the Toolbar settings.

Interestingly, if you manually type a pipe, it does add it to the Toolbar but only accepts a single one.

1834683243_CleanShot2023-05-18at12_59.07@2x.thumb.png.2efe04fc77a338faac2dc7abd46aede4.pngTin

 

Posted

That's (very) unfortunately not possible because the input field used there, InputfieldTextTags, uses jQuery's selectize addon, which doesn't allow duplicates. A bug requesting that capability has been opened ten years ago. It might help to upvote this bug, then @ryan could adapt InputfieldTextTags (or rework, most likely, since it uses tag values as keys, which also eliminates duplicate values).

There's, however, already code inside InputfieldTinyMCEConfigs.php for a textarea instead of a text tags input (with all the downsides of not validating the names entered) for the toolbar config. Just uncomment the code here and comment out the field definition after that.

  • Like 5
Posted

Bummer about the Selectize issue. I think it might be the cause of this too: https://github.com/processwire/processwire-issues/issues/1736

A hook to substitute a textarea for the toolbar config without editing the core:

$wire->addHookAfter('InputfieldTinyMCE::getConfigInputfields', function(HookEvent $event) {
	/** @var InputfieldWrapper $wrapper */
	$wrapper = $event->return;
	$toolbar = $wrapper->getChildByName('toolbar');
	$replacement = $event->wire()->modules->get('InputfieldTextarea');
	$replacement->rows = 3;
	$settings = [
		'name',
		'label',
		'description',
		'icon',
		'textFormat',
		'themeOffset',
		'notes',
		'value',
	];
	foreach($settings as $setting) $replacement->$setting = $toolbar->$setting;
	$wrapper->insertBefore($replacement, $toolbar);
	$wrapper->remove($toolbar);
});

 

  • Like 4
  • 4 weeks later...
Posted
On 5/18/2023 at 10:48 PM, BitPoet said:

That's (very) unfortunately not possible because the input field used there, InputfieldTextTags, uses jQuery's selectize addon, which doesn't allow duplicates. A bug requesting that capability has been opened ten years ago. It might help to upvote this bug, then @ryan could adapt InputfieldTextTags (or rework, most likely, since it uses tag values as keys, which also eliminates duplicate values).

There's, however, already code inside InputfieldTinyMCEConfigs.php for a textarea instead of a text tags input (with all the downsides of not validating the names entered) for the toolbar config. Just uncomment the code here and comment out the field definition after that.

Thank you, I also want to know it.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...