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

Plugin handlePastedText doesn't get called when setting stripPastedStyles=false #435

Open
quirinpa opened this issue Jan 18, 2021 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@quirinpa
Copy link

quirinpa commented Jan 18, 2021

Describe the bug

I'm trying to write a plugin to limit maximum content length in the draftail editor. I also want to be able to paste formatted content from outside the editor. Turns out my plugin's handlePastedText does not get called when setting prop stripPastedStyles to false. Unless I paste plain text.

Environment

Current version of draftail + draft.js 0.10.5

Steps to reproduce

  1. First, write a plugin that uses handlePastedText and use it in draftail
  2. Then, set editor prop stripPastedStyles to false
  3. Finally, handlePastedText is not called when pasting something other than plain text

Expected behavior

I expect my plugin's handlePastedText to be called

Actual behavior

It never gets called (because draftail precedes it in handling the event)

Aditional tests

I've checked out the code in the editor which does handlePastedText and copied handleDraftEditorPastedText to my plugin's handler and I've removed the prop stripPastedStyles from the editor. Then I copy html to the editor and see that it does not have formatting if I copy from outside the editor. PastedState = handleDraftEditorPastedText(html, editorState) is falsey. I add back stripPastedStyles=false and the formatting works again. I thought I'd use stripPastedStyles=true and handle the pasting of formatted content inside my plugin's handler but this does not prove to be working. I've also used draftjs-import-html to actually have some sort of formatted content but I find it very lacking in comparison to default draftail behavior. Ideally I want to pass stripPastedStyles=false and still have my plugin's code handle the paste.

@quirinpa quirinpa added the bug Something isn't working label Jan 18, 2021
@quirinpa quirinpa changed the title Plugin handlePastedText with stripPastedStyles=false Plugin handlePastedText doesn't get called when setting stripPastedStyles=false Jan 18, 2021
@thibaudcolas thibaudcolas added this to the v1.5.0 milestone Apr 24, 2021
@thibaudcolas
Copy link
Collaborator

I believe this could likely be fixed by following the exact same approach as #445. I’d happily review a pull request attempting this, with the needed implementation changes, unit tests, and demo code for manual testing.

@thibaudcolas thibaudcolas added good first issue Good for newcomers help wanted Extra attention is needed labels Apr 24, 2021
@thibaudcolas thibaudcolas modified the milestones: v1.5.0, Nice to have Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants