Browser object contains browser and operating system information of current environment
All known CreateElementData used by roosterjs to create elements
A map from pendable format name to document command
Adds delimiter after the element provided.
element to use
Adds delimiter before the element provided.
element to use
Adds delimiters to the element provided. If the delimiters already exists, will not be added
the node to add the delimiters
Add the given range into selection of the given document
The range to select
When set to true, do nothing if the given range is the same with current selection, otherwise it will always remove current selection range and set to the given one. This parameter is always treat as true in Edge to avoid some weird runtime exception.
Add a new snapshot to the given snapshots data structure
The snapshots data structure to add new snapshot into
The snapshot HTML to add
Whether this is a snapshot before auto complete action
Add a new snapshot to the given snapshots data structure
The snapshots data structure to add new snapshot into
The generic snapshot object to add
Whether this is a snapshot before auto complete action
A callback function to calculate length of the snapshot
A callback function to check if the given snapshots are the same
the contentDiv of the ditor
the node to be inserted
the position of the node to be inserted
the range current or cached range of the editor
the adjusted position of the inserted node
Apply format to an HTML element
The HTML element to apply format to
The format to apply
Whether the content should be formatted in dark mode
An optional dark color handler object. When it is passed, we will use this handler to do variable-based dark color instead of original dataset base dark color
Apply style using a styler function to the given container node in the given range
The container node to apply style to
The styler function
A type-safe wrapper for Array.prototype.push.apply()
The main array to push items into
The items to push to main array
Gets the cached event data by cache key from event object if there is already one. Otherwise, call getter function to create one, and cache it.
The event object
Cache key string, need to be unique
Getter function to get the object when it is not in cache yet
Check whether can move current snapshot with the given step
The snapshots data structure to check
The step to check, can be positive, negative or 0
True if can move current snapshot with the given step, otherwise false
Whether there is a snapshot added before auto complete and it can be undone now
Chain all callback for an attribute together
The source callback map
Name of the property to chain
A new callback to process the given name on the given map. If the same property got multiple callbacks, the final return value will be the return value of the latest callback
Change tag of an HTML Element to a new one, and replace it from DOM tree
The element to change tag
New tag to change to
The new element with new tag
Change tag of an HTML Element to a new one, and replace it from DOM tree
The element to change tag
New tag to change to
The new element with new tag
Clear a cached object by its key from an event object
The event object
The cache key
Clear all snapshots after the current one
The snapshots data structure to clear
Clear all snapshots after the current one
The snapshots data structure to clear
Collapse nodes within the given start and end nodes to their common ancestor node, split parent nodes if necessary
The root node of the scope
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
Collapse nodes within this region to their common ancestor node under this region
The region to collapse nodes in.
Nodes or block elements to collapse. When take BlockElement[] as input, start node of the first BlockElement and end node of the last BlockElement will be used as the nodes. All nodes not contained by the given region will be ignored.
Commit information of an entity (type, isReadonly, id) into the wrapper node as CSS Classes
The entity wrapper element
Entity type
Whether this is a readonly entity
Optional Id of the entity
Test if a node contains another node
The container node
The node to check if it is inside container
When container and contained are the same node, return true if this param is set to true, otherwise return false. Default value is false
True if contained is inside container, or they are the same node when treatSameNodeAsContain is true. Otherwise false.
Test if a node contains a given range
The container node
The range to check if it is inside container
True if contained is inside container, otherwise false
Convert decimal numbers into english alphabet letters
The decimal number that needs to be converted
if true the roman value will appear in lower case
Convert decimal numbers into roman numbers
The decimal number that needs to be converted
if true the roman value will appear in lower case
Create an array definition
Definition of each item of the related array
Whether this property is optional
Allow the property to be null
The array definition object
Create a boolean definition
Whether this property is optional
Optional expected boolean value
Allow the property to be null
The boolean definition object
Create default value of HtmlSanitizerOptions with every property set
Create DOM element from the given CreateElementData
The CreateElementData or an index of a known CreateElementData used for creating this element
The document to create the element from
The root DOM element just created
The entity to create placeholder from
A placeholder comment node as
Create a number definition
Whether this property is optional
Optional value of the number
Optional minimum value
Optional maximum value
Allow the property to be null
The number definition object
Create an object definition
Definition of each property of the related object
Whether this property is optional
Allow the property to be null
The object definition object
Create a range around the given node(s)
The start node to create range from
The end node to create range from. If specified, the range will start before startNode and end after endNode, otherwise, the range will start before and end after the start node
A range start before the given node and end after the given node
Create a collapsed range at the given node and offset
The container node of the range
The offset of the range, can be a number or value of PositionType
A range at the given node and offset
Create a range with the given start/end container node and offset
The start container node of the range
The start offset of the range
The end container node of the range
The end offset of the range
A range at the given start/end container node and offset
Create a range under the given rootNode with start and end selection paths
The root node that the selection paths start from
The selection path of the start position of the range
The selection path of the end position of the range
A range with the given start and end selection paths
Create a range with the start and end position
The start position of the range
The end position of the range, if not specified, the range will be collapsed at start position
A range start at startPosition, end at endPosition, or startPosition when endPosition is not specified
Create initial snapshots
max size of all snapshots
Create a string definition
Whether this property is optional
Optional expected string value
Allow the property to be null
The string definition object
Create a VList object from the given region.
The region to get VList from
True to also try get lists before and after the selection and merge them together, false to only include the list for the selected blocks
(Optional) When specified, try get VList which will contain this node. If not specified, get VList from selection of this region
Delete selected content, and return the new position to select
The range to delete
The paste event
Callback function when data is ready
Options to retrieve more items from the event, including HTML string and other customized items
Optional range to be removed when pasting in Android
An object with the following properties: types: Available types from the clipboard event text: Plain text from the clipboard event image: Image file from the clipboard event html: Html string from the clipboard event. When set to null, it means there's no HTML found from the event. When set to undefined, it means can't retrieve HTML string, there may be HTML string but direct retrieving is not supported by browser.
Extract clipboard items to be a ClipboardData object for IE
The clipboard items retrieve from a DataTransfer object
An object with the following properties: types: Available types from the clipboard event text: Plain text from the clipboard event image: Image file from the clipboard event html: Html string from the clipboard event. When set to null, it means there's no HTML found from the event. When set to undefined, it means can't retrieve HTML string, there may be HTML string but direct retrieving is not supported by browser.
Extract clipboard items to be a ClipboardData object for IE
The clipboard items retrieve from a DataTransfer object
Callback function when data is ready
An object with the following properties: types: Available types from the clipboard event text: Plain text from the clipboard event image: Image file from the clipboard event html: Html string from the clipboard event. When set to null, it means there's no HTML found from the event. When set to undefined, it means can't retrieve HTML string, there may be HTML string but direct retrieving is not supported by browser.
Extract content metadata from DOM tree
Root of the DOM tree
If there is a valid content metadata node in the give DOM tree, return this metadata object, otherwise undefined
Find closest element ancestor start from the given node which matches the given selector
Find ancestor start from this node
Root node where the search should stop at. The return value can never be this node
The expected selector. If null, return the first HTML Element found from start node
An HTML element which matches the given selector. If the given start node matches the selector, returns the given node
the html string to create HTML elements from
Owner document of the result HTML elements
An HTML node array to represent the given html string
This produces a block element from a a node It needs to account for various HTML structure. Examples:
Root node of the scope, the block element will be inside of this node
The node to get BlockElement start from
Get current browser information from user agent string
The userAgent string of a browser
The appVersion string of a browser
The vendor string of a browser
The BrowserInfo object calculated from the given userAgent and appVersion
A shortcut for getComputedStyles() when only one style is to be retrieved
The node to get style from
The style name
The style value
Get computed styles of a node
The node to get computed styles from
Names of style to get, can be a single name or an array. Default value is font-family, font-size, color, background-color
An array of the computed styles
Retrieves Delimiter information from a provided element.
element to try to retrieve a delimiter
delimiter info if it is a Delimiter, else null
Get Entity object from an entity root element
The entity root element. If this element is not an entity root element, it will return null
Get a selector string for specified entity type and id
(Optional) Type of entity
(Optional) Id of entity
Get the first/last BlockElement of under the root node. If no suitable BlockElement found, returns null
The root node to get BlockElement from
True to get first BlockElement, false to get last BlockElement
Get the first meaningful leaf node
Root node to get leaf node from
Get inner Html of a root node with a selection path which can be used for restore selection. The result string can be used by setHtmlWithSelectionPath() to restore the HTML and selection.
Root node to get inner Html from
The range of selection. If pass null, no selection path will be added
Inner HTML of the root node, followed by HTML comment contains selection path if the given range is valid
Get inheritable CSS style values from the given element
The element to get style from
Get the inline element at a node
The root node of current scope
The node to get InlineElement from
Get the inline element at a node
Parent BlockElement of this node
The node to get InlineElement from
Get innerHTML of the given node
The DOM node to get innerHTML from
Get the last meaningful leaf node
Root node to get leaf node from
Get metadata object from an HTML element
The HTML element to get metadata object from
The type definition of this metadata used for validate this metadata object. If not specified, no validation will be performed and always return whatever we get from the element
The default value to return if the retrieved object cannot pass the validation, or there is no metadata object at all
The strong-type metadata object if it can be validated, or null
This walks forwards DOM tree to get next meaningful node
Root node to scope the leaf sibling node
current node to get sibling node from
(Optional) tags that child elements will be skipped
Provide a strong-typed version of Object.keys()
The source object
Array of keys
This function tries to get the source of the Pasted content
the before paste event
Whether convert single image is enabled.
The Type of pasted content, if no type found will return {KnownSourceType.Default}
Get the paste type that will be used corresponding to the configuration
Whether to paste as Text
Whether to apply the current format to the content
Whether to only paste the image
Get Pendable Format State at cursor.
The HTML Document to get format state from
A PendableFormatState object which contains the values of pendable format states
Get bounding rect of this position
The position to get rect from
This walks backwards DOM tree to get next meaningful node
Root node to scope the leaf sibling node
current node to get sibling node from
(Optional) tags that child elements will be skipped
Get regions impacted by the given range under the root node
Root node to get regions from
A selection range. Regions will be created according to this range. Each region will be fully or partially covered by this range.
Type of region. Currently we only support TABLE region.
Get all block elements covered by the selection under this region
The region to get block elements from
When set to true, a new empty block element will be created if there is not any blocks in the region. Default value is false
Deprecated parameter, not used
Get path of the given selection range related to the given rootNode
The root node where the path start from
The range of selection
Get the selection range in the given region. The original range can cover multiple regions, this function will narrow the original selection of a region into current region
The region to get range from
Get CSS styles of a given element in name-value pair format
The element to get styles from
The table cell to use
Get the format info of a table If the table does not have a info saved, it will be retrieved from the css styles
The table that has the info
Get the html tag of a node, or empty if it is not an element
The node to get tag of
Tag name in upper case if the given node is an Element, or empty string otherwise
get block element's text content.
Root node that the get the textContent of.
text content of given text content.
Handles the content when using the Image Paste Option
the image uri to use for the image
fragment that will contain the content to paste.
handle the content when using the text only option
Text from clipboard
current position of the clipboard
fragment that contains the paste content.
Checks if the node is a block like element. Block like element are usually those P, DIV, LI, TD etc.
The node to check
True if the node is a block element, otherwise false
Returns true when the event was fired from a key that produces a character value, otherwise false This detection is not 100% accurate. event.key is not fully supported by all browsers, and in some browsers (e.g. IE), event.key is longer than 1 for num pad input. But here we just want to improve performance as much as possible. So if we missed some case here it is still acceptable.
The keyboard event object
Check if Ctrl key (Windows) or Meta key (Mac) is pressed for the given Event
A Keyboard event or Mouse event object
True if Ctrl key is pressed on Windows or Meta key is pressed on Mac
Returns true when the event was fired from a modifier key, otherwise false
The keyboard event object
Checks if node1 is after node2
The node to check if it is after another node
The node to check if another node is after this one
True if node1 is after node2, otherwise false
Check if a given node has no visible content
The node to check
Whether trim the text content so that spaces will be treated as empty. Default value is false
True if there isn't any visible element inside node, otherwise false
Check if a given node is contained by the given region
The region to check from
The node or block element to check
Check if this position is at beginning of the given node. This will return true if all nodes between the beginning of target node and the position are empty.
The position to check
The node to check
True if position is at beginning of the node, otherwise false
Check if the given node is html void element. Void element cannot have children
The node to check
Check if the whole table is selected
VTable to check whether all cells are selected
Table selection with first cell selected and last cell selected coordinates.
Try to match a given string with link match rules, return matched link
Input url to match
The matched link data, or null if no match found. The link data includes an original url and a normalized url
A wrapper function of Element.matches
The element to match
The selector to match
Merge a BlockElement of given node after another node
Region to operate in
The node to merge after
The node of target block element
Replace all child nodes of the given target node to the child nodes of source node.
Target node, all child nodes of this node will be removed if keepExistingChildren is not set to true
(Optional) source node, all child nodes of this node will be move to target node
(Optional) When set to true, all existing child nodes of target will be kept
Move content from a container into a new Document fragment, and try keep entities to be reusable by creating placeholder for them in the document fragment. If an entity is directly under root container, the whole entity can be reused and no need to move it at all. If an entity is not directly under root container, it is still reusable, but it may need some movement. In any case, entities will be replaced with a placeholder in the target document fragment. We will use an entity map (the "entities" parameter) to save the map from entity id to its wrapper element.
The root element
A map from entity id to entity wrapper element
A new document fragment contains all the content and entity placeholders
Move current snapshot with the given step if can move this step. Otherwise no action and return null
The snapshots data structure to move
The step to move
If can move with the given step, returns the snapshot after move, otherwise null
A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p We validate that and only return a rect when the passed in ClientRect is valid
Parse color string to r/g/b value. If the given color is not in a recognized format, return null
Query HTML elements in the container by a selector string
Container element to query from
Selector string to query
An optional callback to be invoked on each node in query result
The scope of the query, default value is QueryScope.Body
The selection range to query with. This is required when scope is not Body
HTML Element array of the query result
Read a file object and invoke a callback function with the data url of this file
The file to read
the callback to invoke with data url of the file. If fail to read, dataUrl will be null
Remove a css rule style from a style sheet
The document object
the ID of the style tag
Removes the css important rule from some css properties
The HTMLElement
The css properties that important must be removed. Ex: ['background-color', 'background']
Remove metadata from the given element if any
The element to remove metadata from
The metadata key to remove, if none provided it will delete all metadata
Restore HTML content from a document fragment that may contain entity placeholders.
Source document fragment that contains HTML content and entity placeholders
Target container, usually to be editor root container
A map from entity id to entity wrapper, used for reusing existing DOM structure for entity
When pass true, merge with a cloned copy of the nodes from source fragment rather than the nodes themselves @default false
Retrieves the metadata from the content inside of the clipboard
Document parsed from the clipboard
Before Paste event
the trusted html handler to sanitize the content.
Check if the given object is instance of the target type
Object to check
Target type name
Sanitize the content from the pasted content
The before paste event
the position of the cursor
Add metadata to a cell
The table cell to add the metadata
The format of the table
Set text color or background color to the given element
The element to set color to
The color to set, it can be a string of color name/value or a ModeIndependentColor object
Whether set background color or text color
Whether current mode is dark mode. @default false
Whether the font color needs to be adapted to be visible in a dark or bright background color. @default false
A dark color handler object. This is now required. We keep it optional only for backward compatibility. If it is not passed, color will not be set.
Add global css styles
The document object
The css rule that must added to the selection
The id of the style tag
Restore inner HTML of a root element from given html string. If the string contains metadata, remove it from DOM tree and return the metadata
The HTML to restore
An optional trusted HTML handler to convert HTML string to security string
Content metadata if any, or undefined
The HTML to restore
An optional trusted HTML handler to convert HTML string to security string
A selection range if the html contains a valid selection path, otherwise null
Set the Style of a List Item provided, with the styles that the inline child elements have If the child inline elements have different styles, it will not modify the styles of the list item
the LI Element to set the styles
The styles that should be applied to the element.
True means the given styles are CSS style names, false means they are HTML attributes @default true
Set metadata object into an HTML element
The HTML element to set metadata object to
The metadata object to set
An optional type definition object used for validate this metadata object. If not specified, metadata will be set without validation
True if metadata is set, otherwise false
Set styles to an HTML element. If styles are empty, remove 'style' attribute
The element to set styles
The styles to set, in name-value pair format
Split parent node by a balanced node range
The nodes to split from. If only one node is passed, split it from all its siblings. If two or nodes are passed, will split before the first one and after the last one, all other nodes will be ignored
The parent node of the given node range if the given nodes are balanced, otherwise null
Split parent node of the given node before/after the given node. When a parent node contains [A,B,C] and pass B as the given node, If split before, the new nodes will be [A][B,C] and returns [A]; otherwise, it will be [A,B][C] and returns [C].
The node to split before/after
Whether split before or after
The new parent node
Split a text node into two parts by an offset number, and return one of them
The text node to split
The offset number to split at
True to return the first part, then the passed in textNode will become the second part. Otherwise return the second part, and the passed in textNode will become the first part
Convert a named node map to an array
The map to convert
Convert a named node map to an array
The map to convert
Convert a collection to an array
The collection to convert
Convert a collection to an array
The collection to convert
Convert an array to an array. This is to satisfy typescript compiler. For some cases the object can be a collection at runtime, but the declaration is an array. e.g. ClipboardData.types
The array to convert
Removes the node and keep all children in place, return the parentNode where the children are attached
the node to remove
Validate the given object with a type definition object
The object to validate
The type definition object used for validation
True if the object passed the validation, otherwise false
Wrap all the node with html and return the wrapped node, and put the wrapper node under the parent of the first node
The node or node array to wrap
The wrapper HTML tag name
The wrapper element
The node or node array to wrap
The wrapper HTML string, default value is DIV
The wrapper element
Wrap all the nodes with html and return the wrapped node, and put the wrapper node under the parent of the first node
The node or node array to wrap
The wrapper HTML element, default value is a new DIV element
The wrapper element
Wraps all the nodes with CreateElementData or an index of a known CreateElementData
The nodes to wrap
The CreateElementData or an index of a known CreateElementData
Generated using TypeDoc
Names of Pendable formats