I've been tearing my hair out over this with no luck.
I created a menubar for the editor....
When I try to insert something using the Javascript API, like a Horizontal Line, it inserts it on the first line of the editor instead of where the mouse was...
How can I make it so it inserts the html elements in where the text selection was in the editor?
Thanks.
Wed, 07/09/2008 - 00:12
#1
Re: Javascript API Insert Issue
You should use insertHtml http://docs.fckeditor.net/FCKeditor_2.x ... Script_API
Re: Javascript API Insert Issue
Re: Javascript API Insert Issue
Re: Javascript API Insert Issue
I'm am now trying to use something like FCKSelection.GetSelection().createRange().text with editorInstance.Events.AttachEvent( 'OnSelectionChange', updateSelection ) or ..OnBlur and ...OnFocus but I'm having trouble figuring out if there is a value like SelectionStart, SelectionEnd, or something along those lines with the GetSelection() function. I want to throw the position into a hidden field and then have the html inserted into that spot.
Any ideas?
Re: Javascript API Insert Issue
But
for example, if I have selected image and then you can refer to its src in this way
oh, wait you need to insert at cursor position.
Well, InsertHtml works perfectly in ff3. When I have a text input in a webpage with
it works. So their is something wrong with you browser or code.
Re: Javascript API Insert Issue
Please go to http://wolfcow.andrewtite.com/admin/editor8.html to see what I'm talking about.
If you use the toolbar everything works great.
If you use the menubar at the top (Insert, Format, ...), as soon as you click the menu I think the editing area is losing focus so it is entering the html codes to the top line.
I have my code I'm working on for every toolbar item except the Horizontal Line. I put your code above (InsertHtml...) for the Horizontal Line. If you try to insert that one you will see "boo" entered on the top line.
If I could save the position of the cursor before the editing area loses focus and then insert that html to that spot it would work. As soon as it loses focus and then gains it again, it enters it on the top line.
Re: Javascript API Insert Issue
If I insert some hidden html code such as <!--thisisthecursorposition--> when OnBlur is triggered, maybe I can search and replace <!--thisisthecursorposition--> with the html code I am trying to insert once OnFocus is triggered.
hmmmm
Re: Javascript API Insert Issue
I find it an interesting issue. I tried your editor, and everything works great in Firefox 3.
If you use IE 7, than you get your issue. I suggest to look at existing bug reports, or to create a new ticket.
Have a look here, it seems that IE has a bug in that in allows only one selection in window: viewtopic.php?f=6&t=8814.
Re: Javascript API Insert Issue
This is the current IE-code:
Re: Javascript API Insert Issue
Can I use some code from 2.6.1?
I am using version 2.6.2 Build 19417.
Re: Javascript API Insert Issue
I have no idea how you can fix this. The code regarding insertHtml did apparently not change between 2.6.1 and 2.6.2 It might be that a change elsewhere in 2.6.2 makes insertHtml to misbehave.
I advise you to test a 2.6.1 installation: http://sourceforge.net/project/showfile ... e_id=75845, as it has been claimed that this release fixes your problem.
Re: Javascript API Insert Issue
Hi all,
This is not a regression bug, but rather a long standing IE bug. Every IE window can contain at most one selection, no matter how many iframes you've opened inside it. So if you select something inside FCKeditor, and then click on a menu outside of FCKeditor, the selection positions inside FCKeditor would be lost and thus calling FCK.InsertHtml() would insert things into a default position (which is the beginning of the document body).
We've implemented a workaround for when floating dialogs need to call InsertHtml() but that workaround does not handle the generic case. I've posted a new workaround for the generic case in https://dev.fckeditor.net/ticket/2376. Note that you'll have to download the SVN code and apply the patch to see the effect, applying the patch to the released code package has no effect.
Re: Javascript API Insert Issue
applyed the patch to version 2.6.1 and it didn't resolve the problem
Re: Javascript API Insert Issue
Re: Javascript API Insert Issue
So I tried patching fckeditorcode_ie.js with the workaround and it didn't work. Is that what martinkou means when he says that applying the patch to the released code package has no effect? I don't see how else I would apply the patch.
Re: Javascript API Insert Issue
Well, he said you need the version that is currently in development. You can check it out via subversion, but you can grab a nighlty build here too:http://dev.fckeditor.net/wiki/SVN
Re: Javascript API Insert Issue
Problem still exsists:
Using: MW 1.13
Not working: IE 6.0/7.0
Working: FF 3.0/Opera 9.51
Installed extension from http://svn.fckeditor.net/MediaWiki/trunk
Installed the latest editor from http://sourceforge.net/project/showfile ... e_id=75845
Edited the js according to https://dev.fckeditor.net/ticket/2376
Have also tried to download the pack from SVN http://www.fckeditor.net/nightly/FCKeditor_N.tar.gz (seems like the patches are done on this one)
Still puts the image on the top.
Am i doing something wrong?