monsieurbiz / SyliusRichEditorPlugin

This plugin add a rich editor on fields to be able to drag and drop elements and edit it.
MIT License
67 stars 40 forks source link

Customize Wysiwyg editor #113

Open armellarcier opened 3 years ago

armellarcier commented 3 years ago

I need a field with only the h3 and paragraph levels

I'd like to add a configuration in my form builder to customize the Wysiwyg toolbar.

armellarcier commented 3 years ago

Could be done with a data-attribute on the textarea tag, so with attr config but it will not allow for formatting functions.

Better register javascript Pell configuration object and use those.

I'd need a few directions before creating a PR.

jacquesbh commented 3 years ago

The actions are defined here: https://github.com/monsieurbiz/SyliusRichEditorPlugin/blob/26a41cb575b773864103d87a8c654b9e858f3f6c/src/Resources/views/Admin/app.html.twig#L86-L103

But it is for all wysiwyg fields. It could be possible to pass the actions directly to an attribute of the field, using data-actions as example, and a json encoded value. Then add a condition here to initialize Pell with those actions if they exist: https://github.com/monsieurbiz/SyliusRichEditorPlugin/blob/26a41cb575b773864103d87a8c654b9e858f3f6c/assets/js/app.js#L32

jacquesbh commented 3 years ago

Another way could be to register somewhere more Pell configurations identified by a specific name, and use that name in the attribute to setup pell for each wysiwyg field. This is much better actually but it'll require a bit more code.

armellarcier commented 3 years ago

I'm wondering whether this plugin should be so opinionated on the js text editor to use altogether.

We need at least a way to configure Pell's toolbar globally and for individual UiElements but why not allow replacing the editor library?

jacquesbh commented 3 years ago

If you want to replace the library you are free to do so ;). But we won't change the library here because the goal is to have something really simple.

armellarcier commented 3 years ago

Sure, I just meant supporting / documenting text editing lib switch

jacquesbh commented 3 years ago

Yes but why documenting a feature which doesn't exist yet? :p

armellarcier commented 3 years ago

I'm actually making the scope of this issue wider than just "toolbar customization"