@@ -27,6 +27,7 @@ class ImportExportControls {
2727 this . defaultOptionsPanelWidthPx = 272 ;
2828 this . minOptionsPanelWidthPx = 180 ;
2929 this . maxOptionsPanelWidthPx = 520 ;
30+ this . minPreviewPanelWidthPx = 220 ;
3031 this . currentOptionsPanelWidthPx = null ;
3132 this . _activeSplitDrag = null ;
3233 }
@@ -327,7 +328,8 @@ class ImportExportControls {
327328 text_area . style . width = '100%' ;
328329 text_area . style . height = '100%' ;
329330
330- this . _setOptionsPanelWidth ( optionsparent , this . _getInitialOptionsPanelWidthPx ( ) ) ;
331+ const initialWidth = this . _clampOptionsPanelWidth ( this . _getInitialOptionsPanelWidthPx ( ) , edit_area ) ;
332+ this . _setOptionsPanelWidth ( optionsparent , initialWidth ) ;
331333 optionsparent . style . height = '100%' ;
332334
333335 optionsparent . innerHTML = '' ;
@@ -494,19 +496,26 @@ class ImportExportControls {
494496
495497 splitter . style . display = 'block' ;
496498 textArea . style . flex = '1 1 auto' ;
499+ this . _updateSplitterAriaValues ( splitter , optionsParent , editArea ) ;
497500
498501 if ( splitter . dataset . splitterInitialised === 'true' ) {
499502 return ;
500503 }
501504
502505 splitter . dataset . splitterInitialised = 'true' ;
503506 splitter . addEventListener ( 'pointerdown' , ( event ) => this . _beginSplitterDrag ( event , editArea , optionsParent ) ) ;
507+ splitter . addEventListener ( 'keydown' , ( event ) =>
508+ this . _handleSplitterKeyDown ( event , optionsParent , editArea , splitter )
509+ ) ;
504510 }
505511
506512 _beginSplitterDrag ( event , editArea , optionsParent ) {
507513 if ( ! event || event . button > 0 ) {
508514 return ;
509515 }
516+ if ( this . _activeSplitDrag ) {
517+ return ;
518+ }
510519
511520 const pointerId = event . pointerId ;
512521 const startX = event . clientX ;
@@ -541,6 +550,10 @@ class ImportExportControls {
541550 const requestedWidth = dragState . startWidth + deltaX ;
542551 const boundedWidth = this . _clampOptionsPanelWidth ( requestedWidth , dragState . editArea ) ;
543552 this . _setOptionsPanelWidth ( dragState . optionsParent , boundedWidth ) ;
553+ const splitter = document . querySelector ( 'div.options-preview-splitter' ) ;
554+ if ( splitter ) {
555+ this . _updateSplitterAriaValues ( splitter , dragState . optionsParent , dragState . editArea ) ;
556+ }
544557 }
545558
546559 _endSplitterDrag ( event , onMove , onEnd ) {
@@ -567,6 +580,37 @@ class ImportExportControls {
567580 this . currentOptionsPanelWidthPx = safeWidth ;
568581 }
569582
583+ _handleSplitterKeyDown ( event , optionsParent , editArea , splitter ) {
584+ if ( ! event ) {
585+ return ;
586+ }
587+
588+ const step = event . shiftKey ? 24 : 12 ;
589+ let requestedWidth = this . _readOptionsPanelWidthPx ( optionsParent ) ;
590+ let handled = true ;
591+
592+ if ( event . key === 'ArrowLeft' ) {
593+ requestedWidth -= step ;
594+ } else if ( event . key === 'ArrowRight' ) {
595+ requestedWidth += step ;
596+ } else if ( event . key === 'Home' ) {
597+ requestedWidth = this . minOptionsPanelWidthPx ;
598+ } else if ( event . key === 'End' ) {
599+ requestedWidth = this . maxOptionsPanelWidthPx ;
600+ } else {
601+ handled = false ;
602+ }
603+
604+ if ( ! handled ) {
605+ return ;
606+ }
607+
608+ event . preventDefault ( ) ;
609+ const boundedWidth = this . _clampOptionsPanelWidth ( requestedWidth , editArea ) ;
610+ this . _setOptionsPanelWidth ( optionsParent , boundedWidth ) ;
611+ this . _updateSplitterAriaValues ( splitter , optionsParent , editArea ) ;
612+ }
613+
570614 _readOptionsPanelWidthPx ( optionsParent ) {
571615 const parsed = Number . parseFloat ( optionsParent ?. style ?. width || '' ) ;
572616 if ( Number . isFinite ( parsed ) ) {
@@ -585,10 +629,24 @@ class ImportExportControls {
585629 _clampOptionsPanelWidth ( widthPx , editArea ) {
586630 const editWidth = editArea ?. getBoundingClientRect ?. ( ) . width || 0 ;
587631 const maxByContainer =
588- editWidth > 0 ? Math . max ( this . minOptionsPanelWidthPx , editWidth - 220 ) : this . maxOptionsPanelWidthPx ;
632+ editWidth > 0
633+ ? Math . max ( this . minOptionsPanelWidthPx , editWidth - this . minPreviewPanelWidthPx )
634+ : this . maxOptionsPanelWidthPx ;
589635 const maxAllowed = Math . min ( this . maxOptionsPanelWidthPx , maxByContainer ) ;
590636 return Math . min ( Math . max ( widthPx , this . minOptionsPanelWidthPx ) , maxAllowed ) ;
591637 }
638+
639+ _updateSplitterAriaValues ( splitter , optionsParent , editArea ) {
640+ if ( ! splitter ) {
641+ return ;
642+ }
643+ const min = this . minOptionsPanelWidthPx ;
644+ const max = this . _clampOptionsPanelWidth ( this . maxOptionsPanelWidthPx , editArea ) ;
645+ const now = this . _clampOptionsPanelWidth ( this . _readOptionsPanelWidthPx ( optionsParent ) , editArea ) ;
646+ splitter . setAttribute ( 'aria-valuemin' , `${ min } ` ) ;
647+ splitter . setAttribute ( 'aria-valuemax' , `${ max } ` ) ;
648+ splitter . setAttribute ( 'aria-valuenow' , `${ now } ` ) ;
649+ }
592650}
593651
594652export { ImportExportControls } ;
0 commit comments