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);
};
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):
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
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.
/// <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;
// 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.
//these are my editables
var es=
{
'1':editable1,
'2':editable2,
'3':editable3,
'4':editable4,
'5':editable5
}
$.each(es, function(k,v){
//when I focus on an editable, I can see which one is "active"
v.on('focus', function( evt ){
console.log('focused #' + k);
});
//after autoSave fires, I see that the wrong editable is submitted
v.on( 'afterAutosave', function( evt ){
console.log('autosaved #' + k);
});
});
I think a work-around here would be to make onBlur autoSave the last-focused editable. How do I run the "autosave" command and indicate a specific editable?
I haven't been looking at this post for quite a while.
This plugin doesn't work with CKE 4.x version. Itr was designed only for CKEditor 3.x.
Perhaps it wouldn't be such a bad idea to create new version for CKE 4.x but this will happen in few months at the earliest because I have lots of work here in CKSource. Thanks for the posts - it makes me think now that this plugin should be recreated.
I am also having problems when switching back from Source mode. It is a shame this plugin no longer works as it could be really useful. I wonder how simple the fix is?
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:
in var G you must add editable.editor like so:
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:
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
It is this line
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 undefinedPleas 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
or, in the minified version
I found that needs to be altered to
or (minified)
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:
Could use some help
"Source" does not revert back
I also have this problem of Source not reverting back.
Multiple Editor instances
Thx 4 your great plugin. But how can i use it for multiple editor instances on one site?
Im replacing textareas with:
and:
Every instance has another textarea_name, but how can i set the editor.name after that? I didnt
understand this. :-(
Multiple inlines - not auto submitting focused
Hi, I'm using HyShai's fix for inline and it works well, except:
After editing an inline block (let's call it inline#2 on the page) and removing focus, the autosave function auto-submits inline#1.
Seems to me it would be good to autosave onBlur or to use the latest editor as the autosave target?
Any thoughts?
Multiple inlines - not auto submitting focused
I ran this code in FireBug:
I think a work-around here would be to make onBlur autoSave the last-focused editable. How do I run the "autosave" command and indicate a specific editable?
Thank you for the great work here!
Hi,
Hi,
I haven't been looking at this post for quite a while.
This plugin doesn't work with CKE 4.x version. Itr was designed only for CKEditor 3.x.
Perhaps it wouldn't be such a bad idea to create new version for CKE 4.x but this will happen in few months at the earliest because I have lots of work here in CKSource. Thanks for the posts - it makes me think now that this plugin should be recreated.
Regards,
Jakub Świderski
I am also having problems
I am also having problems when switching back from Source mode. It is a shame this plugin no longer works as it could be really useful. I wonder how simple the fix is?
Tim