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

[BUG] Cannot assign to read only property '_cachedNodes' of object '#<RangeSelection>' when I open the editor and undo some texts #485

Open
2 tasks done
bloodteller123 opened this issue Jun 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bloodteller123
Copy link

bloodteller123 commented Jun 7, 2024

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

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

Describe the bug
I have a markdown string which is built by GPT (returned from some API calls), it's passed to the Editor via markdown props as the initial markdown. If I perform undo operation when the editor is open, I can see it's popping error.

Reproduction
https://codesandbox.io/p/sandbox/test-lv7m8w?file=%2Fsrc%2FApp.tsx
please see the md2 string;
and please kindly ignore and close the reference error page :)

To Reproduce
Steps to reproduce the behavior:

  1. Type a few words in the editor
  2. Then do ctrl + Z or click on undo button
  3. See error
  4. but if I close the error page and type a few more words and undo, everything works as normal

Expected behavior
no error

Desktop (please complete the following information):

  • OS: MacOs
  • Browser: Chrome

Additional context
The markdown string is constructed by GPT, and I wondered if it's because of some special characters that cause the error? because I tried it with the markdown from your example, and normal text, everything works fine...

Besides, is there a way to suppress the error page? I know in Lexical we can config the onError method in initialConfig of LexicalComposer which doesn't pop the error page when the error occurs by console.log().
Thank you very much.

@bloodteller123 bloodteller123 added the bug Something isn't working label Jun 7, 2024
@petyosi
Copy link
Contributor

petyosi commented Jun 7, 2024

I think this is a bug in Lexical. This looks the same:
facebook/lexical#3535 - and it looks like the PR never got merged.
Your markdown is fine, by the way. Even if I reduce it down to:

let md2 = `**To:**`;

the error still happens. My gut feel says something does not work with bold formatting being the beginning of the paragraph.

I will see what I can do, but in the meantime, you can also try to reproduce the problem in a plain Lexical environment and get something going there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants