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
_updateGrouping
to manage theitems
that 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 : DropdownView
module:ui/toolbar/toolbarview~DynamicGrouping#groupedItemsDropdown
The 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
element
is available.Parameters
view : ToolbarView
An instance of the toolbar being rendered.
-
readonly
resizeObserver : ResizeObserver
module:ui/toolbar/toolbarview~DynamicGrouping#resizeObserver
An 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 : Boolean
module:ui/toolbar/toolbarview~DynamicGrouping#shouldUpdateGroupingOnNextResize
A 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 : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#ungroupedItems
-
A toolbar view this behavior belongs to.
-
A collection of toolbar children.
-
Toolbar element.
-
readonly
viewFocusTracker : FocusTracker
module:ui/toolbar/toolbarview~DynamicGrouping#viewFocusTracker
Toolbar focus tracker.
-
readonly
viewFocusables : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#viewFocusables
A collection of focusable toolbar elements.
-
A view containing toolbar items.
-
Toolbar locale.
-
private
_areItemsOverflowing : Boolean
module:ui/toolbar/toolbarview~DynamicGrouping#_areItemsOverflowing
Returns
true
whenelement
children visually overflow, for instance if the toolbar is narrower than its members. Returnsfalse
otherwise.
Methods
-
constructor( view )
module:ui/toolbar/toolbarview~DynamicGrouping#constructor
Creates an instance of the
DynamicGrouping
toolbar behavior.Parameters
view : ToolbarView
An instance of the toolbar that this behavior is added to.
-
When called, it will check if any of the
ungroupedItems
do not fit into a single row of the toolbar, and it will move them to thegroupedItems
when it happens.At the same time, it will also check if there is enough space in the toolbar for the first of the
groupedItems
to be returned back toungroupedItems
and still fit into a single row without the toolbar wrapping. -
private
_createGroupedItemsDropdown() → DropdownView
module:ui/toolbar/toolbarview~DynamicGrouping#_createGroupedItemsDropdown
Creates the
groupedItemsDropdown
that hosts the members of thegroupedItems
collection 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#_enableGroupingOnMaxWidthChange
Enables the grouping functionality, just like
_enableGroupingOnResize
but the difference is that it listens to the changes ofmaxWidth
instead. -
private
_enableGroupingOnResize()
module:ui/toolbar/toolbarview~DynamicGrouping#_enableGroupingOnResize
Enables the functionality that prevents
ungroupedItems
from overflowing (wrapping to the next row) upon resize when there is little space available. Instead, the toolbar items are moved to thegroupedItems
collection 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
ungroupedItems
and "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
ungroupedItems
and move it back to thegroupedItems
collection.The opposite of
_ungroupFirstItem
. -
Moves the very first item belonging to
groupedItems
back to theungroupedItems
collection.The opposite of
_groupLastItem
. -
private
_updateFocusCycleableItems()
module:ui/toolbar/toolbarview~DynamicGrouping#_updateFocusCycleableItems
Updates 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
groupedItemsDropdown
can 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.