Opened 14 years ago

Closed 13 years ago

#5989 closed New Feature (wontfix)

Serverside preview

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

Description

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

By vladfr http://cksource.com/forums/viewtopic.php?p=49442#p49442

/**
* File Name: serverpreview\plugin.js
*
* Licensed under the terms of the GNU Lesser General Public License:
*       http://www.opensource.org/licenses/lgpl-license.php
*
*    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
*       vlad.fratila@gmail.com
*
* == 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 = 'http://www.mydomain.com/myfile.php';
* 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!
*
*/


(function(){
   
   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' ;
            theForm.name = 'serverPreviewForm' ;
            theForm.id=theForm.name ;
            theForm.style.display = 'none' ;

            theForm.action = editor.config.serverPreviewURL;

            //new window please
            theForm.target='_blank';
            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 -->
         input.name = '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
         theForm.submit();
      }
   }
   
   
   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 14 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 14 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 http://plugins.jquery.com/ or http://scripteka.com ?

comment:3 in reply to:  2 Changed 14 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 13 years ago by Jakub Ś

Resolution: wontfix
Status: newclosed

@Matti as you probably already know plugins forum exists - http://cksource.com/forums/viewforum.php?f=17 and there is even “serverside preview” plugin available there: http://cksource.com/forums/viewtopic.php?f=18&t=23604

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 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy