Skip to content

RoosterJs 8 types

Jiuqing Song edited this page Jan 12, 2021 · 1 revision

Changes in roosterjs-editor-types package in RoosterJs 8.0.0

Removed interfaces/types

PasteOption enum

(Removed from 8.0.0)

To specify paste type when handle BeforePasteEvent, modify the DOM tree under BeforePasteEvent.fragment directly.

ExtractContentEvent interface

(Removed from 8.0.0)

Use ExtractContentWithDomEvent instead.

DarkModeChangedEvent interface

(Removed from 8.0.0)

Use ContentChangedEvent instead, check source = ChangeSource.SwitchToDarkMode or ChangeSource.SwitchToLightMode

ClipboardItem interface

(Removed from 8.0.0)

Use ClipboardData instead

DarkModeOptions interface

(Removed from 8.0.0)

Use onExternalContentTransform directly

Interfaces/Types moved from other packages

CorePlugins interface

(moved from roosterjs-editor-core package)

An interface for editor core plugins Reference

New members:

Name Description
pendingFormatState PendingFormatStatePlugin handles pending format state management
entity Entity Plugin handles all operations related to an entity and generate entity specified events
lifecycle Copy and paste plugin for handling onCopy and onPaste event
copyPaste

Removed members:

Name Description
copyPlugin Merged into copyPaste plugin
pastePlugin Merged into copyPaste plugin

Renamed members:

Old Name New Name Description
firefoxTypeAfterLink TypeAfterLinkPlugin plugin helps workaround a Firefox bug to allow type outside a hyperlink Callbacks for CSS styles

EditorCore interface

(Moved from roosterjs-editor-core package)

Represents the core data structure of an editor Reference

Removed members:

Name Description
document This can be calcuated from contentDiv
scrollContainer Moved to DOMEventPluginState
eventHandlerPlugins No need to have it
defaultFormat Moved to LifecyclePluginState
corePlugins Merged into plugins
customData Moved to LifecyclePluginState
defaultApi No need to have it
currentUndoSnapshot Moved to UndoPluginState
cachedSelectionRange No need to have it
inDarkMode Moved to LifecyclePluginState
darkModeOptions No need to have it

CoreApiMap interface

(Moved from roosterjs-editor-core package)

A map of all core API functions Reference

New members:

Name Description
ensureTypeInContainer Ensure user will type into a container element rather than into the editor content DIV directly
getContent Get current editor content as HTML string
restoreUndoSnapshot Set HTML content to this editor
setContent Edit and transform color of elements between light mode and dark mode
transformColor

Removed members:

Name Description
getCustomData Noe need to have it
select Use selectRange instead

Renamed members:

Old Name New Name Description
editWithUndo addUndoSnapshot Call an editing callback with adding undo snapshots around

EditorOptions interface

(Moved from roosterjs-editor-core package)

The options to specify parameters customizing an editor, used by ctor of Editor class Reference

New members:

Name Description
undoSnapshotService Undo snapshot service. Use this parameter to customize the undo snapshot service.
corePluginOverride A plugin map to override default core Plugin implementation Default value is null
onExternalContentTransform Allow propagation of keyboard event
allowKeyboardEventPropagation Specify the enabled experimental features
experimentalFeatures

Removed members:

Name Description
undo Use undoSnapshotService instead
disableRestoreSelectionOnFocus No need to have it
omitContentEditableAttributeChanges Set contenteditable attribute on editor DIV directly instead
additionalEditFeatures Call IEditor.addContentEditFeature instead
darkModeOptions Use onExternalContentTransform instead
customData No need to have it
enableExperimentFeatures Use experimentalFeatures instead

ContentEditFeature type

(Moved from roosterjs-editor-core package)

ContentEditFeature interface that handles keyboard event Reference

GenericContentEditFeature interface

(Moved from roosterjs-editor-core package)

Generic ContentEditFeature interface Reference

EditorPlugin interface

(Moved from roosterjs-editor-core package)

Interface of an editor plugin Reference

CreatePasteFragment type

(Moved from roosterjs-editor-core package)

Create a DocumentFragment for paste from a ClipboardData Reference

Focus type

(Moved from roosterjs-editor-core package)

Focus to editor. If there is a cached selection range, use it as current selection Reference

GetSelectionRange type

(Moved from roosterjs-editor-core package)

Get current or cached selection range Reference

GetStyleBasedFormatState type

(Moved from roosterjs-editor-core package)

Get style based format state from current selection, including font name/size and colors Reference

HasFocus type

(Moved from roosterjs-editor-core package)

Check if the editor has focus now Reference

InsertNode type

(Moved from roosterjs-editor-core package)

Insert a DOM node into editor content Reference

SelectRange type

(Moved from roosterjs-editor-core package)

Change the editor selection to the given range Reference

TriggerEvent type

(Moved from roosterjs-editor-core package)

Trigger a plugin event Reference

CustomReplacment interface

(Moved from roosterjs-editor-plugins package)

An interface to define a replacement rule for CustomReplace plugin Reference

UndoSnapshotsService interface

(Moved from roosterjs-editor-core package)

Represent an interface to provide functionalities for Undo Snapshots Reference

New members:

Name Description
canUndoAutoComplete Whether there is a snapshot added before auto complete and it can be undone now

PickerDataProvider interface

(Moved from roosterjs-editor-plugins package)

Data provider for PickerPlugin Reference

PickerPluginOptons interface

(Moved from roosterjs-editor-plugins package)

Options for PickerPlugin Reference

VCell interface

(Moved from roosterjs-editor-dom package)

Represent a virtual cell of a virtual table Reference

CssStyleCallbackMap type

(Moved from roosterjs-editor-dom package)

A map of style callbacks. Style name should be in lower case Reference

New types/interfaces/enums

IEditor interface

(New in 8.0.0)

A new IEditor interface is introduced and all places that Editor was used as parameter are now replaced by IEditor. Reference

New members:

Name Description
addContentEditFeature Add a Content Edit feature.
addDomEventHandler Add a custom DOM event handler to handle events not handled by roosterjs. Caller need to take the responsibility to dispose the handler properly
addUndoSnapshot Add undo snapshot, and execute a format callback function
collapseNodes Collapse nodes within the given start and end nodes to their common ascenstor node
contains Check if the node falls in the editor content
deleteNode Delete a node from editor content
deleteSelectedContent Delete selected content
dispose Dispose this editor, dispose all plugins and custom data
ensureTypeInContainer Ensure user will type into a container element rather than into the editor content DIV directly
focus Focus to this editor, the selection was restored to where it was before, no unexpected scroll.
getBlockElementAtNode Get BlockElement at given node
getBlockTraverser Get a content traverser for current block element start from specified position
getBodyTraverser Get a content traverser for the whole editor
getContent Get current editor content as HTML string
getContentSearcherOfCursor Get a text traverser of current selection
getCustomData Get custom data related to this editor
getDefaultFormat Get default format of this editor
getDocument Get document which contains this editor
getEditorDomAttribute Get DOM attribute of editor content DIV
getElementAtCursor Get an HTML element from current cursor position
getFocusedPosition Get current focused position
getScrollContainer Get the scroll container of the editor
getSelectedRegions Get impacted regions from selection
getSelectionPath Get current selection in a serializable format It does a live pull on the selection
getSelectionRange Get current selection range from Editor.
getSelectionTraverser Get a content traverser for current selection
getStyleBasedFormatState Get style based format state from current selection
getUndoState Whether there is an available undo/redo snapshot
hasFocus Check if focus is in editor now
insertContent Insert HTML content into editor
insertNode Insert node into editor
isDarkMode Check if the editor is in dark mode
isDisposed Get whether this editor is disposed
isEmpty Check whether the editor contains any visible content
isFeatureEnabled Check if the given experimental feature is enabled
isInIME Check if editor is in IME input sequence
isPositionAtBeginning Check if this position is at beginning of the editor.
paste Paste into editor using a clipboardData object
queryElements Query HTML elements in editor by tag name
redo Redo next edit operation
replaceNode Replace a node in editor content with another node
runAsync Run a callback function asynchronously
select Select content by range
setContent Set HTML content to this editor
setDarkModeState Set the dark mode state and transforms the content to match the new state
setEditorDomAttribute Set DOM attribute of editor content DIV
triggerContentChangedEvent Trigger a ContentChangedEvent
triggerPluginEvent Trigger an event to be dispatched to all plugins
undo Undo last edit operation

ColorTransformDirection enum

(New in 8.0.0)

Represents the mode of color transformation. Reference

New members:

Name Description
DarkToLight Transform from dark to light
LightToDark Transform from light to dark

DarkModeDatasetNames enum

(New in 8.0.0)

Constants string for dataset names used by dark mode. Reference

New members:

Name Description
OriginalStyleColor Original style text color
OriginalStyleBackgroundColor Original style background color
OriginalAttributeColor Original attribute text color
OriginalAttributeBackgroundColor Original attribute background color

EntityClasses enum

(New in 8.0.0)

CSS Class names for Entity. Reference

New members:

Name Description
ENTITY_INFO_NAME Class name to specify this is an entity
ENTITY_TYPE_PREFIX Class name to specify the type of an entity
ENTITY_ID_PREFIX Class name to specify the ID of an entity
ENTITY_READONLY_PREFIX Class name to specify if the entity is readonly

ExperimentalFeatures enum

(New in 8.0.0)

Experimental feature flags. Reference

New members:

Name Description
ListChain Enable List Chain for numbering list
MergePastedLine When paste, try merge pasted content to the same line with existing content
NewBullet Toggle bullet using VList
NewIndentation Toggle indentation using VList
NewNumbering Toggle numbering using VList
PasteWithLinkPreview Try retrieve link preview information when paste
SingleDirectionResize Resize an image horizontally or vertically

GetContentMode enum

(New in 8.0.0)

Represents a mode number to indicate what kind of content to retrieve when call Editor.getContent(). Reference

New members:

Name Description
CleanHTML The clean content without any temporary content only for editor.
PlainText Get plain text content only, all format will be ignored
RawHTMLOnly Retrieve the raw HTML string in current editor. Temporary content will be included.
RawHTMLWithSelection Retrieve the raw HTML string in current editor with a selection marker. 

BeforeCutCopyEvent interface

Provides a chance for plugin to change the content before it is copied from editor. Reference

(New in 8.0.0)

New members:

Name Description
rawEvent Raw DOM event
clonedRoot An object contains all related data for pasting
range The selection range under cloned root
isCut Whether this is a cut event

ExtractContentWithDomEvent interface

(New in 8.0.0)

Extract Content with a DOM tree event Reference

New members:

Name Description
clonedRoot Cloned root element of editor Plugin can change this DOM tree to clean up the markups it added before
eventDataCache An optional event cache. This will be consumed by event cache API to store some expensive calculation result. So that for the same event across plugins, the result doesn't need to be calculated again
eventType Type of this event

PluginContextMenuEvent interface

(New in 8.0.0)

Represents a PluginEvent wrapping native ContextMenu event Reference

New members:

Name Description
items A callback array to let edtior retrieve context menu itesm related to this event. 

EditorUndoState interface

(New in 8.0.0)

Specify if editor can undo/redo an editing operation. Reference

New members:

Name Description
canUndo Whether the content can be undone
canRedo Whether the content can be redone

ExtractClipboardEventOption interface

(New in 8.0.0)

Options for extractClipboardEvent API. Reference

New members:

Name Description
allowLinkPreview Whether retrieving value of text/link-preview is allowed

IContentTraverser interface

(New in 8.0.0)

Interface of ContentTraverser, provides traversing of content inside editor. Reference

New members:

Name Description
currentBlockElement Get current block element
currentInlineElement Get current inline element
getNextBlockElement Get next block element
getNextInlineElement Get next inline element
getPreviousBlockElement Get previous block element
getPreviousInlineElement Get previous inline element

IPositionContentSearcher interface

(New in 8.0.0)

Interface of PositionContentSearcher, help search content around a position. Reference

New members:

Name Description
forEachTextInlineElement Get text section before position till stop condition is met
getInlineElementAfter Get the inline element after position
getInlineElementBefore Get the inline element before position
getNearestNonTextInlineElement Get first non textual inline element before position
getRangeFromText Try to get a range matches the given text before the position
getSubStringBefore Get X number of chars before position
getWordBefore Get the word before position

RegionBase interface

(New in 8.0.0)

Represents a DOM region. Reference

New members:

Name Description
nodeAfter A node to define the ending boundary of this region
nodeBefore A node to define the beginning boundary of this region
rootNode Root node of this region
skipTags Tags that child elements will be skipped

BuildInEditFeature interface

(New in 8.0.0)

RoosterJs build in content edit feature Reference

New base interfaces:

Name Description
GenericContentEditFeature Generic ContentEditFeature interface

New members:

Name Description
defaultDisabled Whether this edit feature is disabled by default

PluginWithState interface

(New in 8.0.0)

An editor plugin which have a state object stored on editor core so that editor and core api can access it Reference

New members:

Name Description
getState Get plugin state object

ContentEditFeatureSettings inteface

(New in 8.0.0)

A list to specify whether each of the listed content edit features is enabled Reference

New base interfaces:

Name Description
ListFeatureSettings Settings for list features
QuoteFeatureSettings Settings for quote features
TableFeatureSettings Settings for table features
StructuredNodeFeatureSettings Settings for structured node features
AutoLinkFeatureSettings Settings for auto link features
ShortcutFeatureSettings Settings for shortcut features
CursorFeatureSettings Settings for cursor features
MarkdownFeatureSettings Settings for mark down features
EntityFeatureSettings Settings for entity features

AutoLinkFeatureSettings interface

(New in 8.0.0)

Settings for auto link features Reference

New members:

Name Description
autoLink When press Space or Enter after a hyperlink-like string, convert the string to a hyperlink
unlinkWhenBackspaceAfterLink Unlink when backspace right after a hyperlink

CursorFeatureSettings interface

(New in 8.0.0)

Settings for cursor features Reference

New members:

Name Description
noCycleCursorMove Chrome may make the cursor move the then end of document if press Ctrl+Left at the beginning of document Let's disable this behaivor

EntityFeatureSettings interface

(New in 8.0.0)

Settings for entity features Reference

New members:

Name Description
backspaceAfterEntity A content edit feature to trigger EntityOperation event with operation "RemoveFromEnd" when user press BACKSPACE right after an entity
clickOnEntity A content edit feature to trigger EntityOperation event with operation "Click" when user clicks on a readonly entity.
deleteBeforeEntity A content edit feature to trigger EntityOperation event with operation "RemoveFromStart" when user press DELETE right after an entity
enterBeforeReadonlyEntity A content edit feature to split current line into two lines at the cursor when user presses ENTER right before a readonly entity.
escapeFromEntity A content edit feature to trigger EntityOperation event with operation "Escape" when user presses ESC on a readonly entity.

ListFeatureSettings interface

(New in 8.0.0)

Settings for list features Reference

New members:

Name Description
autoBullet When press space after an asterik or number in an empty line, toggle bullet/numbering
indentWhenTab When press Tab in a list, indent current list item
maintainListChain When edit with lists, maintain the list numbers of list chain
mergeInNewLineWhenBackspaceOnFirstChar When press Backspace on first char in a list, make current item a new line of previous list item
outdentWhenBackspaceOnEmptyFirstLine When press BaskSpace on empty line which is the first item of a list, outdent current list item
outdentWhenEnterOnEmptyLine When press Enter on empty line in a list, outdent current list item
outdentWhenShiftTab When press Shift+Tab in a list, outdent current list item

MarkdownFeatureSettings interface

(New in 8.0.0)

Settings for mark down features Reference

New members:

Name Description
markdownBold When typing text surrounded by '*', the symbols will be removed and the text will be bolded.
markdownInlineCode When typing text surrounded by '`', the symbols will be removed and the text will be wrapped in a code tag.
markdownItalic When typing text surrounded by '_', the symbols will be removed and the text will be italicized.
markdownStrikethru When typing text surrounded by '~', the symbols will be removed and the text will be striked through.

QuoteFeatureSettings interface

(New in 8.0.0)

Settings for quote features Reference

New members:

Name Description
unquoteWhenBackspaceOnEmptyFirstLine When press BAckspace on empty line which is the first line of a blockquote, unquote current line
unquoteWhenEnterOnEmpty When press Enter on empty line in a blockquote, unquote current line

ShortcutFeatureSettings interface

(New in 8.0.0)

Settings for shortcut features Reference

New members:

Name Description
defaultShortcut Respond to default common keyboard short, i.e. Ctrl+B, Ctrl+I, Ctrl+U, Ctrl+Z, Ctrl+Y

StructuredNodeFeatureSettings interface

(New in 8.0.0)

Settings for structured node features Reference

New members:

Name Description
insertLineBeforeStructuredNodeFeature When press Enter at the beginning of first structured element (table, list) and there isn't line before the position we create a new line before so that user got a chance to enter content before the table or list

TableFeatureSettings interface

(New in 8.0.0)

Settings for table features Reference

New members:

Name Description
tabInTable When press TAB or SHIFT+TAB key in table cell, jump to next/previous table cell
upDownInTable When press Up or Down in table cell, jump to the table cell above/below

DOMEventPluginState interface

(New in 8.0.0)

The state object for DOMEventPlugin Reference

New members:

Name Description
contextMenuProviders Context menu providers, that can provide context menu items
isInIME Whether editor is in IME input sequence
scrollContainer Scroll container of editor
selectionRange Cached selection range
stopPrintableKeyboardEventPropagation stop propagation of a printable keyboard event

EditPluginState interface

(New in 8.0.0)

The state object for EditPlugin Reference

New members:

Name Description
features All content edit features sorted by their keys

EntityPluginState interface

(New in 8.0.0)

The state object for EntityPlugin Reference

New members:

Name Description
clickingPoint Last clicking point when mouse down event happens
knownEntityElements All known entity elements

LifecyclePluginState interface

(New in 8.0.0)

The state object for LifecyclePlugin Reference

New members:

Name Description
customData Custom data of this editor
defaultFormat Default format of this editor
experimentalFeatures Enabled experimental features
isDarkMode Whether editor is in dark mode
onExternalContentTransform External content transform function to help do color transform for existing content

PendingFormatStatePluginState interface

(New in 8.0.0)

The state object for PendingFormatStatePlugin Reference

New members:

Name Description
pendableFormatPosition The position of last pendable format state changing
pendableFormatState Current pending format state

UndoPluginState interface

(New in 8.0.0)

The state object for UndoPlugin Reference

New members:

Name Description
autoCompletePosition Position after last auto complate. Undo autoComplete only works if the current position matches this one
hasNewContent Whether there is new content change after last undo snapshot is taken
isNested If addUndoSnapshot() is called nested in another one, this will be true
isRestoring Whether restoring of undo snapshot is in proguress.
snapshotsService Snapshot service for undo, it helps handle snapshot add, remove and retrive

PredefinedCssMap type

(New in 8.0.0)

A map of predefined CSS styles for elements Reference

DOMEventHandlerFunction type

(New in 8.0.0)

Handler function type of DOM event Reference

DOMEventHandlerObject interface

(New in 8.0.0)

DOM event handler object with mapped plugin event type and handler function Reference

New members:

Name Description
beforeDispatch Handler function. Besides the mapped plugin event type, this function will also be triggered when correlated DOM event is fired
pluginEventType Type of pluign event. The DOM event will be mapped with this plugin event type

DOMEventHandler type

(New in 8.0.0)

Combined event handler type with all 3 posibilities Reference

PluginState type

(New in 8.0.0)

Auto-calculated State object type for plugin with states Reference

AddUndoSnapshot type

(New in 8.0.0)

Call an editing callback with adding undo snapshots around Reference

AttachDomEvent type

(New in 8.0.0)

Attach a DOM event to the editor content DIV Reference

GetContent type

(New in 8.0.0)

Get current editor content as HTML string Reference

RestoreUndoSnapshot type

(New in 8.0.0)

Restore an undo snapshot into editor Reference

SetContent type

(New in 8.0.0)

Set HTML content to this editor. All existing content will be replaced. A ContentChanged event will be triggered if triggerContentChangedEvent is set to true Reference

TransformColor type

(New in 8.0.0)

Edit and transform color of elements between light mode and dark mode Reference

Modified existing types/interfaces/enums

Keys enum

Key numbers common used keys. Reference

New members:

Name Description
PAGEUP PageUp key
CONTENTCHANGED A virtual key mapped to ContentChanged event
RANGE A virtual key mapped to a key operation when a range is selected
Ctrl Ctrl key
Meta Meta key
Shift Shift key

ChangeSource enum

Predefined change sources. Reference

New members:

Name Description
SwitchToDarkMode Editor is switched to dark mode, content color is changed
SwitchToLightMode Editor is switched to light mode, content color is changed
ListChain List chain reorganized numbers of lists

BeforePasteEvent

Provides a chance for plugin to change the content before it is pasted into editor. Reference

Removed members:

Name Description
pasteOption To change paste option, handle BeforePasteEvent and replace the DOM tree in BeforePasteEvent.fragment to be whatever we want

PluginEventType enum

Editor plugin event type enum. Reference

New members:

Name Description
BeforeCutCopy Before Paste event, provide a chance to change copied content
ContextMenu HTML ContextMenu event

ClipboardData interface

An object contains all related data for pasting. Reference

New members:

Name Description
linkPreview Link Preview information provided by Edge

Entity interface

Represents an entity in editor. Reference

Renamed members:

Old Name New Name Description
contentNode wrapper The wrapper DOM node of this entity which holds the info CSS classes of this entity

FormatState interface

The format state of a given node. Reference

Removed members:

Name Description
canUndo Moved to EditorUndoState interface
canRedo Moved to EditorUndoState interface

New base interfaces:

Name Description
EditorUndoState Specify if editor can undo/redo an editing operation

Region interface

Represents a DOM region with selection information. Reference

New base interfaces:

Name Description
RegionBase Represents a DOM region

Removed members:

Name Description
nodeAfter Moved to RegionBase interface
nodeBefore Moved to RegionBase interface
rootNode Moved to RegionBase interface
skipTags Moved to RegionBase interface

Snapshots interface

Represents a data structure of snapshots, this is usually used for undo snapshots. Reference

New members:

Name Description
autoCompleteIndex Index of snapshot added before an auto complete action

HtmlSanitizerOptions interface

Options for HtmlSanitizer Reference

New members:

Name Description
additionalPredefinedCssForElement Additional predefined CSS for element
additionalTagReplacements Additional tag replacement, to allow replace a tag to another name, or remove it.
unknownTagReplacement Define a replacement tag name of unknown tags. 

Removed members:

Name Description
allowPreserveWhiteSpace Use additionalPredefinedCssForElement instead
additionalAllowedTags Use additionalTagReplacements instead

Renamed members:

Old Name New Name Description
styleCallbacks cssStyleCallbacks Callbacks for CSS styles
additionalAllowAttributes additionalAllowedAttributes Allowed HTML attributes in addition to default attributes
Clone this wiki locally