@@ -342,27 +342,37 @@ export default {
342342 },
343343 // prevents page reloading on internal URL's
344344 onHtmlClick (event ) {
345+ const target = event .target ;
346+ const tagName = target .tagName .toLowerCase ();
345347
346- // Si c'est un lien interne avec une ancre (#), on laisse le comportement par défaut
347- if (event . target . parentNode . tagName . toLowerCase () === ' a' && event . target .parentNode .getAttribute ( ' href ' ). startsWith ( ' # ' )) {
348- navigator . clipboard . writeText ( event . target .parentNode . href ) ;
349- return ;
350- }
351- if (event . target . tagName . toLowerCase () === ' a ' ) {
352- if ( event . target . hasAttribute ( ' download ' )) {
348+ // Handle anchor tags
349+ if (tagName === ' a' || (tagName === ' span ' && target .parentNode .tagName . toLowerCase () === ' a ' )) {
350+ const link = tagName === ' a ' ? target : target .parentNode ;
351+
352+ // Handle internal anchor links
353+ if (link . getAttribute ( ' href ' ) ? . startsWith ( ' # ' ) ) {
354+ navigator . clipboard . writeText ( link . href );
353355 return ;
354356 }
355- // Si le lien est sur le même domaine
356- if (event .target .href .includes (window .location .origin )) {
357+
358+ // Skip processing for TOC links and download links
359+ if (link .closest (' .toc' ) || link .hasAttribute (' download' )) {
360+ return ;
361+ }
362+
363+ // Handle internal navigation
364+ if (link .href ? .includes (window .location .origin )) {
357365 event .stopPropagation ();
358366 event .preventDefault ();
359- let path = event . target . hasAttribute ( ' href ' ) ? event . target . getAttribute (' href' ) : event . target .pathname ;
367+ const path = link . getAttribute (' href' ) || link .pathname ;
360368 this .$router .push (path);
361369 }
370+ return ;
362371 }
363- // display image in lightbox when clicked
364- if (event .target .tagName .toLowerCase () === ' img' ) {
365- this .uiStore .displayLightBox (event .target .src );
372+
373+ // Handle images
374+ if (tagName === ' img' ) {
375+ this .uiStore .displayLightBox (target .src );
366376 }
367377 },
368378 async getVideoUrl () {
0 commit comments