@@ -18,16 +18,17 @@ import {DeleteArea} from './delete_area.js';
1818import type { Abstract as AbstractEvent } from './events/events_abstract.js' ;
1919import { EventType } from './events/type.js' ;
2020import * as eventUtils from './events/utils.js' ;
21+ import { FlyoutItem } from './flyout_item.js' ;
2122import { FlyoutMetricsManager } from './flyout_metrics_manager.js' ;
2223import { FlyoutSeparator , SeparatorAxis } from './flyout_separator.js' ;
2324import { IAutoHideable } from './interfaces/i_autohideable.js' ;
24- import type { IBoundedElement } from './interfaces/i_bounded_element.js' ;
2525import type { IFlyout } from './interfaces/i_flyout.js' ;
2626import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js' ;
2727import type { Options } from './options.js' ;
2828import * as registry from './registry.js' ;
2929import * as renderManagement from './render_management.js' ;
3030import { ScrollbarPair } from './scrollbar_pair.js' ;
31+ import { SEPARATOR_TYPE } from './separator_flyout_inflater.js' ;
3132import * as blocks from './serialization/blocks.js' ;
3233import { Coordinate } from './utils/coordinate.js' ;
3334import * as dom from './utils/dom.js' ;
@@ -677,20 +678,19 @@ export abstract class Flyout
677678 const type = info [ 'kind' ] . toLowerCase ( ) ;
678679 const inflater = this . getInflaterForType ( type ) ;
679680 if ( inflater ) {
680- const element = inflater . load ( info , this . getWorkspace ( ) ) ;
681- contents . push ( {
682- type,
683- element,
684- } ) ;
685- const gap = inflater . gapForElement ( info , defaultGap ) ;
681+ contents . push ( inflater . load ( info , this . getWorkspace ( ) ) ) ;
682+ const gap = inflater . gapForItem ( info , defaultGap ) ;
686683 if ( gap ) {
687- contents . push ( {
688- type : 'sep' ,
689- element : new FlyoutSeparator (
690- gap ,
691- this . horizontalLayout ? SeparatorAxis . X : SeparatorAxis . Y ,
684+ contents . push (
685+ new FlyoutItem (
686+ new FlyoutSeparator (
687+ gap ,
688+ this . horizontalLayout ? SeparatorAxis . X : SeparatorAxis . Y ,
689+ ) ,
690+ SEPARATOR_TYPE ,
691+ false ,
692692 ) ,
693- } ) ;
693+ ) ;
694694 }
695695 }
696696 }
@@ -711,9 +711,12 @@ export abstract class Flyout
711711 */
712712 protected normalizeSeparators ( contents : FlyoutItem [ ] ) : FlyoutItem [ ] {
713713 for ( let i = contents . length - 1 ; i > 0 ; i -- ) {
714- const elementType = contents [ i ] . type . toLowerCase ( ) ;
715- const previousElementType = contents [ i - 1 ] . type . toLowerCase ( ) ;
716- if ( elementType === 'sep' && previousElementType === 'sep' ) {
714+ const elementType = contents [ i ] . getType ( ) . toLowerCase ( ) ;
715+ const previousElementType = contents [ i - 1 ] . getType ( ) . toLowerCase ( ) ;
716+ if (
717+ elementType === SEPARATOR_TYPE &&
718+ previousElementType === SEPARATOR_TYPE
719+ ) {
717720 // Remove previousElement from the array, shifting the current element
718721 // forward as a result. This preserves the behavior where explicit
719722 // separator elements override the value of prior implicit (or explicit)
@@ -752,9 +755,9 @@ export abstract class Flyout
752755 * Delete elements from a previous showing of the flyout.
753756 */
754757 private clearOldBlocks ( ) {
755- this . getContents ( ) . forEach ( ( element ) => {
756- const inflater = this . getInflaterForType ( element . type ) ;
757- inflater ?. disposeElement ( element . element ) ;
758+ this . getContents ( ) . forEach ( ( item ) => {
759+ const inflater = this . getInflaterForType ( item . getType ( ) ) ;
760+ inflater ?. disposeItem ( item ) ;
758761 } ) ;
759762
760763 // Clear potential variables from the previous showing.
@@ -959,11 +962,3 @@ export abstract class Flyout
959962 return null ;
960963 }
961964}
962-
963- /**
964- * A flyout content item.
965- */
966- export interface FlyoutItem {
967- type : string ;
968- element : IBoundedElement ;
969- }
0 commit comments