mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
2.08k stars 160 forks source link

[BUG] Nested NestedLexicalEditor instances within table cell fail to update parentEditor MDX #570

Closed mlequime closed 3 months ago

mlequime commented 3 months ago

If you want to ask for support or request features, sponsor the project and contact me over email.

Describe the bug A NestedLexicalEditor within a NestedLexicalEditor (to any depth) will fail to update with updateMdastNode when within a table cell.

This is due to the priority on the NESTED_EDITOR_UPDATED_COMMAND within TableEditor, it effectively captures the dispatched event before the change has been able to propagate, and sets state with the older value.

Lowering this state to match NestedLexicalEditor (COMMAND_PRIORITY_EDITOR) fixes the issue.

Reproduction Working on adding an example

To Reproduce Steps to reproduce the behavior:

  1. Create a directive with a nested lexical editor and some action that sets its attributes with updateMdastNode
  2. Include this within an instance of itself, within a table cell
  3. Button will have no action, but button on the parent will work as it's a direct child of the TableCell

Expected behavior Updating state within any depth should work

Screenshots If applicable, add screenshots to help explain your problem.

Screenshot 2024-08-22 at 10 46 25

Desktop (please complete the following information):

Additional context Will raise a merge request with the fix

petyosi commented 3 months ago

The diagram makes a lot of sense to me. Happy to accept a PR, I remember you were doing something in the space.