Hi again,
My plugin is breaking my editor's output - the editor literally doesn't show. For some reason, as soon as I comment the addCommand section in my plugin's js file it all works fine, except the buttons don't do anything.
Here's the code:
// Keep cache clean with constantly changing timestamp CKEDITOR.timestamp = (new Date()).valueOf(); // --- PLUGIN CODE // Add plugin CKEDITOR.plugins.add("encryptstring", { // initialise function init: function(editor) { // Plugin name var pluginName = "En/De-crypt strings"; // Add main js file CKEDITOR.dialog.add(pluginName, this.path + "encryptstring/plugin.js"); // Add dialog functions editor.addCommand(encrypt, {exec:encryptDialogFunc}); // - These two lines commented editor.addCommand(decrypt, {exec:decryptDialogFunc}); // - makes the buttons (and editor) show properly... // Add buttons editor.ui.addButton("encryptstring", { label: "Create encrypted string", command: encrypt, icon: this.path + "lock.png" }); editor.ui.addButton("decryptstring", { label: "Decrypt encrypted string", command: decrypt, icon: this.path + "unlock.png" }); } });
Am I doing something wrong? By the way, the functions the commands are running 'encryptDialogFunc' etc. are created in another file, which is already on the page. (can be run from console)
There are no encrypt and
There are no encrypt and decrypt variables declared in your code, but you're trying to use them in editor.ui.addButton. The command property of button defition accepts strings - e.g. 'decrypt'.
BTW. Next time check the JS console.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Thanks for that. I made the
Thanks for that. I made the addCommand's first argument a string, and it worked.
Nothing was showing up on the JS console, so I couldn't see what was happening...
Ah, right. I haven't noticed
Ah, right. I haven't noticed that you used that encrypt variable even there. So yes - nothing was logged on the console. However, you can avoid this silent failure using strict mode. It's very simple. See e.g.: https://developer.mozilla.org/en/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Okay thanks.
Okay thanks.