how to trigger a Gutenberg image gallery lightbox

In this case I think it would be easiest to simply ignore any Gutenberg-specific implementation and set up the button’s click event to click() the first linked image in the gallery listing.

The following searches the page for “gallery buttons” and the first linked image in a gallery block, then sets up the buttons to execute a click event on the first linked image when clicked.

const initPostGalleryButtons = () => {
  const btns = document.querySelectorAll( '.fl-module-fl-post-content .gallery-btn' )
  const first_gallery_link = document.querySelector( '.fl-module-fl-post-content .wp-block-gallery .wp-block-image>a' )

  if( ! btns.length || ! first_gallery_link )
    return

  const openGallery = () => first_gallery_link.click()

  for ( const btn of btns )
    btn.addEventListener( 'click', openGallery )
}

document.addEventListener( 'DOMContentLoaded', initPostGalleryButtons )