DynamicGrouping (ui/toolbar)
@ckeditor/ckeditor5-ui/src/toolbar/toolbarview
A toolbar behavior that makes the items respond to changes in the geometry.
In a nutshell, it groups items
that do not fit visually into a single row of the toolbar (due to limited space).
Items that do not fit are aggregated in a dropdown displayed at the end of the toolbar.
┌──────────────────────────────────────── ToolbarView ──────────────────────────────────────────┐
| ┌─────────────────────────────────────── #children ─────────────────────────────────────────┐ |
| | ┌─────── #itemsView ────────┐ ┌──────────────────────┐ ┌── #groupedItemsDropdown ───┐ | |
| | | #ungroupedItems | | ToolbarSeparatorView | | #groupedItems | | |
| | └──────────────────────────-┘ └──────────────────────┘ └────────────────────────────┘ | |
| | \---------- only when toolbar items overflow --------/ | |
| └───────────────────────────────────────────────────────────────────────────────────────────┘ |
└───────────────────────────────────────────────────────────────────────────────────────────────┘
Filtering
Properties
-
A cached value of the horizontal padding style used by
_updateGroupingto manage theitemsthat do not fit into a single toolbar line. This value can be reused between updates because it is unlikely that the padding will change and re–usingWindow.getComputedStyle()is expensive. -
A method called after the toolbar has been destroyed. It allows cleaning up after the toolbar behavior, for instance, this is the right place to detach event listeners, free up references, etc.
-
readonly
groupedItemsDropdown : DropdownViewmodule:ui/toolbar/toolbarview~DynamicGrouping#groupedItemsDropdownThe dropdown that aggregates grouped items that do not fit into a single row of the toolbar. It is displayed on demand as the last of toolbar children and offers another (nested) toolbar which displays items that would normally overflow.
-
A method called after the toolbar has been rendered. It can be used to, for example, customize the behavior of the toolbar when its
elementis available.Parameters
view : ToolbarViewAn instance of the toolbar being rendered.
-
readonly
resizeObserver : ResizeObservermodule:ui/toolbar/toolbarview~DynamicGrouping#resizeObserverAn instance of the resize observer that helps dynamically determine the geometry of the toolbar and manage items that do not fit into a single row.
Note: Created in
_enableGroupingOnResize. -
readonly
shouldUpdateGroupingOnNextResize : Booleanmodule:ui/toolbar/toolbarview~DynamicGrouping#shouldUpdateGroupingOnNextResizeA flag indicating that an items grouping update has been queued (e.g. due to the toolbar being visible) and should be executed immediately the next time the toolbar shows up.
-
readonly
ungroupedItems : ViewCollectionmodule:ui/toolbar/toolbarview~DynamicGrouping#ungroupedItems -
A toolbar view this behavior belongs to.
-
A collection of toolbar children.
-
Toolbar element.
-
readonly
viewFocusTracker : FocusTrackermodule:ui/toolbar/toolbarview~DynamicGrouping#viewFocusTrackerToolbar focus tracker.
-
readonly
viewFocusables : ViewCollectionmodule:ui/toolbar/toolbarview~DynamicGrouping#viewFocusablesA collection of focusable toolbar elements.
-
A view containing toolbar items.
-
Toolbar locale.
-
private
_areItemsOverflowing : Booleanmodule:ui/toolbar/toolbarview~DynamicGrouping#_areItemsOverflowingReturns
truewhenelementchildren visually overflow, for instance if the toolbar is narrower than its members. Returnsfalseotherwise.
Methods
-
constructor( view )module:ui/toolbar/toolbarview~DynamicGrouping#constructorCreates an instance of the
DynamicGroupingtoolbar behavior.Parameters
view : ToolbarViewAn instance of the toolbar that this behavior is added to.
-
When called, it will check if any of the
ungroupedItemsdo not fit into a single row of the toolbar, and it will move them to thegroupedItemswhen it happens.At the same time, it will also check if there is enough space in the toolbar for the first of the
groupedItemsto be returned back toungroupedItemsand still fit into a single row without the toolbar wrapping. -
private
_createGroupedItemsDropdown() → DropdownViewmodule:ui/toolbar/toolbarview~DynamicGrouping#_createGroupedItemsDropdownCreates the
groupedItemsDropdownthat hosts the members of thegroupedItemscollection when there is not enough space in the toolbar to display all items in a single row.Returns
-
private
_enableGroupingOnMaxWidthChange()module:ui/toolbar/toolbarview~DynamicGrouping#_enableGroupingOnMaxWidthChangeEnables the grouping functionality, just like
_enableGroupingOnResizebut the difference is that it listens to the changes ofmaxWidthinstead. -
private
_enableGroupingOnResize()module:ui/toolbar/toolbarview~DynamicGrouping#_enableGroupingOnResizeEnables the functionality that prevents
ungroupedItemsfrom overflowing (wrapping to the next row) upon resize when there is little space available. Instead, the toolbar items are moved to thegroupedItemscollection and displayed in a dropdown at the end of the row (which has its own nested toolbar).When called, the toolbar will automatically analyze the location of its
ungroupedItemsand "group" them in the dropdown if necessary. It will also observe the browser window for size changes in the future and respond to them by grouping more items or reverting already grouped back, depending on the visual space available. -
When called, it will remove the last item from
ungroupedItemsand move it back to thegroupedItemscollection.The opposite of
_ungroupFirstItem. -
Moves the very first item belonging to
groupedItemsback to theungroupedItemscollection.The opposite of
_groupLastItem. -
private
_updateFocusCycleableItems()module:ui/toolbar/toolbarview~DynamicGrouping#_updateFocusCycleableItemsUpdates the focus–cycleable items collection so it represents the up–to–date state of the UI from the perspective of the user.
For instance, the
groupedItemsDropdowncan show up and hide but when it is visible, it must be subject to focus cycling in the toolbar.See the collection documentation to learn more about the purpose of this method.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.