sethyuan / logseq-plugin-tocgen

Generate a TOC of any page anywhere to quickly access the page's content.
MIT License
144 stars 10 forks source link

jump to later sections in longform notes #66

Closed chs33 closed 1 year ago

chs33 commented 1 year ago

As far as I observe, due to Logseq's lazy loading for longform notes, click on the section that are not loaded yet won't jump you to that section, my workaround is to scroll down to the bottom of the page let it load everything and then it is good. I am wondering is it possible to improve on this? After all, the whole point of table of content is to being able to jump arbitrarily on real longform notes.

sethyuan commented 1 year ago

It's a long-standing issue, theoretically speaking, it should be solved by the Logseq plugin SDK, there is little the plugin can do.

Anyway, I'll keep making researches about this, will let you know once I have new findings.

sethyuan commented 1 year ago

@chs33 I implemented an algorithm to try hard to handle the lazy loading. Please have a try.

chs33 commented 1 year ago

Just tried. It now jumps to the desired section now. Looks like the time it takes will be proportional to the length of the page as it keep scrolling down automatically (assume you always jump to the last section). I suppose it is best we can achieve given current state/design of the Logseq. I appreciate the quick response, effort and time implementing this. Thank you very much!

arigit commented 1 year ago

Hi @sethyuan , landed here as I am new to logseq, I migrated some VERY long pages to it and I am using the ToC plugin extensively (it's awesome, thanks). The way you are working around lazy loading works well for medium-sized pages of up to some 10 "screens" long, but on longer pages, it seems to time out and stops jumping down. I figure that you have set some maximum time out value after which you stop "paging down", could you allow your workaround to try longer (at least 3X the time you try today)? - or if this impacts other things, make the timeout / max page-down configurable?

sethyuan commented 1 year ago

@arigit Sure, I can add a plugin setting for the number of times to try to scroll down.

sethyuan commented 1 year ago

@arigit The setting is added.

arigit commented 1 year ago

Just tested it and it works great. I had to increase the default max number of scroll-downs to 35. Thanks a zillion for this