Skip to content

Bug: Exception is swallowed when pasting into editor #7940

@mareolan

Description

@mareolan

Lexical version: 0.37.0

Steps To Reproduce

  1. Use Editor's initialConfig: { html: { import: { span: (el) => { throw new Error("Unintentional error."); } } } }, i.e. have custom import handling for an HTML element and do an unintentional error there.
  2. Copy any HTML containing element.
  3. When pasting, the exception is swallowed - it's not shown anywhere, so developer has no clue why the import is behaving weirdly (it looks like it falls back to something like non-HTML plain-text paste).

Link to code example:

https://stackblitz.com/edit/facebook-lexical-7nhfkbzs?file=src%2FApp.tsx

The current behavior

Exception is swallowed. Likely due to:
https://github.com/facebook/lexical/blob/main/packages/lexical-clipboard/src/clipboard.ts#L148
https://github.com/facebook/lexical/blob/main/packages/lexical-clipboard/src/clipboard.ts#L168

The expected behavior

Exception is logged into console.

Impact of fix

Developers will thank you for not making it harder for them ;-).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions