Options
All
  • Public
  • Public/Protected
  • All
Menu

Module roosterjs-editor-types

Index

Enumerations

Interfaces

Type aliases

Type aliases

AddUndoSnapshot

AddUndoSnapshot: (core: EditorCore, callback: ((start: NodePosition | null, end: NodePosition | null) => any) | null, changeSource: ChangeSource | CompatibleChangeSource | string | null, canUndoByBackspace: boolean, additionalData?: ContentChangedData) => void

Type declaration

    • Call an editing callback with adding undo snapshots around, and trigger a ContentChanged event if change source is specified. Undo snapshot will not be added if this call is nested inside another addUndoSnapshot() call.

      Parameters

      • core: EditorCore

        The EditorCore object

      • callback: ((start: NodePosition | null, end: NodePosition | null) => any) | null

        The editing callback, accepting current selection start and end position, returns an optional object used as the data field of ContentChangedEvent.

      • changeSource: ChangeSource | CompatibleChangeSource | string | null

        The ChangeSource string of ContentChangedEvent. @default ChangeSource.Format. Set to null to avoid triggering ContentChangedEvent

      • canUndoByBackspace: boolean

        True if this action can be undone when user press Backspace key (aka Auto Complete).

      • Optional additionalData: ContentChangedData

        Optional parameter to provide additional data related to the ContentChanged Event.

      Returns void

ArrayItemType

ArrayItemType<T>: T extends infer U[] ? U : never

A type template to get item type of an array

Type parameters

  • T: any[]

AttachDomEvent

AttachDomEvent: (core: EditorCore, eventMap: Record<string, DOMEventHandler>) => () => void

Type declaration

    • Attach a DOM event to the editor content DIV

      Parameters

      Returns () => void

        • (): void
        • Returns void

AttributeCallback

AttributeCallback: (value: string, element: HTMLElement, context: Object) => string

Type declaration

    • (value: string, element: HTMLElement, context: Object): string
    • Attribute callback, will be called when HtmlSanitizer process an attribute with given name

      Parameters

      • value: string

        Value of the attribute

      • element: HTMLElement

        The HTML element contains this attribute

      • context: Object

        A context object to store values which can used for communicating among callbacks

      Returns string

      null to remove this attribute, otherwise keep the attribute with the value returned

AttributeCallbackMap

AttributeCallbackMap: Record<string, AttributeCallback>

A map of attribute callbacks. Tag name should be in lower case

CompatiblePluginDomEvent

This represents a PluginEvent wrapping native browser event

CompatiblePluginKeyboardEvent

The interface represents a PluginEvent wrapping native Keyboard event

CompatiblePluginMouseEvent

This interface represents a PluginEvent wrapping native Mouse event

ContentEditFeature

ContentEditFeature interface that handles keyboard event

ContentMetadata

A content metadata is a data structure storing information other than HTML content, such as dark mode info, selection info, ...

CoreCreator

CoreCreator<TEditorCore, TEditorOptions>: (contentDiv: HTMLDivElement, options: TEditorOptions) => TEditorCore

Type parameters

Type declaration

    • (contentDiv: HTMLDivElement, options: TEditorOptions): TEditorCore
    • Type of Editor Core Creator

      Parameters

      • contentDiv: HTMLDivElement

        The DIV HTML element which will be the container element of editor

      • options: TEditorOptions

        An optional options object to customize the editor

      Returns TEditorCore

CreatePasteFragment

CreatePasteFragment: (core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean, pasteAsImage: boolean) => DocumentFragment | null

Type declaration

    • (core: EditorCore, clipboardData: ClipboardData, position: NodePosition | null, pasteAsText: boolean, applyCurrentStyle: boolean, pasteAsImage: boolean): DocumentFragment | null
    • Create a DocumentFragment for paste from a ClipboardData

      Parameters

      • core: EditorCore

        The EditorCore object.

      • clipboardData: ClipboardData

        Clipboard data retrieved from clipboard

      • position: NodePosition | null

        The position to paste to

      • pasteAsText: boolean

        True to force use plain text as the content to paste, false to choose HTML or Image if any

      • applyCurrentStyle: boolean

        True if apply format of current selection to the pasted content, false to keep original format

      • pasteAsImage: boolean

      Returns DocumentFragment | null

CssStyleCallback

CssStyleCallback: (value: string, element: HTMLElement, thisStyle: StringMap, context: Object) => boolean

Type declaration

    • (value: string, element: HTMLElement, thisStyle: StringMap, context: Object): boolean
    • Style callback, will be called when HtmlSanitizer process an inline CSS style with given name

      Parameters

      • value: string

        Value of the CSS rule

      • element: HTMLElement

        The HTML element contains this CSS style

      • thisStyle: StringMap

        Current values of known inheritable styles

      • context: Object

        A context object to store values which can used for communicating among callbacks

      Returns boolean

      True if this rule should be kept, otherwise false

CssStyleCallbackMap

CssStyleCallbackMap: Record<string, CssStyleCallback>

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

DOMEventHandler

Combined event handler type with all 3 possibilities

Type parameters

  • E = Event

DOMEventHandlerFunction

DOMEventHandlerFunction<E>: (event: E) => void

Type parameters

  • E = Event

Type declaration

    • (event: E): void
    • Handler function type of DOM event

      Parameters

      • event: E

      Returns void

Definition

Definition<T>: CustomizeDefinition | (T extends any[] ? ArrayDefinition<T> : T extends Record<string, any> ? ObjectDefinition<T> : T extends String ? StringDefinition : T extends Number ? NumberDefinition : T extends Boolean ? BooleanDefinition : never)

A combination of all definition types

Type parameters

  • T

ElementCallback

ElementCallback: (element: HTMLElement, context: Object) => boolean

Type declaration

    • (element: HTMLElement, context: Object): boolean
    • Element callback, will be called when HtmlSanitizer process an element with the given tag

      Parameters

      • element: HTMLElement

        The HTML element

      • context: Object

        A context object to store values which can used for communicating among callbacks

      Returns boolean

      True if this element should be kept, otherwise false

ElementCallbackMap

ElementCallbackMap: Record<string, ElementCallback>

A map of elements callback. Tag name should be in upper case

EnsureTypeInContainer

EnsureTypeInContainer: (core: EditorCore, position: NodePosition, keyboardEvent?: KeyboardEvent, deprecated?: boolean) => void

Type declaration

    • Ensure user will type into a container element rather than into the editor content DIV directly

      Parameters

      • core: EditorCore

        The EditorCore object.

      • position: NodePosition

        The position that user is about to type to

      • Optional keyboardEvent: KeyboardEvent

        Optional keyboard event object

      • Optional deprecated: boolean

        Deprecated parameter, not used

      Returns void

Focus

Focus: (core: EditorCore) => void

Type declaration

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

      Parameters

      Returns void

GenericPluginState

GenericPluginState<Key>: {[ P in StatePluginKeys<Key>]: TypeOfStatePlugin<P> }

A type map from name of plugin with state to its plugin type

Type parameters

GetContent

GetContent: (core: EditorCore, mode: GetContentMode | CompatibleGetContentMode) => string

Type declaration

GetPendableFormatState

GetPendableFormatState: (core: EditorCore, forceGetStateFromDOM: boolean) => PendableFormatState

Type declaration

    • Get the pendable format such as underline and bold

      Parameters

      • core: EditorCore

        The EditorCore object

      • forceGetStateFromDOM: boolean

        If set to true, will force get the format state from DOM tree.

      Returns PendableFormatState

      The pending format state of editor.

GetSelectionRange

GetSelectionRange: (core: EditorCore, tryGetFromCache: boolean) => Range | null

Type declaration

    • (core: EditorCore, tryGetFromCache: boolean): Range | null
    • Get current or cached selection range

      Parameters

      • core: EditorCore

        The EditorCore object

      • tryGetFromCache: boolean

        Set to true to retrieve the selection range from cache if editor doesn't own the focus now

      Returns Range | null

      A Range object of the selection range

GetSelectionRangeEx

GetSelectionRangeEx: (core: EditorCore) => SelectionRangeEx

Type declaration

GetStyleBasedFormatState

GetStyleBasedFormatState: (core: EditorCore, node: Node | null) => StyleBasedFormatState

Type declaration

HasFocus

HasFocus: (core: EditorCore) => boolean

Type declaration

    • Check if the editor has focus now

      Parameters

      Returns boolean

      True if the editor has focus, otherwise false

InsertNode

InsertNode: (core: EditorCore, node: Node, option: InsertOption | null) => boolean

Type declaration

    • Insert a DOM node into editor content

      Parameters

      • core: EditorCore

        The EditorCore object. No op if null.

      • node: Node
      • option: InsertOption | null

        An insert option object to specify how to insert the node

      Returns boolean

InsertOption

Type definition for the InsertOption, used in the insertNode API. The position parameter defines how the node will be inserted. In a future revision, this will become strongly typed Only parameters applicable to the given position will be accepted.

KeyOfStatePlugin

KeyOfStatePlugin<Key>: CorePlugins[Key] extends PluginWithState<infer U> ? Key : never

Names of the core plugins that have plugin state

Type parameters

ObjectPropertyDefinition

ObjectPropertyDefinition<T>: {[ Key in keyof T]: Definition<T[Key]> }

Object property definition type used by Object Definition

Type parameters

  • T: Object

PluginDomEvent

This represents a PluginEvent wrapping native browser event

PluginEvent

Editor plugin event interface

PluginEventData

PluginEventData<T>: PluginEventDataGeneric<PluginEvent, T>

A type to extract data part of a plugin event type. Data part is the plugin event without eventType field.

Type parameters

PluginEventDataGeneric

PluginEventDataGeneric<E, T>: E extends BasePluginEvent<T> ? Pick<E, Exclude<keyof E, "eventType">> : never

A type to extract data part of a plugin event type. Data part is the plugin event without eventType field. This type is a middle result and only used by PluginEventData type

Type parameters

PluginEventFromType

PluginEventFromType<T>: PluginEventFromTypeGeneric<PluginEvent, T>

A type to get specify plugin event type from eventType parameter.

Type parameters

PluginEventFromTypeGeneric

PluginEventFromTypeGeneric<E, T>: E extends BasePluginEvent<T> ? E : never

A type to get specify plugin event type from eventType parameter. This type is a middle result and only used by PluginEventFromType type

Type parameters

PluginKey

PluginKey: keyof CorePlugins

Names of core plugins

PluginKeyboardEvent

The interface represents a PluginEvent wrapping native Keyboard event

PluginMouseEvent

This interface represents a PluginEvent wrapping native Mouse event

PluginState

Auto-calculated State object type for plugin with states

PredefinedCssMap

PredefinedCssMap: Record<string, StringMap>

A map of predefined CSS styles for elements

RestoreUndoSnapshot

RestoreUndoSnapshot: (core: EditorCore, step: number) => void

Type declaration

    • Restore an undo snapshot into editor

      Parameters

      • core: EditorCore

        The editor core object

      • step: number

        Steps to move, can be 0, positive or negative

      Returns void

Select

Select: (core: EditorCore, arg1: Range | SelectionRangeEx | NodePosition | Node | SelectionPath | null, arg2?: NodePosition | number | PositionType | TableSelection | null, arg3?: Node, arg4?: number | PositionType) => boolean

Type declaration

SelectImage

SelectImage: (core: EditorCore, image: HTMLImageElement | null) => ImageSelectionRange | null

Type declaration

SelectRange

SelectRange: (core: EditorCore, range: Range, skipSameRange?: boolean) => boolean

Type declaration

    • (core: EditorCore, range: Range, skipSameRange?: boolean): boolean
    • Change the editor selection to the given range

      Parameters

      • core: EditorCore

        The EditorCore object

      • range: Range

        The range to select

      • Optional skipSameRange: boolean

        When set to true, do nothing if the given range is the same with current selection in editor, otherwise it will always remove current selection range and set to the given one. This parameter is always treated as true in Edge to avoid some weird runtime exception.

      Returns boolean

SelectTable

SelectTable: (core: EditorCore, table: HTMLTableElement | null, coordinates?: TableSelection) => TableSelectionRange | null

Type declaration

    • Select a table and save data of the selected range

      Parameters

      • core: EditorCore

        The EditorCore object

      • table: HTMLTableElement | null

        table to select

      • Optional coordinates: TableSelection

        first and last cell of the selection, if this parameter is null, instead of selecting, will unselect the table.

      Returns TableSelectionRange | null

      true if successful

SelectionRangeEx

Types of ranges used in editor api getSelectionRangeEx

SetContent

SetContent: (core: EditorCore, content: string, triggerContentChangedEvent: boolean, metadata?: ContentMetadata) => void

Type declaration

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

      Parameters

      • core: EditorCore

        The EditorCore object

      • content: string

        HTML content to set in

      • triggerContentChangedEvent: boolean

        True to trigger a ContentChanged event. Default value is true

      • Optional metadata: ContentMetadata

      Returns void

SizeTransformer

SizeTransformer: (size: number) => number

Type declaration

    • (size: number): number
    • A transformer function. It transform the size changes according to current situation. A typical scenario to use this function is when editor is located under a scaled container, so we need to calculate the scaled size change according to current zoom rate.

      Parameters

      • size: number

        Original delta size from mouse event

      Returns number

      Calculated delta size. By default it should just return original value

StatePluginKeys

StatePluginKeys<Key>: {[ P in Key]: KeyOfStatePlugin<P> }[Key]

All names of plugins with plugin state

Type parameters

StringMap

StringMap: Record<string, string>

A map of attribute callbacks. Tag name should be in lower case

SwitchShadowEdit

SwitchShadowEdit: (core: EditorCore, isOn: boolean) => void

Type declaration

    • Switch the Shadow Edit mode of editor On/Off

      Parameters

      • core: EditorCore

        The EditorCore object

      • isOn: boolean

        True to switch On, False to switch Off

      Returns void

TableCellMetadataFormat

TableCellMetadataFormat: { bgColorOverride?: boolean; borderOverride?: boolean; vAlignOverride?: boolean }

Format of table cell that stored as metadata

Type declaration

  • Optional bgColorOverride?: boolean

    Override default background color

  • Optional borderOverride?: boolean

    Override default border value

  • Optional vAlignOverride?: boolean

    Override default vertical align value

TransformColor

TransformColor: (core: EditorCore, rootNode: Node | null, includeSelf: boolean, callback: (() => void) | null, direction: ColorTransformDirection | CompatibleColorTransformDirection, forceTransform?: boolean, fromDarkMode?: boolean) => void

Type declaration

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

      Parameters

      • core: EditorCore

        The EditorCore object

      • rootNode: Node | null

        The root HTML node to transform

      • includeSelf: boolean

        True to transform the root node as well, otherwise false

      • callback: (() => void) | null

        The callback function to invoke before do color transformation

      • direction: ColorTransformDirection | CompatibleColorTransformDirection

        To specify the transform direction, light to dark, or dark to light

      • Optional forceTransform: boolean

        By default this function will only work when editor core is in dark mode. Pass true to this value to force do color transformation even editor core is in light mode

      • Optional fromDarkMode: boolean

      Returns void

TriggerEvent

TriggerEvent: (core: EditorCore, pluginEvent: PluginEvent, broadcast: boolean) => void

Type declaration

    • Trigger a plugin event

      Parameters

      • core: EditorCore

        The EditorCore object

      • pluginEvent: PluginEvent

        The event object to trigger

      • broadcast: boolean

        Set to true to skip the shouldHandleEventExclusively check

      Returns void

TrustedHTMLHandler

TrustedHTMLHandler: (html: string) => string

Type declaration

    • (html: string): string
    • A handler type to convert HTML string to a trust HTML string

      Parameters

      • html: string

      Returns string

TypeOfStatePlugin

TypeOfStatePlugin<Key>: CorePlugins[Key] extends PluginWithState<infer U> ? U : never

Get type of a plugin with state

Type parameters

Generated using TypeDoc