Opened 7 years ago

Closed 5 years ago

#5989 closed New Feature (wontfix)

Serverside preview

Reported by: Matti Järvinen Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:


Since I'm so impatient and vladfr has not posted this in here yet.

By vladfr

* File Name: serverpreview\plugin.js
* Licensed under the terms of the GNU Lesser General Public License:
*    Plugin for CKeditor 3 to send the current data to the server so it can be previewed in a custom way
*   Extended from the FCK plugin with the same name, by Alfonso Martínez de Lizarrondo
*  version
*      0.1 15/02/2006
*      0.2 02/09/2007 Replace the 'Preview' command instead of creating a custom one.
*      0.3 14/07/2010 No longer replaces the Preview button, adds another one instead.      
* File Author:
*       Vlad Fratila
* == How to Use: ==
* Add the plugin in your config.js like other plugins:
*    config.extraPlugins = 'serverpreview';
* You will also need to specify the full URL of your server-side script like this:
*      config.serverPreviewURL = '';
* In this file, you need to stripslashes and display the post variable "htmlData"
* To get an icon for the button, you will need to change your skin's CSS file
* (e.g. if you're using the default: change /ckeditor/skins/kama/editor.css)
* I just disabled the Preview plugin and did a Search/Replace to replace 'preview' with 'serverpreview'.
*  Lastly, don't forget to add the button 'ServerPreview' to your toolbars!

   var pluginName = 'serverpreview';

   var serverpreviewCmd =
      modes : { wysiwyg:1, source:1 },
      canUndo : false,
      exec : function( editor )
         var theForm = document.getElementById('serverPreviewForm') ;
         if (!theForm) {
            //it doesn't exist still, we create it here
            theForm = document.createElement('FORM') ;
            theForm.method = 'POST' ;
   = 'serverPreviewForm' ;
   = 'none' ;

            theForm.action = editor.config.serverPreviewURL;

            //new window please
            document.body.appendChild( theForm );

         //clear previous data
         theForm.innerHTML = '' ;
         //set the new content
         var input = document.createElement('INPUT') ;
         input.type = 'hidden';
         //change the name as needed --> = 'htmlData' ;
         //set the data
         input.value = editor.getData();
         //append the new input to the form
         theForm.appendChild( input );

         //that's all, append additional fields as needed, or set the variables in the previewPath

         //send the data to the server
   CKEDITOR.plugins.add( pluginName,
      init : function( editor )
         editor.addCommand( pluginName, serverpreviewCmd );
         editor.ui.addButton( 'ServerPreview',
               label : 'Server Preview',
               command : pluginName

Change History (4)

comment:1 Changed 7 years ago by Alfonso Martínez de Lizarrondo

Milestone: CKEditor 3.x

I would not add this to the core.

With this plugin it's too easy to create a XSS bug, that's too serious and enough to not add it without due care.

Second, as I learned when I created the first version people will request further adjustments, how to send other data (because as soon as it's in the core you can't say "edit that line")...

It's a useful plugin, but not something required at the core.

comment:2 Changed 7 years ago by Matti Järvinen

Hmm... should we have a concentrated plugin repository where people could add their own plugins? Since these things end up being buried in forums or scattered around the internet so that no-one will ever find them.

Something like jQuery plugins site or ?

comment:3 in reply to:  2 Changed 7 years ago by Frederico Caldeira Knabben

Replying to matti:

should we have a concentrated plugin repository

We're in fact working on this. Stay in touch ;)

comment:4 Changed 5 years ago by Jakub Ś

Resolution: wontfix
Status: newclosed

@Matti as you probably already know plugins forum exists - and there is even “serverside preview” plugin available there:

Since such plugin, as you have described, will never be implemented in core version of CKEditor I'm closing this ticket as wontfix.

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy