Fullsize Plugin
- Features
- fullsize
- globalFullSize
- Basic Usage
- Start in Fullscreen Mode
- Programmatic Toggle
- Using Events
- Without Global Fullsize
- Listen for Fullsize Changes
- Custom Button Configuration
- Plugin Initialization
- Entering Fullscreen Mode
- Exiting Fullscreen Mode
- Window Resize Handling
- Button State Update
- Multiple Editor Support
- editor.toggleFullSize()
- editor.isFullSize
- toggleFullSize
- afterResize
- Edge Cases
- Notes
Provides fullscreen mode functionality for the Jodit editor. This plugin allows users to expand the editor to fill the entire browser window, providing a distraction-free editing experience.
Features
- Toggle between normal and fullscreen modes
- Automatic window resize handling in fullscreen mode
- Global fullsize mode that affects parent elements
- Preserves original editor dimensions when exiting fullscreen
- Toolbar button with dynamic icon (fullsize/shrink)
- Multiple editor instance support with shared fullsize tracking
- Optional auto-start in fullscreen mode
- Works in both WYSIWYG and source code modes
fullsize
Type: boolean
Default: false
Opens the editor in fullscreen mode immediately on initialization.
Example:
const editor = Jodit.make('#editor', {
fullsize: true
});
globalFullSize
Type: boolean
Default: true
When enabled, all parent elements of the editor container receive the jodit_fullsize-box_true
class in fullscreen mode. This class applies z-index: 100000 !important
to ensure the editor appears above all other content.
Example:
const editor = Jodit.make('#editor', {
globalFullSize: true
});
Example (disabled):
const editor = Jodit.make('#editor', {
globalFullSize: false
});
Basic Usage
The plugin is enabled by default and provides a fullsize button in the toolbar:
const editor = Jodit.make('#editor');
// Click the fullsize button in the toolbar to toggle fullscreen mode
Start in Fullscreen Mode
const editor = Jodit.make('#editor', {
fullsize: true
});
Programmatic Toggle
const editor = Jodit.make('#editor');
// Toggle fullscreen mode
editor.toggleFullSize();
// Enable fullscreen
editor.toggleFullSize(true);
// Disable fullscreen
editor.toggleFullSize(false);
// Check if in fullscreen mode
if (editor.isFullSize) {
console.log('Editor is in fullscreen mode');
}
Using Events
const editor = Jodit.make('#editor');
// Toggle using event
editor.e.fire('toggleFullSize');
// Enable using event
editor.e.fire('toggleFullSize', true);
// Disable using event
editor.e.fire('toggleFullSize', false);
Without Global Fullsize
When globalFullSize
is disabled, only the editor container expands:
const editor = Jodit.make('#editor', {
globalFullSize: false
});
editor.toggleFullSize(true);
Listen for Fullsize Changes
const editor = Jodit.make('#editor');
editor.e.on('toggleFullSize', (enabled) => {
if (enabled) {
console.log('Entered fullscreen mode');
} else {
console.log('Exited fullscreen mode');
}
});
// Fires after resize completes
editor.e.on('afterResize', () => {
console.log('Editor resized');
});
Custom Button Configuration
const editor = Jodit.make('#editor', {
controls: {
fullsize: {
tooltip: 'Toggle fullscreen mode'
}
}
});
Plugin Initialization
- Button Registration: Registers the
fullsize
toolbar button - State Variables: Initializes tracking variables:
isEnabled
: Current fullscreen stateoldHeight
: Original editor heightoldWidth
: Original editor widthwasToggled
: Whether fullscreen was ever activated
- Event Handlers: Sets up event listeners for window resize and editor lifecycle events
- Global Stack: Uses a shared
fullsizeStack
Set to track all fullscreen editors
Entering Fullscreen Mode
When fullscreen is enabled:
- Save Dimensions: Stores the current container height and width
- Apply Fullscreen Styles: Adds the
jodit_fullsize
class to the container - Resize Container: Sets container dimensions to match window inner dimensions:
height: window.innerHeight
width: window.innerWidth
- Update Stack: Adds the container to the global
fullsizeStack
- Global Mode: If
globalFullSize
is enabled and this is the first fullscreen editor:- Traverses up the DOM tree from the container
- Adds
jodit_fullsize-box_true
class to all parent elements - Stops at document node or document fragment
- Toolbar Adjustment: Ensures toolbar is properly positioned and sets width to
auto
- Update State: Sets
editor.o.fullsize = true
- Fire Events: Triggers
afterResize
event
Exiting Fullscreen Mode
When fullscreen is disabled:
- Remove Fullscreen Styles: Removes the
jodit_fullsize
class from the container - Restore Dimensions: Restores original height and width (or 'auto' if not set)
- Update Stack: Removes the container from
fullsizeStack
- Global Mode: If
globalFullSize
is enabled and this is the last fullscreen editor:- Traverses up the DOM tree
- Removes
jodit_fullsize-box_true
class from all parent elements
- Update State: Sets
editor.o.fullsize = false
- Fire Events: Triggers
afterResize
event
Window Resize Handling
When globalFullSize
is enabled:
- Listen to Window Resize: Attaches a listener to the window's resize event
- Auto-Adjust: In fullscreen mode, automatically adjusts container to new window dimensions
- Preserve State: When not in fullscreen, original dimensions are preserved
Button State Update
The fullsize button updates dynamically:
- Icon Change: Shows "fullsize" icon normally, "shrink" icon when in fullscreen
- Activation State: Button appears activated when in fullscreen mode
- Text Mode: If
textIcons
is enabled, shows "fullsize" or "shrink" text
Multiple Editor Support
The plugin handles multiple editor instances:
- Shared Stack: Uses a global
fullsizeStack
Set to track all fullscreen editors - Global Mode Logic: Only applies global parent styles when:
- Entering fullscreen and it's the first editor (stack size becomes 1)
- Exiting fullscreen and it's the last editor (stack size becomes 0)
- Independent Operation: Each editor can be in fullscreen independently
editor.toggleFullSize()
Toggles between fullscreen and normal modes.
Syntax:
editor.toggleFullSize(enable?: boolean): void
Parameters:
enable
(boolean, optional): If specified, explicitly sets fullscreen mode. If omitted, toggles current state.
Example:
// Toggle
editor.toggleFullSize();
// Enable fullscreen
editor.toggleFullSize(true);
// Disable fullscreen
editor.toggleFullSize(false);
editor.isFullSize
Type: boolean
(read-only property)
Returns whether the editor is currently in fullscreen mode.
Example:
if (editor.isFullSize) {
console.log('Currently in fullscreen');
}
toggleFullSize
Fired when fullscreen mode is toggled.
Handler signature:
(enable: boolean) => void
Example:
editor.e.on('toggleFullSize', (enabled) => {
console.log(`Fullscreen: ${enabled}`);
});
afterResize
Fired after the editor is resized (when entering/exiting fullscreen or window is resized).
Example:
editor.e.on('afterResize', () => {
console.log('Editor was resized');
});
Edge Cases
-
Multiple Editors: When multiple editors are on the same page, global fullsize mode is coordinated so parent elements are styled only when at least one editor is fullscreen
-
Window Resize: In fullscreen mode with
globalFullSize
enabled, the editor automatically adjusts to window resize events -
Original Dimensions: If the editor had no explicit dimensions set, it restores to 'auto' when exiting fullscreen
-
Nested Containers: The plugin traverses all parent elements up to the document node, ensuring proper z-index stacking
-
Toolbar Repositioning: When entering fullscreen, the toolbar is repositioned within the editor's toolbar container
-
Editor Destruction: If an editor is destroyed while in fullscreen mode, it automatically exits fullscreen and cleans up
-
Initial Fullsize: When
fullsize: true
is set in options, fullscreen is applied after bothafterInit
andafterOpen
events -
CSS Specificity: Global fullsize styles use
!important
to ensure they override other styles
Notes
- The plugin works in both WYSIWYG and source code modes
- Fullscreen mode uses CSS classes rather than the native Fullscreen API for better control
- The
jodit_fullsize-box_true
class applied to parent elements setsz-index: 100000 !important
- Original dimensions are preserved using inline styles, not computed styles
- The plugin uses a module-level
fullsizeStack
Set to coordinate across multiple editor instances - Window resize event listener is only attached when
globalFullSize
is enabled - Toolbar width is set to 'auto' in fullscreen mode to allow it to span the full width
- The button's icon/text updates automatically based on the current state
- The plugin properly cleans up event listeners when the editor is destroyed
- Fullscreen state is stored in
editor.o.fullsize
and can be checked viaeditor.isFullSize
fullsize
fullsize(editor
): void
Process toggleFullSize
event, and behavior - set/unset fullsize mode
Parameters
Name | Type |
---|---|
editor |
IViewWithToolbar <IViewOptions > |
Returns
void
Defined in
jodit/src/plugins/fullsize/fullsize.ts:27