Log in or register to post comments
Last post
<< < 1 2
Bug with new CKEditor inline editing

There's an 1ssue using the autosave plugin and the new Inline Editing (CKEditor v4) together. This function doesn't account for inline editing:

function t(D, E, F) {
		var G = CKEDITOR.document.getById(D._.commands.autosave.uiItems[0]._.id);
		G.getFirst().setStyle('background-image', 'url(' + D.plugins.autosave.path + E + ')');
		G.setAttribute('title', F);
		G.getChild(1).setHtml(F);
	};

in var G you must add editable.editor like so:

function t(D, E, F) {
		var G =    CKEDITOR.document.getById(D._.editable.editor.commands.autosave.uiItems[0]._.id);

		G.getFirst().setStyle('background-image', 'url(' + D.plugins.autosave.path + E + ')');
		G.setAttribute('title', F);
		G.getChild(1).setHtml(F);
	};

Thanks

update some div on page which contains editor

Hi, 
I managed to get the plugin working relatively quick. To hide the icons I've used: 

.cke_button_autosave{
    visibility: hidden;
}

 and I would like to use my own message div because of a consistent behavior of the app.

How is it possible to do something like:  $("#autosaveMsg").toggle(); in the autosaveChangeIcon function?

 

Error using it

Hey,

Could any1 help me or tell me where the problem might be. I try to use this autosave plugin, but whenever i hit save, I get javascript error

Uncaught TypeError: Cannot read property 'autosave' of undefined plugin.js:515

It is this line

var autosaveButton = CKEDITOR.document.getById( editor._.commands.autosave.uiItems[0]._.id );

 

Fix

aah nvm, great thnx to HyShai. Your fix worked.

Autosave conflict Text/Background color selector

Hello, I try this plugin and have two problem:

First (solwed) the downloadable 1.0.2 plugin muss modifie plugin.js to:

function t(D,E,F){var G=CKEDITOR.document.getById(D._.editable.editor.commands.autosave.uiItems[0]._.id);G.getFirst().setStyle('background-image','url('+D.plugins.autosave.path+E+')');G.setAttribute('title',F);G.getChild(1).setHtml(F);};

Second (current): After install this plugin, the text/background color selector Fault. Error (Firebug):

TypeError: this.attributes is undefined
...,styles:{display:"none"}}));b&&CKEDITOR.tools.extend(this,b);this.attributes.tit...
ckeditor.js (546. sor

 Pleas Help me solwe this problem!

Whenn off the plugin, color selectro currently functional again.

CKEditor 4.1 inline editing language problem

I've installed the autosave plugin with CKEditor 4.1 and used HyShai's fix for the inline editing.  Everything works fine except the plugin's language file is not being used.  The button tooltip displays {title} initially and then undefined.  Can anyone point me in the right direction to fix this?  TIA

Possible code error in 1.0.2

I've been using this superb plugin for some time with no problems, but today I decided to upgrade to the latest ckeditor and get the newest (1.0.2) plugin version.

The plugin now loaded and initialized as before, but failed to work, with the server-side ajax handler never being invoked and every keystroke throwing a javascript error in the autosaveChangeIcon( ) function.

In expanded form, the problem portion of the code reads

 

 var autosaveButton = CKEDITOR.document
		.getById( editor._.commands.autosave.uiItems[0]._.id );

or, in the minified version 

 var G=CKEDITOR.document.getById(D._.commands.autosave.uiItems[0]._.id);

I found that needs to be altered to  

editor.commands.autosave.uiItems 
 

or (minified)      

D.commands.autosave.uiItems;

after which everything works fine as before.

Not sure what's behind this, but if anyone else hits this problem with the current plugin release, it may help.

ASP.Net C# implementation

Hi here is my ASP.Net implementation based on PHP Connector.

Create the page AutoSaveCallBack_.aspx. Be careful, ValidateRequest must set to "false" (to accept non encoded html in post request).

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoSaveCallBack_.aspx.cs" Inherits="webservices_AutoSaveCallBack_" ValidateRequest="false" %>

the code behind :

using System;

/// <summary>
/// My implemention in ASP.Net C# is a translation of PHP Connector.
/// </summary>
public partial class webservices_AutoSaveCallBack_ : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // If you want to secure access to this page, you can pass 
        // additionnal parameters like userid via querystring.
        //
        // In my case, on the "edit" page, i drive CKEditor programmaticly in code-behind via C#. (I use the "dll-wrapper" CKEditor.Net 3.6.4 in my \Bin directory.) :
        // 
        // this.myEditor.ExtraPlugins = "autosave";
        // this.myEditor.config.ExtraOptions["autosaveTargetUrl"] = "'https://localhost/webservices/AutoSaveCallBack.aspx?id_user=<mylogin>'";
        // this.myEditor.config.ExtraOptions["autosaveRefreshTime"] = "'30'";

        // NOTE IMPORTANT :
        // If your "edit" page (ie, the page containing CKEditor) is accessed in "https", the autosaveTargetUrl must have the same
        // http scheme, so "https" too.

         this.SaveContent();
    }

    private bool SaveContent()
    {
        int id_rubrique = 0;
        string exceptionMessage = null;
        bool result = false;

        // Invalid requests
        if (String.IsNullOrEmpty(Request.Form["content"]) || String.IsNullOrEmpty(Request.Form["ckeditorname"]) || String.IsNullOrEmpty(Request.Form["autosaveaction"]))
        {
            this.SendResponse(400, null);
            return false;
        }

        if (!Request.Form["autosaveaction"].Equals("draft"))
        {
            this.SendResponse(400, null);
            return false;
        }

        if ((String.IsNullOrEmpty(Request.QueryString["id_rubrique"])) || (!int.TryParse(Request.QueryString["id_rubrique"], out id_rubrique)))
        {
            this.SendResponse(400, null);
            return false;
        }

        if (String.IsNullOrEmpty(Request.QueryString["id_rubrique"]))
        {
            this.SendResponse(400, null);
            return false;
        }

        // Save datas here...
        result = this.SaveContent(Request.Form["content"], out exceptionMessage);

        if (result)
        {
            this.SendResponse(200, null);
            return result;
        }

        this.SendResponse(403, null);
        return result;
    }

    /// <summary>
    /// Send the response to the ajax request initiated by CKEditor plugin.
    /// </summary>
    /// <param name="errorCode">http error code</param>
    /// <param name="errorMessage">custom exception message (optionnal)</param>
    protected void SendResponse(int errorCode, string errorMessage)
    {
        this.SendXmlHeaders();

        if (errorCode == 200)
        {
            Response.Write("<result status=\"ok\" />");
        }
        else
        {
            Response.Write("<error statuscode=\"" + errorCode + "\" ");

            if (!String.IsNullOrEmpty(errorMessage))
            {
                Response.Write("message=\"" + Server.HtmlEncode(errorMessage) + "\" ");
            }

            Response.Write("/>");
        }
    }

    /// <summary>
    /// Send the appropriate headers.
    /// </summary>
    protected void SendXmlHeaders()
    {
        string gmtDate = DateTime.Now.ToString("r");

        Response.Headers.Add("Expires", gmtDate);
        Response.Headers.Add("Last-Modified", "Mon, 26 Jul 1997 05:00:00 GMT");

        // HTTP/1.1
        Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        Response.AddHeader("Cache-Control", "post-check=0, pre-check=0");
        
        // HTTP/1.0
        Response.AddHeader("CPragma", "no-cache");

        // Set the response format.
        Response.AddHeader("Content-Type", "text/xml; charset=utf-8");
    }

    /// <summary>
    /// This is the function used to save user-data.
    /// </summary>
    /// <param name="content">html content provided by CKEditor</param>
    /// <param name="exceptionMessage">exception message if you want to have clear errors messages.</param>
    /// <returns>return true if operation succeeded.</returns>
    protected bool SaveContent(string content, out string exceptionMessage)
    {
        // Build you own persistence function to store
        // CKEditor content in database or filesystem.
        bool result = false;
        exceptionMessage = "";

        try
        {
            // Put your code here...
            result = true;
        }
        catch (Exception ex)
        {
            exceptionMessage = ex.Message;
            result = false;
        }

        return result;
    }

    /// <summary>
    /// Optionnal security function to check if user is allowed to call this page
    /// via ajax request by CKEditor Autosave plugin.
    /// </summary>
    /// <param name="userId"></param>
    /// <returns></returns>
    protected bool IsUserAllowed(string userId)
    {
        // Build your owncode here to check
        // if user is allowed to use this page.

        return false;
    }
}

 

Got it working, but now "Source" does not revert back

Hello,

I have gotten this script fully working (and made the two changes above by @HyShai and @mbeddow and all seemed to be good.

I then clicked on the "Source" button and it switched over to the view html source... but now it will not revert back to standard view mode.

Totally stuck on this.

Here is my config:

	config.language = 'en';
	config.toolbar = [
		[ 'Preview','Print', '-', 'Find', 'Replace', 'SelectAll'],
		[ 'Cut', 'Copy', 'Paste'],
		[ 'PasteText', 'PasteFromWord'],
		['Undo', 'Redo' ],
		[ 'Smiley','Maximize','Preview'],
		['Source'],['Autosave'],
		'/',
		[ 'Bold', 'Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ],
		[ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
		[ 'list', 'indent', 'blocks', 'align' ],
		[ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-'],
		[ 'Blockquote' ],
		[ 'Table', 'Image' ],
		[ 'Link', 'Unlink'],
	];
	
	// turn off stuff we are not using
	config.removePlugins = 'flash,iframe,scayt,elementspath';
	//
	config.extraPlugins = 'autosave,wordcount,smiley';
	config.autosaveTargetUrl = 'http://www.domain.com/autosaveto/index.php'; // bogus url of course

Could use some help 

"Source" does not revert back

I also have this problem of Source not reverting back.

<< < 1 2