Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting does not trigger editablePaste #1098

Closed
JeanCarriere opened this issue May 24, 2016 · 8 comments
Closed

Pasting does not trigger editablePaste #1098

JeanCarriere opened this issue May 24, 2016 · 8 comments

Comments

@JeanCarriere
Copy link

JeanCarriere commented May 24, 2016

Description

Copy and pasting a file in the editor does not trigger editablePaste event

Steps to reproduce

  1. Subscribe to the editablePaste event
  2. Copy a file to the clipboard
  3. Paste in the editor with CTL V

Expected behavior:
The subscribed function should be called

Actual behavior:
It's not called
There is an error in the console :
Uncaught TypeError: Cannot read property 'split' of undefined
a.Extension.extend.doPaste @ medium-editor.min.js:3

Versions

  • medium-editor: 5.18.0
  • browser: Chrome 50
  • OS: OS X El Capitan
@j0k3r
Copy link
Contributor

j0k3r commented May 24, 2016

Which kind of file are your dropping in the editor, an image, a text file?

@JeanCarriere
Copy link
Author

For instance, I paste a picture copied in the clipboard from a web page.
The problem seems to come from the handlePasteBinPaste mechanism.

@j0k3r
Copy link
Contributor

j0k3r commented May 24, 2016

Didn't took time to look at it, but we rewrote the pasting part recently, it might be related.

@nmielnik
Copy link
Member

nmielnik commented May 25, 2016

This is definitely a result of the new code. Right click paste fires the event correctly, but keyboard paste does not. This is because when we capture the CTRL + V command we change which element the user will actually paste into. Since this element is not within the editor, the actual paste event on the editor will never fire. Since that event doesn't trigger, our handler which fires the editablePaste event never gets triggered.

I can get a fix for this in soon, thanks a ton for point this out @JeanCarriere !

@nmielnik
Copy link
Member

@JeanCarriere the fix for this is ready (#1099), as soon as it's merged in we'll cut a new patch release so you'll have the fix available. Thanks again for pointing out this issue.

@nmielnik
Copy link
Member

@JeanCarriere for the case where you weren't able to copy and paste an image in, I wasn't able to reproduce it...what options are you passing when you initialize medium-editor? There are some paste related options you'll have to configure to ensure the images will show up Are you setting paste. forcePlainText to false or paste. cleanPastedHTML to true?

@j0k3r j0k3r closed this as completed in d106f36 May 27, 2016
@JeanCarriere
Copy link
Author

The options I have are :

  • forcePlainText : true
  • cleanPastedHTML : false

@nmielnik
Copy link
Member

In order for the html to come through (and for images to not be ignored), you'll need to set forcePlainText: false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants