mkdocs-encryptcontent-plugin icon indicating copy to clipboard operation
mkdocs-encryptcontent-plugin copied to clipboard

glightbox plugin doesn't work when encrypt is enabled

Open jeetyadav98 opened this issue 1 year ago • 6 comments
trafficstars

I would like to make images zoom able and clickable, which the mkdocs-glightbox enables. However, it does not seem to work at all when this plugin is installed and active.

Any idea how I can fix this?

jeetyadav98 avatar Feb 02 '24 07:02 jeetyadav98

I didn't test with this plugin. Maybe we just need to re-call some javascript after decryption. I'll check.

Edit: Did you make sure that the plugin order is correct?

plugins:
  - glightbox:
      zoomable: true
      draggable: true
      skip_classes:
        - skip-lightbox
  - encryptcontent: {}

I did a brief test with the plugin's documentation, and it worked kind of (first image I clicked sent the browser to the image, but second click opened the GLightbox).

unverbuggt avatar Feb 02 '24 15:02 unverbuggt

Oh, I never changed the order! I'll have to check.

I didn't know that the order would matter. Is there any reason it does?

jeetyadav98 avatar Feb 03 '24 07:02 jeetyadav98

Yes it works. Thank you!

However, as you noted, the first click opens in browser - not default behavior. Any idea how I could fix this?

jeetyadav98 avatar Feb 03 '24 10:02 jeetyadav98

The first-click behaviour is strange indeed. It doesn't trigger any javascript errors or such...

I'd need to dig into how the glightbox plugin works to find the cause. It's probably just some intialization that needs to be triggered. But no idea why it works on the second click.

Not top priority for me at the moment. However, you could try opening an issue here and hope that the developer of the plugin got some ideas.

unverbuggt avatar Feb 03 '24 15:02 unverbuggt

I had the same problem, my site was also constantly asking for the password while navigating. I saw #61 and fixing that problem by removing the navigation.instant from mkdocs material features fixed both of the problems for me.

lilyildiz avatar Apr 02 '24 05:04 lilyildiz

Did you also try setting webcrypto: true or esm: true while enabling navigation.instant? This should fix being re-prompted for the password, however it won't fix the glightbox issue.

unverbuggt avatar Apr 03 '24 18:04 unverbuggt

The new Version 0.4.0 of mkdocs-glightbox can be fixed by reload_scripts like this:

plugins:
  - glightbox:
      zoomable: true
      draggable: true
      skip_classes:
        - skip-lightbox
  - encryptcontent:
      reload_scripts:
      - '#init-glightbox'

I'll update the documentation on this.

unverbuggt avatar May 06 '24 18:05 unverbuggt