Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
2.5k views
in Q2A Core by
edited by
There is a line in qa-wysiwyg.php which reads:

                // Prevent config file being loaded
                 "    customConfig: ''",
                "};",

and it prevents config.js from being loaded. Why?

What sould we do if we wanted to add our own ckeditor plugin?
Q2A version: qa 1.7

2 Answers

+1 vote
by
selected by
 
Best answer

Just add the needed code before the closing curly bracket (note the additional comma in the customConfig line). EG:

// Prevent config file being loaded
"    customConfig: '',",
"    extraPlugins: 'custom-plugin1,custom-plugin2'",
"};",
 
You do need the code inline to make it dynamic (using PHP). However, that is no reason to disallow the config.js, anyway. The only thing I can think of to disallow adding that file is to save an HTTP request (the one that fetches it).

 

by
That's right, I dont know what the reason was to prevent config.js as for setting like config.disableNativeSpellChecker = false; we need to load config.js
by
But you don't actually "need" that file anyway. You can add any configuration exactly how I showed you in the answer. It is the same as the config.js but with a slightly different syntax
by
Again config.js is a place i know to run some js code after the ckeditor is loaded.
But that aside please conduct this simple test in your copy of qa1.7. goto http://ckeditor.com/builderand download the full version (as opposed to standard one), you will see the wysiwyg you get looks still exactly the same perhaps because the toolbar arrangement is actually set inside the php code! I for one have a customized plugin that someone wrote for me to be used with ckEditor for multiple image upload. when he was developing the plugin he used the stable version qa1.63 but now his ckeditor plugin won't work with qa1.7 and cannot be set up the way it is recommended in ckeditor documentation. but anyways i just wanted to share my thoughts on this, otherwise i am thinking to siwth back to the wywsiwyg plugin of qa1.63. -thanks for reading ;)
by
Hey! I just got it to work! that was it as well as adding the "extraPlugins" command as you mentioned above I also had to add the name of the button to
 // The toolbar arrangement line 129
Thanks ;)
0 votes
by

There are a few issues at play here. Firstly, the CKeditor builds from the official site all have the config.js file with some default stuff in it, which means for anyone using a custom build they will get that default file and may override stuff they don't want.

A similar thing applies to updating Q2A as well - if we provide a default (blank) config.js it might get overwritten each time you update. Of course that applies if you modify the config in qa-wysiwyg-editor.php too.

The extra HTTP request for the file is a minor issue. So because some parts of the config are required to be in the PHP (the language and upload paths) I felt it was best to just skip the config.js file altogether.

I think you're right, allowing users to use the JS file would be easier. So maybe we can allow the config.js file to load regardless. We can start with a blank file (or better yet, move the non-PHP stuff from qa-qysiwyg-editor.php to config.js). This does mean that for any custom builds or when Q2A is updated, you'll need to redo your changes.

Alternative: I just checked and if there is no config.js file the editor does still load (I think in the old CKE it broke the editor). So we could provide no config.js and let users add one if they need custom config. This is better when updating Q2A since you won't overwrite your config, but you still have the same issue with custom builds, and you constantly get 404s if you don't have the file. I don't think this is a great solution.

by
@Waterfr I have updated the Github repo with some changes that should fix this issue. Most of the config has been moved to the config.js file. So you can now add your own config and JS code in there.

Can you take a look and check it all works good for you?
by
Thank you so much Scott,
I will test it and let you know
by
Hi Scott
Sorry for not getting back to you yet, but I will test it and let you know in 12 hours.
by
@Scott,
I just completed testing it.

Worked like a charm! Thank you

I am glad that you moved the buttons to the config.js to. Its great that you pay attention to details
...