Thanks for writing FCKeditor -- I'm finding it very useful, and am very impressed by how easy it is to write a plugin.
Question. I create an editor like this:
<!--
oFCKeditor = new FCKeditor( '$!webwork.htmlEncode($parameters.name)' ) ;
oFCKeditor.BasePath = '$req.contextPath/includes/js/' ;
oFCKeditor.Value = '$action.wysiwygContent ' ;
oFCKeditor.Width = '100%';
oFCKeditor.Height = '$height';
oFCKeditor.Config['EditorAreaCSS'] = '$req.contextPath/styles/main-action.css?spaceKey=$spaceKey&forWysiwyg=true';
oFCKeditor.Config['PageId'] = '$pageId';
oFCKeditor.Config['SpaceKey'] = '$spaceKey';
oFCKeditor.Config['FormName'] = '$parameters.formname';
oFCKeditor.Config['FieldName'] = '$parameters.id';
oFCKeditor.Config['Context'] = '$req.contextPath';
oFCKeditor.Create();
if (document.forms['${parameters.formname}'].originalContent != undefined)
{
document.forms['${parameters.formname}'].originalContent.value = oFCKeditor.Value;
}
//-->
(the '$' characters are part of a velocity template)
This works fine, except that I later compare the original content saved here with the xhtml contents of the editor, using:
var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName );
newContent = oEditor.GetXHTML(false);
Unfortunately, the GetXHTML method has reordered the attributes of the HTML elements, so a simple string compare of originalContent and newContent doesn't match, even when they are really the same.
What I'd like to do is to call GetXHTML immediately after Create(), but I can't figure out how to get FCKEditorAPI in scope at that point.
Any advice?
Thanks,
Tom
Question. I create an editor like this:
<!--
oFCKeditor = new FCKeditor( '$!webwork.htmlEncode($parameters.name)' ) ;
oFCKeditor.BasePath = '$req.contextPath/includes/js/' ;
oFCKeditor.Value = '$action.wysiwygContent ' ;
oFCKeditor.Width = '100%';
oFCKeditor.Height = '$height';
oFCKeditor.Config['EditorAreaCSS'] = '$req.contextPath/styles/main-action.css?spaceKey=$spaceKey&forWysiwyg=true';
oFCKeditor.Config['PageId'] = '$pageId';
oFCKeditor.Config['SpaceKey'] = '$spaceKey';
oFCKeditor.Config['FormName'] = '$parameters.formname';
oFCKeditor.Config['FieldName'] = '$parameters.id';
oFCKeditor.Config['Context'] = '$req.contextPath';
oFCKeditor.Create();
if (document.forms['${parameters.formname}'].originalContent != undefined)
{
document.forms['${parameters.formname}'].originalContent.value = oFCKeditor.Value;
}
//-->
(the '$' characters are part of a velocity template)
This works fine, except that I later compare the original content saved here with the xhtml contents of the editor, using:
var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName );
newContent = oEditor.GetXHTML(false);
Unfortunately, the GetXHTML method has reordered the attributes of the HTML elements, so a simple string compare of originalContent and newContent doesn't match, even when they are really the same.
What I'd like to do is to call GetXHTML immediately after Create(), but I can't figure out how to get FCKEditorAPI in scope at that point.
Any advice?
Thanks,
Tom
RE: Using FCKEditorAPI in create script
Your solution will then look something like:
var FCKEApi;
var OriginalContents;
function FCKeditor_OnComplete( editorInstance ) {
FCKEApi = editorInstance;
OriginalContents = FCKEApi.GetXHTML(true);
}
function isDirty() {
return (FCKEApi.GetXHTML(true) != OriginalContents);
}
Not very neat, but workable. Hope that helps.