Milkdown / website

The official documentation website for milkdown.
https://milkdown.dev
MIT License
31 stars 101 forks source link

[Bug] Switching between light mode and dark mode in playground overwrites source markdown #23

Open pugtooth opened 1 year ago

pugtooth commented 1 year ago

Initial checklist

Affected packages and versions

Milkdown Playgroundv7.3.0

Link to runnable example

No response

Steps to reproduce

Type anything into the editor, switch between light modes, and the source text will be reset to default text.

Expected behavior

You keep your text (sorry for lame response, but I feel like this is a given)

Actual behavior

The preview will not be effected, but the source text will be reset to the default text.

Runtime

Chrome

OS

Linux

Build and bundle tools

No response

sindras commented 1 month ago

That's very likely caused by the useLayoutEffect's dependency towards darkMode changes.

Whenever the value change, the useLayoutEffect callback is triggered, so it will call the crepe.destroy() first, and then re-creating a new editor with the original default content.