Add a Content Edit feature.
The feature to add
Add a custom DOM event handler to handle events not handled by roosterjs. Caller need to take the responsibility to dispose the handler properly
DOM event name to handle
Handler callback
A dispose function. Call the function to dispose this event handler
Add a bunch of custom DOM event handler to handle events not handled by roosterjs. Caller need to take the responsibility to dispose the handler properly
A event name => event handler map
A dispose function. Call the function to dispose all event handlers added by this function
Add undo snapshot, and execute a format callback function, then add another undo snapshot, then trigger ContentChangedEvent with given change source. If this function is called nested, undo snapshot will only be added in the outside one
The callback function to perform formatting, returns a data object which will be used as the data field in ContentChangedEvent if changeSource is not null.
The change source to use when fire ContentChangedEvent. When the value is not null, a ContentChangedEvent will be fired with change source equal to this value
True if this action can be undone when user presses Backspace key (aka Auto Complete).
Optional parameter to provide additional data related to the ContentChanged Event.
Collapse nodes within the given start and end nodes to their common ancestor node, split parent nodes if necessary
The start node
The end node
True to allow split parent node there are nodes before start or after end under the same parent and the returned nodes will be all nodes from start through end after splitting False to disallow split parent
When canSplitParent is true, returns all node from start through end after splitting, otherwise just return start and end
Check if the node falls in the editor content
The node to check
True if the given node is in editor content, otherwise false
Check if the range falls in the editor content
The range to check
True if the given range is in editor content, otherwise false
Delete a node from editor content
The node to delete
true if node is deleted. Otherwise false
Delete selected content
Dispose this editor, dispose all plugins and custom data
Ensure user will type into a container element rather than into the editor content DIV directly
The position that user is about to type to
Optional keyboard event object
Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
Get BlockElement at given node
The node to create InlineElement
The BlockElement result
Get a content traverser for current block element start from specified position
Start position of the traverser. Default value is ContentPosition.SelectionStart
A content traverser, or null if editor never got focus before
Get a content traverser for the whole editor
The node to start from. If not passed, it will start from the beginning of the body
Get current editor content as HTML string
specify what kind of HTML content to retrieve
HTML string representing current editor content
Get a text traverser of current selection
Optional, if specified, editor will try to get cached result from the event object first. If it is not cached before, query from DOM and cache the result into the event object
A content traverser, or null if editor never got focus before
Get custom data related to this editor
Key of the custom data
Getter function. If custom data for the given key doesn't exist, call this function to get one and store it if it is specified. Otherwise return undefined
An optional disposer function to dispose this custom data when dispose editor.
Get a darkColorHandler object for this editor.
Get default format of this editor
Default format object of this editor
Get document which contains this editor
The HTML document which contains this editor
Get DOM attribute of editor content DIV, null if there is no such attribute.
Name of the attribute
Get an HTML element from current cursor position. When expectedTags is not specified, return value is the current node (if it is HTML element) or its parent node (if current node is a Text node). When expectedTags is specified, return value is the first ancestor of current node which has one of the expected tags. If no element found within editor by the given tag, return null.
Optional, an HTML selector to find HTML element with.
Optional, start search from this node. If not specified, start from current focused position
Optional, if specified, editor will try to get cached result from the event object first. If it is not cached before, query from DOM and cache the result into the event object
Get current focused position. Return null if editor doesn't have focus at this time.
Get the pendable format state from the current selection, including formats as underline, bold, italics
If set to true, will not consider the cached format and will get the format state directly from DOM tree
The pending format state of editor.
The element to calculate from. If the given element is not in editor, return value will be null
When pass true, The return value will also add scrollLeft and scrollTop if any. So the value may be different than what user is seeing from the view. When pass false, scroll position will be ignored.
An [x, y] array which contains the left and top distances, or null if the given element is not in editor.
Get the scroll container of the editor
Get current selection in a serializable format It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
current selection path, or null if editor never got focus before
Get current selection range from Editor. It does a live pull on the selection, if nothing retrieved, return whatever we have in cache.
Set to true to retrieve the selection range from cache if editor doesn't own the focus now. Default value is true
current selection range, or null if editor never got focus before
Get current selection range from Editor. It does a live pull on the selection.
current selection range, or null if editor never got focus before
Get a content traverser for current selection
A content traverser, or null if editor never got focus before and no range is provided
Get style based format state from current selection, including font name/size and colors
Get a function to convert HTML string to trusted HTML string. By default it will just return the input HTML directly. To override this behavior, pass your own trusted HTML handler to EditorOptions.trustedHTMLHandler See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
Whether there is an available undo/redo snapshot
Retrieves the rect of the visible viewport of the editor.
Get current zoom scale, default value is 1 When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale to let editor behave correctly especially for those mouse drag/drop behaviors
current zoom scale number
Check if focus is in editor now
true if focus is in editor, otherwise false
Insert HTML content into editor
Insert options. Default value is: position: ContentPosition.SelectionStart updateCursor: true replaceSelection: true insertOnNewLine: false
Insert node into editor
The node to insert
Insert options. Default value is: position: ContentPosition.SelectionStart updateCursor: true replaceSelection: true insertOnNewLine: false
true if node is inserted. Otherwise false
Check if the editor is in dark mode
True if the editor is in dark mode, otherwise false
Get whether this editor is disposed
True if editor is disposed, otherwise false
Check whether the editor contains any visible content
Whether trim the content string before check. Default is false
True if there's no visible content, otherwise false
Check if the given experimental feature is enabled
The feature to check
Check if editor is in IME input sequence
True if editor is in IME input sequence, otherwise false
Check if editor is in Shadow Edit mode
Check if this position is at beginning of the editor. This will return true if all nodes between the beginning of target node and the position are empty.
The position to check
True if position is at beginning of the editor, otherwise false
Paste into editor using a clipboardData object
Clipboard data retrieved from clipboard
Force pasting as plain text. Default value is false
Query HTML elements in editor by tag name
Tag name of the element to query
An optional callback to be invoked on each element in query result
HTML Element array of the query result
Query HTML elements in editor by a selector string
Selector string to query
An optional callback to be invoked on each node in query result
HTML Element array of the query result
Query HTML elements with the given scope by tag name
Tag name of the element to query
The scope of the query, default value is QueryScope.Body
An optional callback to be invoked on each element in query result
HTML Element list of the query result
Query HTML elements with the given scope by a selector string
Selector string to query
The scope of the query, default value is QueryScope.Body
An optional callback to be invoked on each element in query result
HTML Element array of the query result
Redo next edit operation
Remove a Content Edit feature.
The feature to remove
Replace a node in editor content with another node
The existing node to be replaced
node to replace to
(optional) Whether to transform new node to dark mode. Default is false
true if node is replaced. Otherwise false
Select content by range
The range to select
True if content is selected, otherwise false
Select content by Position and collapse to this position
The position to select
True if content is selected, otherwise false
Select content by a start and end position
The start position to select
The end position to select, if this is the same with start, the selection will be collapsed
True if content is selected, otherwise false
Select content by node
The node to select
True if content is selected, otherwise false
Select content by node and offset, and collapse to this position
The node to select
The offset of node to select, can be a number or value of PositionType
True if content is selected, otherwise false
Select content by start and end nodes and offsets
The node to select start from
The offset to select start from
The node to select end to
The offset to select end to
True if content is selected, otherwise false
Select content by selection path
A selection path object
True if content is selected, otherwise false
Select content using the Table Selection
to select
first and last cell of the range, if null is provided will remove the selection on the table
Select content SelectionRangeEx
SelectionRangeEx object to specify what to select
Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered
HTML content to set in
True to trigger a ContentChanged event. Default value is true
Set the dark mode state and transforms the content to match the new state.
The next status of dark mode. True if the editor should be in dark mode, false if not.
Set DOM attribute of editor content DIV
Name of the attribute
Value of the attribute
Set current zoom scale, default value is 1 When editor is put under a zoomed container, need to pass the zoom scale number using EditorOptions.zoomScale to let editor behave correctly especially for those mouse drag/drop behaviors
Make the editor in "Shadow Edit" mode. In Shadow Edit mode, all format change will finally be ignored. This can be used for building a live preview feature for format button, to allow user see format result without really apply it. This function can be called repeated. If editor is already in shadow edit mode, we can still use this function to do more shadow edit operation.
Leave "Shadow Edit" mode, all changes made during shadow edit will be discarded
Transform the given node and all its child nodes to dark mode color if editor is in dark mode
The node to transform
The transform direction. @default ColorTransformDirection.LightToDark
Trigger a ContentChangedEvent
Source of this event, by default is 'SetContent'
additional data for this event
Trigger an event to be dispatched to all plugins
Type of the event
data of the event with given type, this is the rest part of PluginEvent with the given type
indicates if the event needs to be dispatched to all plugins True means to all, false means to allow exclusive handling from one plugin unless no one wants that
the event object which is really passed into plugins. Some plugin may modify the event object so the result of this function provides a chance to read the modified result
Undo last edit operation
Generated using TypeDoc
Interface of roosterjs editor object