I have several plugins that open in new dialog windows; because I require the 'application/xhtml+xml' mime type, I cannot use the built-in fckeditor dialog support. Previously, my dialogs were working fine, and the content they inserted into the editor appeared at the correct location.
With the 2.6.3 release, however, I've noticed that the content is always inserted at the beginning of the editor, no matter where the cursor is positioned when I invoke the dialog. This happens on every browser (IE, FF, etc.) on every operation system. The dialog does contain a form, and when a user enters information in this form, the original editor loses focus.
Here's a snippet of how I set up the editor (cribbed from the dialog tutorial):
When a button is clicked in my dialog, the following snippet is executed:
Like I said, this used to work correctly. Has something changed recently, or alternatively, am I invoking the FCKEditor API incorrectly? Should I be doing something else to ensure that I preserve the cursor position? I'd appreciate any help!
With the 2.6.3 release, however, I've noticed that the content is always inserted at the beginning of the editor, no matter where the cursor is positioned when I invoke the dialog. This happens on every browser (IE, FF, etc.) on every operation system. The dialog does contain a form, and when a user enters information in this form, the original editor loses focus.
Here's a snippet of how I set up the editor (cribbed from the dialog tutorial):
var EquationEditorCommand=function(){}; EquationEditorCommand.prototype.Execute=function(){} EquationEditorCommand.GetState=function() { return FCK_TRISTATE_OFF; } EquationEditorCommand.Execute=function() { var url = '/ia/secure/popup/equation.action?fieldName=' + window.FCK.Name; // note: showPopUp creates an inline div, not a new browser window parent.showPopUp(url,500,358); } FCKCommands.RegisterCommand('Equation_Editor',EquationEditorCommand); var oEquationEditorItem = new FCKToolbarButton('Equation_Editor', 'Enter a MathML Equation'); oEquationEditorItem.IconPath = FCKConfig.PluginsPath + 'equation/equation_icon.gif' ; FCKToolbarItems.RegisterItem( 'Equation_Editor', oEquationEditorItem ) ;
When a button is clicked in my dialog, the following snippet is executed:
var FCK = FCKeditorAPI.GetInstance(fieldName); var imageName = form.elements['embeddedImage.name'].value.split("&").join("&").split("<").join("<").split(">").join(">"); FCK.InsertHtml('<img alt="image ' + imageID + '" id="' + imageID + '" src="/ia/image/' + imageID + '"/>'); hidePopUp();
Like I said, this used to work correctly. Has something changed recently, or alternatively, am I invoking the FCKEditor API incorrectly? Should I be doing something else to ensure that I preserve the cursor position? I'd appreciate any help!
Re: FCK.InsertHtml() loses cursor position
Now that I have found my answer I thought I would reply and update for others with the same issue.
This seems to be a symptom of not including the following in the HEAD of the HTML -
Remember that src="../../fckeditor/fckeditor.js" needs to be the proper relative path to fckeditor's javascript file.
Hope this helps!
Christopher
Re: FCK.InsertHtml() loses cursor position
I am not sure I understand. I already have that line in my HTML file because that's the only way to get the editor to work at all -- the difference being that it was an absolute path, and not a relative path. Just for grins I changed it to the proper relative path, but I still had the same issue.
Am I missing something obvious here? Don't you have to have some form of that statement for the editor to work in the first place? I don't see how that would address an issue with InsertHTML().
Re: FCK.InsertHtml() loses cursor position
did you ever get a fix for this. I have a similar issue, put sa button on the page with an onclick event

<input type="button" value="Add Text" onClick="FCKeditor1___Frame.FCK.InsertHtml('soem text')";
Works fine if I highlight an area in the text editor before the button is clicked, otherwise all it does is to return focus back to the iframe.
Any ideas?
Re: FCK.InsertHtml() loses cursor position