@@ -29,6 +29,9 @@ function initMessageListeners() {
2929 DOMManager . updateGlobalDoms ( message ) ;
3030 DOMManager . updateGalleryContent ( ) ;
3131 break ;
32+ case "POST.gallery.setColumnCount" :
33+ updateColumnCount ( message . columnCount ) ;
34+ break ;
3235 }
3336 } ) ;
3437}
@@ -306,6 +309,72 @@ class EventListener {
306309 }
307310}
308311
312+ // Column control functionality
313+ const columnInput = document . getElementById ( 'column-count' ) ;
314+ const columnArrows = document . querySelectorAll ( '.column-arrow' ) ;
315+ const autoCheckbox = document . getElementById ( 'auto-columns' ) ;
316+
317+ function updateColumnCount ( count ) {
318+ const grids = document . querySelectorAll ( '.grid' ) ;
319+ grids . forEach ( grid => {
320+ if ( autoCheckbox . checked ) {
321+ grid . style . removeProperty ( '--column-count' ) ;
322+ grid . style . removeProperty ( '--column-width' ) ;
323+ } else {
324+ grid . style . setProperty ( '--column-count' , count ) ;
325+ grid . style . setProperty ( '--column-width' , '1fr' ) ;
326+ }
327+ } ) ;
328+ }
329+
330+ // Update column input and arrows state based on auto checkbox
331+ function updateColumnControlState ( ) {
332+ const isAuto = autoCheckbox . checked ;
333+ columnInput . disabled = isAuto ;
334+ columnArrows . forEach ( arrow => arrow . disabled = isAuto ) ;
335+ updateColumnCount ( isAuto ? null : columnInput . value ) ;
336+ }
337+
338+ columnInput . addEventListener ( 'change' , ( e ) => {
339+ if ( autoCheckbox . checked ) { return ; }
340+ const value = Math . min ( Math . max ( parseInt ( e . target . value ) || 1 , 1 ) , 100 ) ;
341+ e . target . value = value ;
342+ vscode . postMessage ( {
343+ command : 'POST.gallery.updateColumnCount' ,
344+ columnCount : value
345+ } ) ;
346+ updateColumnCount ( value ) ;
347+ } ) ;
348+
349+ columnArrows . forEach ( arrow => {
350+ arrow . addEventListener ( 'click' , ( ) => {
351+ if ( autoCheckbox . checked ) { return ; }
352+ const currentValue = parseInt ( columnInput . value ) || 1 ;
353+ const direction = arrow . dataset . direction ;
354+ const newValue = direction === 'up'
355+ ? Math . min ( currentValue + 1 , 100 )
356+ : Math . max ( currentValue - 1 , 1 ) ;
357+
358+ columnInput . value = newValue ;
359+ vscode . postMessage ( {
360+ command : 'POST.gallery.updateColumnCount' ,
361+ columnCount : newValue
362+ } ) ;
363+ updateColumnCount ( newValue ) ;
364+ } ) ;
365+ } ) ;
366+
367+ autoCheckbox . addEventListener ( 'change' , ( ) => {
368+ updateColumnControlState ( ) ;
369+ vscode . postMessage ( {
370+ command : 'POST.gallery.updateColumnCount' ,
371+ columnCount : autoCheckbox . checked ? null : columnInput . value
372+ } ) ;
373+ } ) ;
374+
375+ // Initialize column control state
376+ updateColumnControlState ( ) ;
377+
309378( function ( ) {
310379 init ( ) ;
311380} ( ) ) ;
0 commit comments