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

Feature Requests: Right Sidebar & Interaction Detail Optimization #7

Closed jjaychen1e closed 2 years ago

jjaychen1e commented 2 years ago

Thanks for you contribution, I love this plugin so much.

It will be nice if it also supports:

sethyuan commented 2 years ago

Glad you like it!

  1. You can create a TOC in any page that's opened in the right sidebar, e.g. Contents. In fact, I designed it exactly to be used this way.
  2. I can implement this, I'll let you know when I'm done.
  3. It can be done by clicking the page link. I kind of prefer to offer simple and consistent behaviors to users.

image

BTW, I implemented a "Back to Top" button, you can use it in any page that is too long.

jjaychen1e commented 2 years ago

@sethyuan Thanks for your reply! Point 1 works great for me. And for point 3, it works fine in most cases, but seems to be broken when the corresponding block was collapsed.

sethyuan commented 2 years ago

Good catch. Unfortunately, this goto behavior is provided by the plugin SDK, I cannot fix it on my side. Maybe you can create an issue ticket to the Logseq team?

sethyuan commented 2 years ago

@JJAYCHEN1e point 2 is implemented and a new version is released.

jjaychen1e commented 2 years ago

@JJAYCHEN1e point 2 is implemented and a new version is released.

Thanks! It works great for me.

jjaychen1e commented 2 years ago

@JJAYCHEN1e point 2 is implemented and a new version is released.

This works pretty well with right sidebar, it can easily show current page's TOC. But currently it won't refresh after jumping to a new page, I need to make changes to the content to trigger the refresh. Could jumping action trigger an event, refreshing the TOC automatically?

sethyuan commented 2 years ago

Interesting, I didn't expect that it could be used in this way. I'll investigate how to detect page changes, triggering event upon jumping can only solve half the problem, a page change can be triggered in a lot of ways.

Thanks for letting know of this interesting usage!

sethyuan commented 2 years ago

@JJAYCHEN1e I thought about it again, no named TOC should really go along with the page it resides on. It shouldn't change with the currently browsing page. For that, I choose to use * as the page name when creating TOC.

I released a new version with this implemented, you're welcome to give it a try. I also updated the README to document how to use this feature.

jjaychen1e commented 2 years ago

@sethyuan I've tried it, it's fantastic. Thanks!

nhan000 commented 2 years ago

TOC still doesn't show up in the right sidebar for me. It works in the main windows, but when I shift click that block, the block shows up as blank in the right sidebar. If I click it, it still shows {{renderer :tocgen }} Btw, great work! Really really like it!

sethyuan commented 2 years ago

@nhan000 I see. This is not how I designed it to be used, but I think your way of using it should also be supported. I'll investigate the problem here, meanwhile, your can open any page in the right sidebar, e.g. "Contents" that opens by default, and create there another TOC by specifying the page name. Say your page is called "abc", you can then create a TOC by typing {{renderer :tocgen, [[abc]]}}.

sethyuan commented 2 years ago

@nhan000 I implemented it and released a new version, can you try it?

nhan000 commented 2 years ago

works great! thanks a lot!

nhan000 commented 2 years ago

currently the page function is only available when the TOC is generated for a page, but not a block. image

Could you have page implemented for block TOC as well? Thanks a lot!

sethyuan commented 2 years ago

@nhan000 Implemented, please give new version a try.

nhan000 commented 2 years ago

works great! Thanks a lot!

thiswillbeyourgithub commented 2 years ago

Hi,

I didn't know if I should have created a new issue but here goes:

I ported a very long .docx file to .md and your plugin is incredible to access it. I'm currently on 0.6.7 and found a quite serious bug : page links only work if the document has been loaded in RAM apparently.

To be a bit more clear, after putting the toc in the sidebar, to make the pagelinks work I need to scroll down in the document until SECTION (so it's now "loaded") and only then can I use the SECTION page links. Otherwise, clicking does nothing and I see no new output in the terminal window running "flatpak run logseq".

The problem is then that it renders your incredible plugin useless to me : going to the end of the document takes forever for a long document and I have to redo it again if I changed document even once.

Is there a way to load the whole page direclty and make sure the page links work?

Thanks a lot!

sethyuan commented 2 years ago

@thiswillbeyourgithub It's maybe better to open an issue of its own, to better track this topic.

BTW, since this is an old plugin SDK problem, I ran another test with the newest version of Logseq and the plugin SDK, and the result is the same, it can't automatically load the necessary content.

The lazy loading behavior of the page by Logseq is to help with loading performance, it only loads as you scroll down the page. However this introduced the issue you mentioned for the plugin SDK's "goto" function.

There is no good solutions on the plugin side, it must be solved by the plugin SDK, which is maintained by the Logseq team.