mdx-editor / editor

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

[BUG] Copy paste list from MacOS Pages app throw an error #583

Closed dmowski closed 2 months ago

dmowski commented 2 months ago

Describe the bug When copy pasting List elements from docx file on MacOs, changes are not applied.

To Reproduce

  1. Go to mdxeditor.dev demo

  2. Open provided document listCopyPaste.docx

    image
  3. Copy/Paste content into Editor

  4. Open browser console

  5. See error:

    image

TypeError: Cannot read properties of undefined (reading 'children')

Expected behavior No error in console, on change event triggered

Desktop:

Additional context I found, that errors happened on module src/exportMarkdownFromLexical.ts:100 Function: isParent

Additionally I checked that mdastParent! is undefined

image

src/exportMarkdownFromLexical.ts:100

I've tried to update lexical libs to 0.17.1 - doesn't help

If someone would suggest what to do to fix it, or how to better research it I will be thankful. For now, I am new at that code base, and it's little difficult to fix it fast for me

petyosi commented 2 months ago

@dmowski this is this issue: https://github.com/mdx-editor/editor/issues/178. Nested lists are very painful. I want to fix this, but it's not very simple, especially with copy paste. The AST is the culprit.

petyosi commented 2 months ago

@dmowski forgot to mention - thank you for the sponsorship. I will see if I can at least prevent the error, even if this means losing the indentation, which IMO is far more acceptable.

dmowski commented 2 months ago

@dmowski forgot to mention - thank you for the sponsorship. I will see if I can at least prevent the error, even if this means losing the indentation, which IMO is far more acceptable.

Nice, Thanks. yes, it will be nice to prevent losing data, even if formatting will be broken (that's ok).

In my case, end user see editor on page with auto saving functionality, and they may put something to editor and close the tab. With error, onChange event doesn't trigger and nothing to save

github-actions[bot] commented 2 months ago

:tada: This issue has been resolved in version 3.11.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: