helloflask / flask-ckeditor

CKEditor integration for Flask, including image upload, code syntax highlight, and more.
https://flask-ckeditor.readthedocs.io
MIT License
200 stars 67 forks source link

Can't set custom configuration from main config options #40

Closed stevedunford closed 3 years ago

stevedunford commented 4 years ago

Hi, I use this a lot in one of my major projects (thankyou!), both for custom Flask-WTF forms and in flask-admin with no huge problems, except one - I need the SCAYT spell checker turned on by default. I can do this for my custom forms in the flask app using the custom config option:

{{ ckeditor.config(custom_config : "scayt_autoStartup = true'") }}

But that doesn't work with flask-admin forms, so I've had to do some ugly hacking about to make it work.

Anything in the main config options do work with flask-admin forms though, so if there was another option available (CKEDITOR_CUSTOM_CONFIG ?) then little tweaks like this could be done easily. Is this something that could be added or would this open a 'can of worms'?

One last important thing: Thanks for all your hard work with flask-ckeditor, I love how easy it makes using a WYSIWYG editor in Flask.

remyzandwijk commented 4 years ago

Hi Steve,

According to the docs: “Keep it mind that the proper syntax for each option is configuration name : configuration value.”.

It is worth a try using a colon in stead of an equal sign.

stevedunford commented 4 years ago

Thanks, I've fixed my typo above now... but that isn't the problem - the problem is that making custom configuration changes that way does not apply on flask-admin forms. The custom changes need to be made in the global config for it to apply to flask-admin forms, so that is what I'm hoping can be added.

remyzandwijk commented 4 years ago

Understood. It was a long shot, I know. Let’s wait what @greyli has to say about this.

greyli commented 4 years ago

I'm not sure I totally understood your question. To make the configuration work on Flask-Admin and Flask-WTF, you have to pass the target form field name like this:

{{ ckeditor.config(name='form_field_name') }}

In your case, it will be:

{{ ckeditor.config(name='text', custom_config : "scayt_autoStartup = true'") }}

Sorry for not address this in the documentation, I will update then.

stevedunford commented 4 years ago

Hi, thanks I'll test this and reply later - but I think I tried this and it did not work.

greyli commented 3 years ago

Closing it now for inactive, please feel free to reopen or comment.