Hi i would like to know this too, as i'm trying to find a way to prevent editor users delete objects/tables/images with the delete/backspace keystroke. For start - i need to know how to get selected html text and the text before/after the cursor. thank you
FCK.EditorDocument.selection wouldn't return a selection object inside the editing document, but rather the selection object inside the floating dialog iframe. This is an IE bug in which it is limited to having only one selection per browser window, and that it can return a selection object from another iframe document even though you asked for document.selection. We've included an updated API in FCKeditor 2.6 to workaround this problem. Try to use FCKSelection.GetSelection() in place of FCK.EditorDocument.selection - it should always give you the selection object inside the editing iframe.
var selection = "";
if(oEditor.FCK.EditorDocument.selection != null) {
selection = oEditor.FCK.EditorDocument.selection.createRange().text;
} else {
selection = oEditor.FCK.EditorWindow.getSelection(); // after this, won't be a string
selection = "" + selection; // now a string again
}
Please forgive me if I am missing the point of this discussion thread. I am relatively new to FCKeditor.
There is some sample code for creating a non-dialog plugin over a Source Forge. It works - but only in IE. The problem in Safari and FireFox is the line containing the .createRange() method. The JS console says the method doesn't exist. This is the code. Is there an easy way to generalize this so it works in Safari and FireFox as well?
I haven't dug into this much, but you'll see from my previous post that createRange() is in an if statement. I'm pretty sure you need to do the same. That part of the code is called in IE, but you need an else for Firefox/Safari that contains other code.
I haven't dug into this much, but you'll see from my previous post that createRange() is in an if statement. I'm pretty sure you need to do the same. That part of the code is called in IE, but you need an else for Firefox/Safari that contains other code.
Good luck.
It turns out if you just make sure that the "range" related statements just get used in IE and make sure they aren't executed in Firefox/Safari (no substitutions with other methods) it seems to work just fine.
Re: [New plugin] how to get HTML selected text ?
I'm a begginer, i don't know if it's the answer, it works for me ...
Re: [New plugin] how to get HTML selected text ?
Re: [New plugin] how to get HTML selected text ?
Re: [New plugin] how to get HTML selected text ?
Hi i would like to know this too, as i'm trying to find a way to prevent editor users delete objects/tables/images with the delete/backspace keystroke.
For start - i need to know how to get selected html text and the text before/after the cursor.
thank you
Re: [New plugin] how to get HTML selected text ?
I noticed that is not working anymore in FCKeditor 2.6RC (and also in the 2.6 beta).
In IE you have to use this function to retreive the selected text.
In the current stable release 2.5.1 the function is working like a sharm!
Firefox users can use: and that is still working in 2.6RC!
I hope it will be fixed in the upcoming release of this great editor!
Re: [New plugin] how to get HTML selected text ?
According to the comment on ticket #2071:
So the code to will work now!
Re: [New plugin] how to get HTML selected text ?
Re: [New plugin] how to get HTML selected text ?
But it works great now. Excellent!
Re: [New plugin] how to get HTML selected text ?
Re: [New plugin] how to get HTML selected text ?
There is some sample code for creating a non-dialog plugin over a Source Forge. It works - but only in IE. The problem in Safari and FireFox is the line containing the .createRange() method. The JS console says the method doesn't exist. This is the code. Is there an easy way to generalize this so it works in Safari and FireFox as well?
Thanks!
doug
Re: [New plugin] how to get HTML selected text ?
I haven't dug into this much, but you'll see from my previous post that createRange() is in an if statement. I'm pretty sure you need to do the same. That part of the code is called in IE, but you need an else for Firefox/Safari that contains other code.
Good luck.
Re: [New plugin] how to get HTML selected text ?
It turns out if you just make sure that the "range" related statements just get used in IE and make sure they aren't executed in Firefox/Safari (no substitutions with other methods) it seems to work just fine.
doug
Re: [New plugin] how to get HTML selected text ?
Thanks a lot, but this doesn't work in IE7 either. I always get an empty string in IE7.
Re: [New plugin] how to get HTML selected text ?
I'm also in the case :
FCKSelection.GetSelection().createRange().text
doesn't work with IE 6 & 7
I'm using FCKEditor 2.6.4
I'm trying to use the plugin Abbr. It's OK with FF, but IE refuse to get the selection :
when i trace FCKSelection.GetSelection().createRange().text, it's empty
After reading diffeent topics, it seems that new revision bring bugs that werent there
Anyone got this plugin working with FCK 2.6.4 and IE
thanks
Re: [New plugin] how to get HTML selected text ?
Try this to get the content of the selection on IE 7:
var selection = oEditor.FCK.Selection.GetSelection().createRange().text;