Use trailing commas in the editor inits

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 13592
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Use trailing commas in the editor inits

Post by cmb » Wed Jan 03, 2018 11:40 am

Hi everybody!

Unless we're changing the editor inits to JSON, I suggest that we use trailing commas to ease customization. Trailing commas in object literals are allowed by the ES 5.1 specification, and are supported by all contemporary browsers (that excludes IE ≤ 9, what shouldn't be an issue). See https://developer.mozilla.org/en-US/doc ... ing_commas for details.

My main motivation for suggesting this is to simplify documentation on adding additional configuration options to the inits. It would be much simpler to tell user to insert a new line, instead of also telling where to add and remove a comma, respectively – and a missing comma would break TinyMCE.
Christoph M. Becker – Plugins for CMSimple_XH

manu
Posts: 948
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: Use trailing commas in the editor inits

Post by manu » Mon Mar 01, 2021 12:12 pm

I just made an effort to make tinyMCE5 inits JSON ready. But, is TinyMCE able to factory JSON? Almost, but not completely!
I didn't manage to enter the file_picker_callback property. This property expects a callback/function, which is not allowed in JSON. An ugly pastprocessing hack could fix this, but I dont't know..
On the other hand the init files don't look alike the examples on tiny.cloud. The notation is a bit different and could end up in confusion.
What do you think? Should we abandon the plans of setting the init files to JSON?

cmb
Posts: 13592
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Use trailing commas in the editor inits

Post by cmb » Mon Mar 01, 2021 6:19 pm

manu wrote:
Mon Mar 01, 2021 12:12 pm
I didn't manage to enter the file_picker_callback property. This property expects a callback/function, which is not allowed in JSON. An ugly pastprocessing hack could fix this, but I dont't know..
But isn't this what we're doing anyway? And frankly, why do we even have file_picker_callback in the init file? I mean, likely no user will ever touch this, but instead rely on the provided callbacks.
manu wrote:
Mon Mar 01, 2021 12:12 pm
On the other hand the init files don't look alike the examples on tiny.cloud. The notation is a bit different and could end up in confusion.
What do you think? Should we abandon the plans of setting the init files to JSON?
In my opinion, JSON has a lot of advantages for the config files over native JS, and as such it's easier to be edited by power users, and it would be easier to manipulate it programmatically. It is also safer, because it can be processed and validated by PHP, instead of just doing some pattern replacements and sending potentially broken JS to the client, where that causes some error (maybe even suppressed by the editor, falling back to some defaults).

That said, I have no real issues with the native JS format that we're using for a long time, and it's okay for me to stick with it.
Christoph M. Becker – Plugins for CMSimple_XH

manu
Posts: 948
Joined: Wed Jun 04, 2008 12:05 pm
Location: St. Gallen - Schweiz
Contact:

Re: Use trailing commas in the editor inits

Post by manu » Tue Mar 02, 2021 8:56 am

cmb wrote:
Mon Mar 01, 2021 6:19 pm

.. And frankly, why do we even have file_picker_callback in the init file? I mean, likely no user will ever touch this, but instead rely on the provided callbacks.
The file_picker_/filebrowser_callback was there since ever. But you are right, we have the "external filebrowser" systen config property to set another filebrowser in the editor.

I agree with you that managing JSON is much easier and safer as JS literals. The timing to change it to JSON wouldn't be better than yet. But I just wondered if there are other pitfalls which could make the change impossible.
It just remains the slightly different syntax than tiny.cloud propagates.
And btw, trailing commas wouldn't be possible.
Should we do a voting on GitHub?

cmb
Posts: 13592
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Use trailing commas in the editor inits

Post by cmb » Tue Mar 02, 2021 10:06 pm

manu wrote:
Tue Mar 02, 2021 8:56 am
Should we do a voting on GitHub?
I think an informal poll there makes sense, but IMO the final decision should be made by you, since you're maintaining the plugin. As for me, it's years ago since I worked with the TinyMCE 4 inits, and I barely have looked into TinyMCE 5 at all.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply