FullscreenAbstractEditorHandler
The abstract editor type handler.
This class defines some actions and behaviors that are applied when fullscreen mode is toggled, and which are common regardless of the editor type. Then, specific classes like ClassicEditorHandler or DecoupledEditorHandler extend this class with actions specific for these editor types.
Extend this class to provide fullscreen mode handling for unsupported editor types, or if you wish to heavily customize the default behavior.
The only method that is necessary to provide when extending this class is defaultOnEnter. However, make sure to familiarize yourself with the below full list of actions taken by FullscreenAbstractEditorHandler to understand what is covered by default, and what should be provided by you.
When entering the fullscreen mode, the enable method is called. It creates the properly styled container and handles the editor features that need it, in the following order:
- Saves the scroll positions of all ancestors of the editable element to restore them after leaving the fullscreen mode.
- Executes the
defaultOnEntermethod to move the proper editor UI elements to the fullscreen mode. If you extend the abstract handler, you should override this method to move the elements that are specific to your editor type, like: editable, toolbar, menu bar. UsemoveToFullscreenmethod for this purpose to ensure they are automatically cleaned up after leaving the fullscreen mode. - Adds proper classes to the
<body>and<html>elements to block page scrolling, adjustz-indexetc.
Steps 4-12 are only executed if the corresponding features are used.
- If presence list is used, moves it to the fullscreen mode container.
- If document outline is used, moves it to the fullscreen mode.
- If pagination is used, adjusts it's configuration for the changed view.
- If annotations are used, moves them to the fullscreen mode.
- If revision history is used, overrides the callbacks to show the revision viewer in the fullscreen mode.
- If AI Tabs is used, moves it to the fullscreen mode.
- If source editing and document outline are both used, registers a callback hiding the document outline header in source editing mode.
- Changes the position of some dialogs to utilize the empty space on the right side of the editable element.
- If custom container is used, hides all other elements in it to ensure they don't create an empty unscrollable space.
Then finally:
- Adjusts the visibility of the left and right sidebars based on the available space.
- Sets up a resize observer to adjust the visibility of the left and right sidebars dynamically.
- Executes the configured
config.fullscreen.onEnterCallbackfunction. By default, it returns the fullscreen mode container element so it can be further customized.
When leaving the fullscreen mode, the disable method is called. It does the following:
- Execute the configured
config.fullscreen.onLeaveCallbackfunction. - Remove the classes added to the
<body>and<html>elements. - If document outline is used, restore its default container.
- If annotations are used, restore their original state (UI, filters etc).
- If revision history is used, restore the original callbacks.
- If AI Tabs is used, restore it to the original state.
- If source editing and document outline are both used, restore the document outline header.
- Restore all moved elements to their original place.
- Destroy the fullscreen mode container.
- If the editor has a toolbar, switch its behavior to the one configured in the
shouldGroupWhenFullproperty. - Restore the scroll positions of all ancestors of the editable element.
- If pagination is used, restore its default configuration.
- Restore default dialogs positions.
This class is exported to allow for custom extensions.
Properties
updateDialogPositionCallback : ( _evt: EventInfo, _name: string, isOpen: boolean ) => voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#updateDialogPositionCallbackStores a bound reference to the _updateDialogPosition method, allowing it to be attached and detached from change event.
_closeRevisionViewerCallback : null | ( viewerEditor: any ) => Promise<unknown>protectedmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_closeRevisionViewerCallbackA callback that closes the revision viewer, stored to restore the original one after exiting the fullscreen mode.
_editor : objectprotectedmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_editorAn editor instance. It should be set by the particular editor type handler.
_showRevisionViewerCallback : null | ( config: EditorConfig ) => Promise<any>protectedmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_showRevisionViewerCallbackA callback that shows the revision viewer, stored to restore the original one after exiting the fullscreen mode.
_aiTabsData : null | objectprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_aiTabsDataA map of AI Tabs data that were set before entering the fullscreen mode.
_annotationsUIsData : null | Map<string, Record<string, any>>privatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_annotationsUIsDataData of the annotations UIs that were active before entering the fullscreen mode.
_collapseLeftSidebarButton : null | ButtonViewprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_collapseLeftSidebarButtonThe button that toggles the visibility of the left sidebar.
_document : Documentprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_documentThe document object in which the editor is located.
_forceShowLeftSidebar : booleanprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_forceShowLeftSidebarTemporary flag used to ignore the first automatic layout adjustment logic when user collapses the left sidebar with a button. It is then immediately set back to
false._hasLeftCollapseButton : booleanprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_hasLeftCollapseButtonWhether the left sidebar collapse button is created.
_hiddenElements : Map<HTMLElement, string>privatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_hiddenElementsA map of elements that were hidden when entering the fullscreen mode. It is used to restore their previous visibility when leaving the fullscreen mode and avoid showing elements that were hidden before entering the fullscreen mode.
_keepLeftSidebarHidden : booleanprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_keepLeftSidebarHiddenWhether the left sidebar should be kept hidden even if there is enough space for it. It's set to
truewhen user collapses the left sidebar with a button. Behavior is reset when exiting the fullscreen mode._paginationBodyCollection : null | BodyCollectionprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_paginationBodyCollectionThe pagination body collection that is used in the fullscreen mode. If we don't move pagination lines to the fullscreen container, they won't be visible.
_placeholderMap : Map<string, object>privatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_placeholderMapMaps placeholder names to placeholder elements and moved elements.
_resizeObserver : null | ResizeObserverprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_resizeObserverThe resize observer that is used to adjust the visibility of the left and right sidebars dynamically.
_savedAncestorsScrollPositions : Map<HTMLElement, object>privatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_savedAncestorsScrollPositionsA map matching the ancestors of the editable element with their scroll positions before entering fullscreen mode.
_sidebarsWidths : objectprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_sidebarsWidthsThe width of the expanded left and right sidebars in the fullscreen mode. Necessary for logic checking if they should be visible.
_wrapper : null | HTMLElementprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_wrapperThe wrapper element that holds the fullscreen mode layout.
Methods
constructor( editor )module:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#constructordefaultOnEnter() → HTMLElementmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#defaultOnEnterA function that moves the editor UI elements to the fullscreen mode. It should be set by the particular editor type handler.
Returns the fullscreen mode container element so it can be further customized via
fullscreen.onEnterCallbackconfiguration property.Returns
HTMLElement
destroy() → voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#destroydisable() → voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#disableDisables the fullscreen mode by restoring all moved elements and destroying the fullscreen container.
Returns
void
enable() → voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#enableEnables the fullscreen mode. It executes the editor-specific enable handler and then the configured callback.
Returns
void
getWrapper() → HTMLElementmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#getWrappermoveToFullscreen( elementToMove, placeholderName ) → voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#moveToFullscreenMoves the given element to the fullscreen mode container, leaving a placeholder in its place.
Parameters
elementToMove : HTMLElementplaceholderName : string
Returns
void
restoreMovedElementLocation( placeholderName ) → voidmodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#restoreMovedElementLocationReturns a single moved element to its original place.
Parameters
placeholderName : string
Returns
void
_adjustVisibleElements() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_adjustVisibleElementsAdjusts the visibility of the left and right sidebars based on the available space.
Returns
void
_destroyContainer() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_destroyContainer_generateCollapseButton() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_generateCollapseButton_generateDocumentOutlineContainer() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_generateDocumentOutlineContainerChecks if the DocumentOutlineUI plugin is available and moves its elements to fullscreen mode.
Returns
void
_generatePresenceListContainer() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_generatePresenceListContainerChecks if the PresenceListUI plugin is available and moves its elements to fullscreen mode.
Returns
void
_handleAISidebarTransitions( evt ) → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_handleAISidebarTransitionsChecks the transition event to see if it's changing the width of the AI tabs and if so, adjusts the visible fullscreen mode elements.
Parameters
evt : TransitionEvent
Returns
void
_handleAITabsTransfer() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_handleAITabsTransferStores the current state of the AI Tabs and moves it to the fullscreen mode.
Returns
void
_hideLeftSidebar() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_hideLeftSidebarHides the left sidebar. Works only if there is anything to hide.
Returns
void
_hideRightSidebar() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_hideRightSidebarHides the right sidebar. Works only if there is anything to hide.
Returns
void
_overrideAnnotationsUIs() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_overrideAnnotationsUIsStores the current state of the annotations UIs to restore it when leaving fullscreen mode and switches the UI to the wide sidebar.
Returns
void
_overrideRevisionHistoryCallbacks() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_overrideRevisionHistoryCallbacksModifies the revision history viewer callbacks to display the viewer in the fullscreen mode.
Returns
void
_registerFullscreenDialogPositionAdjustments() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_registerFullscreenDialogPositionAdjustmentsAdds an event listener when the dialog opens to adjust its position in fullscreen mode, utilizing the empty space on the right side of the editable element.
Returns
void
_restoreAITabs() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_restoreAITabs_restoreAnnotationsUIs() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_restoreAnnotationsUIs_restoreDocumentOutlineDefaultContainer() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_restoreDocumentOutlineDefaultContainerRestores the default value of documentOutlineContainer, which is modified in fullscreen mode.
Returns
void
_restoreRevisionHistoryCallbacks() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_restoreRevisionHistoryCallbacksResets the revision history viewer callbacks to their original values.
Returns
void
_saveAncestorsScrollPositions( domElement ) → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_saveAncestorsScrollPositionsSaves the scroll positions of all ancestors of the given element.
Parameters
domElement : HTMLElement
Returns
void
_setNewDialogPosition() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_setNewDialogPositionAdjusts the dialog position to utilize the empty space on the right side of the editable. The new dialog position should be on the right side of the fullscreen view with a 30px margin. Only dialogs with the position set to "editor-top-side" should have their position changed.
Returns
void
_setupResizeObserver() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_setupResizeObserverSets up a resize observer to adjust the visibility of the left and right sidebars dynamically.
Returns
void
_showLeftSidebar() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_showLeftSidebarShows the left sidebar. Works only if there is anything to show.
Returns
void
_showRightSidebar() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_showRightSidebarShows the right sidebar. Works only if there is anything to show.
Returns
void
_sourceEditingCallback( _evt, _name, value ) → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_sourceEditingCallbackA callback that hides the document outline header when the source editing mode is enabled. Document outline element itself is hidden by source editing plugin.
Parameters
_evt : EventInfo_name : stringvalue : boolean
Returns
void
_switchAnnotationsUI( uiName ) → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_switchAnnotationsUISwitches the annotations UI to the requested one.
Parameters
uiName : string
Returns
void
_unregisterFullscreenDialogPositionAdjustments() → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_unregisterFullscreenDialogPositionAdjustmentsRemoves an event listener that adjusts the dialog's position in fullscreen mode.
Returns
void
_updateDialogPosition( _evt, _name, isOpen ) → voidprivatemodule:fullscreen/handlers/abstracteditorhandler~FullscreenAbstractEditorHandler#_updateDialogPositionIf dialog is open, adjust its positioning.
Parameters
_evt : EventInfo_name : stringisOpen : boolean
Returns
void