Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload pages which include a changed document #503

Open
fbruetting opened this issue Apr 4, 2021 · 5 comments
Open

Reload pages which include a changed document #503

fbruetting opened this issue Apr 4, 2021 · 5 comments

Comments

@fbruetting
Copy link

When I have a main document which includes certain subdocuments, that main document currently does net get reloaded when one if the included files get changed. Can this be implemented?

@ggrossetie
Copy link
Member

It could be implemented but depending on many includes you have it will negatively impact the performance.
The reason is that we will need to fetch the content regularly (every X seconds) for every include.

Similarly, we could also reload the page when a local resource changed (i.e., images).

I'm willing to implement this feature behind a flag, so users will decide if they want to pay a small performance price for this feature.

@KarelPeeters
Copy link

Some questions I have while working on an implementation:

  • Is there some "proper" way to access the list of included files? In converter.js I can access them as doc.catalog.$$smap.includes.$$smap, but it feels like that's touching Opal internal names. An alternative is to register an Include Processor. How does this work right now? Does Asciidoctor.js just access the right include files internally, without any interaction with the browser plugin?
  • Why are the images not similarly listed in doc.catalog.$$smap.images.$$smap? I can't find any code in the plugin that has custom handling for images, is this also just normal Asciidoctor.js behavior?

@KarelPeeters
Copy link

@ggrossetie Any advice?

@ggrossetie
Copy link
Member

The include directive is a preprocessor directive https://docs.asciidoctor.org/asciidoc/latest/directives/include/#include-processing.

Is there some "proper" way to access the list of included files? In converter.js I can access them as doc.catalog.$$smap.includes.$$smap, but it feels like that's touching Opal internal names

You can use getCatalog().includes: https://asciidoctor.github.io/asciidoctor.js/main/#documentgetcatalog

Why are the images not similarly listed in doc.catalog.$$smap.images.$$smap? I can't find any code in the plugin that has custom handling for images, is this also just normal Asciidoctor.js behavior?

I think you are looking for this option: https://docs.asciidoctor.org/asciidoctor/latest/api/catalog-assets/

@KarelPeeters
Copy link

I've made some progress, collecting all included paths (even the figures) is working now.

I have a question about where the hashes of all the files should be stored. Currently they are stored using Settings in storage.local, eg. in loader.js. That storage is shared across multiple tabs that are using the extension though, which makes me worried that there will be concurrency issues caused by multiple tabs having the same files open. I think it's better if these hashes are stored in the per-tab storage.session instead. Is it okay if I make that change as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants