Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Download working plugin: <a href="https://docs.google.com/file/d/0B0dQ8h7Cze23cUJGb2dJM1h2LWM/edit?pli=1" rel="noreferrer">https://docs.google.com/file/d/0B0dQ8h7Cze23cUJGb2dJM1h2LWM/edit?pli=1</a></p> </blockquote> <p><em>This plugin uses jquery but you could easily rewrite it using pure javascript! Be sure you included jquery to your pages before including ckeditor</em> </p> <p><strong>first register the plugin in the config.js file</strong> (just add these lines at the end of your config.js file)</p> <pre><code>config.extraPlugins = 'savebtn';//savebtn is the plugin's name config.saveSubmitURL = 'http://server/link/to/post/';//link to serverside script to handle the post </code></pre> <p><strong>Now we are ready to add the plugin to ckeditor. Download the plugin (see google drive download link above) and extract the zip file in your ckeditors plugin folder.</strong> (the download contains the scripts below together with the used icons)</p> <p>That's it. The plugin should work now! </p> <blockquote> <p>For reference I included the source (plugin.js) at the bottom of this answer. I suggest you read the comments if you don't know what's going on. The comments in the code from this answer differs slightly from the comments in the actual plugin file. Most up to date comments can be found here. The business logic is exactly the same. </p> </blockquote> <p>plugin.js</p> <pre><code>CKEDITOR.plugins.add( 'savebtn', { icons: 'savebtn', init: function( editor ) { //add a new command to the editor. //We give the command a name 'savecontent', //so we can reference it later. editor.addCommand( 'savecontent', { //this is the business logic of our 'savecontent' command. //this function gets executed when clicking the button. //you can change/replace the logic of this function //according to your own needs. exec : function(editor){ //get the text from ckeditor you want to save var data = editor.getData(); //get the current url (optional) var page = document.URL; //path to the ajaxloader gif loading_icon=CKEDITOR.basePath+'plugins/savebtn/icons/loader.gif'; //css style for setting the standard save icon. //We need this when the request is completed. normal_icon=$('.cke_button__savebtn_icon').css('background-image'); //replace the standard save icon with the ajaxloader icon. //We do this with css. $('.cke_button__savebtn_icon').css("background-image", "url("+loading_icon+")"); //Now we are ready to post to the server... $.ajax({ url: editor.config.saveSubmitURL,//the url to post at... configured in config.js type: 'POST', data: {text: data, id: editor.name, page: page},//editor.name contains the id of the current editable html tag }) .done(function(response) { console.log("success"); alert('id: '+editor.name+' \nurl: '+page+' \ntext: '+data); }) .fail(function() { console.log("error"); }) .always(function() { console.log("complete"); //set the button icon back to the original $('.cke_button__savebtn_icon').css("background-image", normal_icon); }); } }); //add the save button to the toolbar. Mind that we declare command: 'savecontent'. //This way ckeditor knows what to do when clicking the button. editor.ui.addButton( 'savebtn', { label: 'Save', command: 'savecontent' // toolbar: 'insert' }); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload