aguingand / tiptap-markdown

The Markdown extension for Tiptap editor.
MIT License
307 stars 22 forks source link

Long texts making `getMarkdown` to freeze the app #32

Open rajatkulkarni95 opened 1 year ago

rajatkulkarni95 commented 1 year ago

Describe the bug When using tiptap-markdown and a long text (example: https://tiptap.dev/examples/book) the 200k word text here, it freezes the editor, and any update made is also extremely slow.

To Reproduce Steps to reproduce the behavior:

  1. Tiptap Editor with StarterKit and tiptap-markdown extension
  2. Paste the above book text
  3. Takes around 3-4 seconds to render
  4. Scrolling and typing is too slow

Expected behavior However when you use editor.getText() its almost instantaneous.

Screenshots See Video

https://github.com/aguingand/tiptap-markdown/assets/57321156/83ac1695-8ace-4e76-a22b-9af447888a87

aguingand commented 1 year ago

Prosemirror markdown seems to cause this. You can try to insert the large content in the example page.

For your information I've fixed parse perfomance in the latest release (v0.8.2), so it should be significantly faster at first load.

rajatkulkarni95 commented 1 year ago

Thanks! I'll give it a try. I feel the issue with slowness is it tries to reserialise the entire 200k word for every onUpdate that causes it.

Tried debouncing it to every 10 secs, but then the sudden lag would come post 10 secs, and would carry on since the next debounces would stagger.

Will check v0.8.2

aguingand commented 1 year ago

I think performances improvements can be done to prosemirror-markdown. I'll keep this open for now but it's not in the scope of this package.

rajatkulkarni95 commented 1 year ago

@aguingand Any suggestions on how best to improve conversion to markdown for long texts?

aguingand commented 1 year ago

Currently no. You could try to use another HTML to markdown serializer if you don't use complex extensions.

I have no bandwidth to contribute to prosemirror-markdown. I was thinking to switch to another parsing / serializing lib like remark for v1 but there is no ETA.