PKM-er / obsidian-floating-toc-plugin

MIT License
209 stars 6 forks source link

BUG: 80 h2s slow down rendering. #86

Open mariomui opened 10 months ago

mariomui commented 10 months ago

Summary

As a user who wants to take notes on a book, i frequently need to create notes with 100+ headers (level 2).

I've isolated the problem in a new vault.

Problem

Whenever, I add a new line, the toc rerenders all 100+ headers at once causing the ui thread to hang.

Solutions

Proposed Short-term Solution:

Allow the user to turn off automatic re-rendering. Allow user to manually re-render headers.

Proposed Long-term Solution: Cache

Store the val(html string) via localforage cache(indexdb) using the H2 name by key and call up the html string and use DOMParser.parseFromString to insert the the html

Example

https://github.com/pashashocky/obsidian-note-gallery/blob/121fa1217c724a00c7072fa06bc032e0c9a3d113/src/react/components/CardMarkdownContentRenderer.tsx#L27

Tradeoffs

The long term solution requires hooking into the crud updates on the headers.