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
-
cachedPadding : Number
module:ui/toolbar/toolbarview~DynamicGrouping#cachedPadding
readonly
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. -
destroy : function
module:ui/toolbar/toolbarview~DynamicGrouping#destroy
readonly
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.
-
groupedItems : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#groupedItems
readonly
-
groupedItemsDropdown : DropdownView
module:ui/toolbar/toolbarview~DynamicGrouping#groupedItemsDropdown
readonly
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.
-
render : function
module:ui/toolbar/toolbarview~DynamicGrouping#render
readonly
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.
-
resizeObserver : ResizeObserver
module:ui/toolbar/toolbarview~DynamicGrouping#resizeObserver
readonly
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
. -
shouldUpdateGroupingOnNextResize : Boolean
module:ui/toolbar/toolbarview~DynamicGrouping#shouldUpdateGroupingOnNextResize
readonly
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.
-
ungroupedItems : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#ungroupedItems
readonly
-
view : ToolbarView
module:ui/toolbar/toolbarview~DynamicGrouping#view
readonly
A toolbar view this behavior belongs to.
-
viewChildren : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#viewChildren
readonly
A collection of toolbar children.
-
viewElement : HTMLElement
module:ui/toolbar/toolbarview~DynamicGrouping#viewElement
readonly
Toolbar element.
-
viewFocusTracker : FocusTracker
module:ui/toolbar/toolbarview~DynamicGrouping#viewFocusTracker
readonly
Toolbar focus tracker.
-
viewFocusables : ViewCollection
module:ui/toolbar/toolbarview~DynamicGrouping#viewFocusables
readonly
A collection of focusable toolbar elements.
-
viewItemsView : ItemsView
module:ui/toolbar/toolbarview~DynamicGrouping#viewItemsView
readonly
A view containing toolbar items.
-
viewLocale : Locale
module:ui/toolbar/toolbarview~DynamicGrouping#viewLocale
readonly
Toolbar locale.
-
_areItemsOverflowing : Boolean
module:ui/toolbar/toolbarview~DynamicGrouping#_areItemsOverflowing
private
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.
-
_updateGrouping()
module:ui/toolbar/toolbarview~DynamicGrouping#_updateGrouping
protected
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. -
_createGroupedItemsDropdown() → DropdownView
module:ui/toolbar/toolbarview~DynamicGrouping#_createGroupedItemsDropdown
private
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
-
_enableGroupingOnMaxWidthChange()
module:ui/toolbar/toolbarview~DynamicGrouping#_enableGroupingOnMaxWidthChange
private
Enables the grouping functionality, just like
_enableGroupingOnResize
but the difference is that it listens to the changes ofmaxWidth
instead. -
_enableGroupingOnResize()
module:ui/toolbar/toolbarview~DynamicGrouping#_enableGroupingOnResize
private
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. -
_groupLastItem()
module:ui/toolbar/toolbarview~DynamicGrouping#_groupLastItem
private
When called, it will remove the last item from
ungroupedItems
and move it back to thegroupedItems
collection.The opposite of
_ungroupFirstItem
. -
_ungroupFirstItem()
module:ui/toolbar/toolbarview~DynamicGrouping#_ungroupFirstItem
private
Moves the very first item belonging to
groupedItems
back to theungroupedItems
collection.The opposite of
_groupLastItem
. -
_updateFocusCycleableItems()
module:ui/toolbar/toolbarview~DynamicGrouping#_updateFocusCycleableItems
private
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 an outdated information? Is something missing? Please report it via our issue tracker.