Skip to content

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

Open
@quirinpa

Description

@quirinpa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions