Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML 5 drag-drop into wysiwyg editor in Firefox

I have a wysiwyg editor using the HTML 5 drag-drop api to allow the user to place widgets within the page they are editing. When the OnDrop event fires, I prevent the default event, and insert some html within the editor that represents the widget they inserted. I use execCommand("inserthtml", false, html) for this in Firefox.

This works fine in IE, but in Firefox the html is not placed in the location where it was dropped. It always gets placed in the location where the previous selection was, which leads me to believe that cancelling the OnDrop event to override the default drop also cancels the selection change.

Any ideas on how to solve this?

Thanks!

like image 390
einarq Avatar asked Jan 27 '10 21:01

einarq


1 Answers

I hate these kinds of answers, but I have to say, jQuery UI's drag & drop event structure is pretty straightforward. It would allow you to track the objects you're using and append the html you're talking about quickly.

If you aren't familiar with it, I think it's an excellent option for the type of system you're talking about.

like image 159
Trafalmadorian Avatar answered Oct 02 '22 00:10

Trafalmadorian