GwtMaterialDesign / gwt-material-addins

Custom Components for gwt-material.
https://gwtmaterialdesign.github.io/gmd-addins-demo/
Apache License 2.0
35 stars 46 forks source link

MaterialRichEditor: Paste via CTRL + V does nothing in Firefox #114

Closed david2411 closed 8 years ago

david2411 commented 8 years ago

Hey, like said in title, there is an issue with pasting text into MaterialRichEditor within Mozilla Firefox (I tested with the currently newest version 47.0.1). Paste does nothing if you want to insert text using CTRL + V. Paste works when using browsers context menu with right click. BTW: CTRL + C in order to copy something from MaterialRichEditor works fine.

I have tested this issue also on the Material Design Demo Page to be sure, that not my implementation is faulty.

Because you can not implement a workaround, for you have no chance to get clipboard data in GWT, we would really appreciate a built-in fix in MaterialDesign Addins.

Kind regards, David

david2411 commented 8 years ago

I investigated some more and found out, that in firefox paste not "does nothing", but it pastes objects to the wrong area. Instead of pasting to the focussed <div class="note-editable">, pasted objects are inserted in the following <div contenteditable="true"> (no id, no class). So i think in firefox the second div overlays the first div when pasting from clipboard. I hope, this will help you solving this problem. For better understanding i made a video-gif to show my point:

strg_v_firefox

david2411 commented 8 years ago

For people with the same problem finding this issue, here's a workaround: The above shown second div only exists in Firefox. I remove it with a JNDI method, so that paste goes to correct div (note-editable):

public static native void removeNextSibling(String identifier) /*-{ // ~ div is a jquery command to find next siblings $wnd.$(identifier + " ~ div").remove(); }-*/;

In my case i identify it by giving an ID to my parent column, so my identifier looks like: #version_description_col .note-editable

kevzlou7979 commented 8 years ago

Hi, I added a onPasteEvent() on MaterialRichEditor, it might be the solution for this issue. Just set the html whenever you have a paste event triggered.