Creates an instance of Editor
The DIV HTML element which will be the container element of editor
An optional options object to customize the editor
Add a Content Edit feature.
The feature to add
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 press Backspace key (aka Auto Complete).
Announce the given data
Data to announce
Attach a DOM event to the editor content DIV
A map from event name to its handler
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
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
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.
The general API to do format change with Content Model It will grab a Content Model for current editor content, and invoke a callback function to do format change. Then according to the return value, write back the modified content model into editor. If there is cached model, it will be used and updated.
Formatter function, see ContentModelFormatter
More options, see FormatContentModelOptions
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 a color manager object for this editor.
Get current editor content as HTML string
specify what kind of HTML content to retrieve
HTML string representing current editor content
Create Content Model from DOM tree in this editor
What kind of Content Model we want. Currently we support the following values:
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
the current EditorCore object
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 DOM Helper object to help access DOM tree in editor
Get current DOM selection
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.
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 running environment, such as if editor is running on Mac
Get current focused position. Return null if editor doesn't have focus at this time.
The pending format state
Get pending format of editor if any, or return null
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 impacted regions from selection
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, if nothing retrieved, return whatever we have in cache.
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
Get undo snapshots manager
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 a given feature is enabled
The name of feature to check
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
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
Restore an undo snapshot into editor
The snapshot to restore
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 DOMSelection into editor content.
The selection to set
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
Add CSS rules for editor
A string to identify the CSS rule type. When set CSS rules with the same key again, existing rules with the same key will be replaced.
The CSS rule string, must be a valid CSS rule string, or browser may throw exception. Pass null to clear existing rules
@optional If the rule is used for child element under editor, use this parameter to specify the child elements. Each item will be combined with root selector together to build a separate rule.
Set a new logical root (most likely due to focus change)
The new logical root (has to be child of physicalRoot)
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
The new scale number to set. It should be positive number and no greater than 10, otherwise it will be ignored.
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
Add a single undo snapshot to undo stack
@optional State for entity if we want to add entity state for this snapshot
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
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
Editor for Content Model.