Drag'n'Drop and Paste detection with contentEditable or designMode enabled

Do any of you know a cross-browser way to detect drag'n'drop inserts or inserts in an editable html document (with designMode or contentEditable enabled).

Paste detection works as long as the user uses the Ctrl-V key combination because it generates key events, but if you use Edit-> Paste browsers, no events are generated.

+3
source share
2 answers

There is an event pastethat works for all pastes (including through the context menu or the editing menu) in an editable document, in Firefox since version 3.0, WebKit for several years (not sure about the version number), and IE since version 5.5. Adding an event handler pasteto the body element works in all of these browsers.

I’m afraid that I don’t have information about drag and drop events: in the editors I worked on, I had good reasons to explicitly disable drag and drop.

+1
source

To handle drag'n'drop, you can subscribe to the mouseUp event. But in this case, you need to parse the already inserted html.

0
source

Source: https://habr.com/ru/post/1732704/


All Articles