Hi everyone it is my first post on this board, I searched for this but was not able to find the answer.
I created a plugin for my site that loads a modal and inside that modal it displays all of that users images. From this point I want to bind a function to clicking that image that would insert the html into the current ckeditor instance. With TinyMCE I bind the following coffee script function
For CKEditor I thought it would be something like the following, but it didn't work...
Not sure how I access the CKEDITOR instance to inject that HTML. Any suggestions? Let me paste my plugin code below:
I created a plugin for my site that loads a modal and inside that modal it displays all of that users images. From this point I want to bind a function to clicking that image that would insert the html into the current ckeditor instance. With TinyMCE I bind the following coffee script function
insertImageIntoTinyMCE: (image) -> tinyMCE.execCommand('mceInsertContent',false,image)
For CKEditor I thought it would be something like the following, but it didn't work...
insertImageIntoCKEDITOR: (image) -> CKEDITOR.execCommand('insertHtml',image)
Not sure how I access the CKEDITOR instance to inject that HTML. Any suggestions? Let me paste my plugin code below:
CKEDITOR.plugins.add('images', { init: function(editor) { var $mediaBrowser; $mediaBrowser = $("<div><div class='loading-dialog' style='width:inherit; height:inherit'></div></div>").dialog({ title: 'Insert Image', modal: true, autoOpen: false, height: 400, width: 600 }); editor.addCommand('insertImage', { exec : function(editor) { $mediaBrowser.dialog("open"); $mediaBrowser.load("/documents/get_images_ckeditor"); } }); editor.ui.addButton('Image', { label : 'Insert Image', command : 'insertImage', icon : '/images/application/icon_16_picture.png' }); } });
Re: insertHTML from outside plugin
insertImageIntoCKEDITOR: (image) ->
CKEDITOR.instances.body.insertHtml(image);
body being my CKEDITOR.currentInstance.name