Options
All
  • Public
  • Public/Protected
  • All
Menu

Module roosterjs-content-model-api

Index

Functions

adjustImageSelection

adjustLinkSelection

  • adjustLinkSelection(editor: IEditor): [string, string | null]

applySegmentFormat

applyTableBorderFormat

changeCapitalization

  • changeCapitalization(editor: IEditor, capitalization: "sentence" | "lowerCase" | "upperCase" | "capitalize", language?: string): void
  • Change the capitalization of text in the selection

    Parameters

    • editor: IEditor

      The editor instance

    • capitalization: "sentence" | "lowerCase" | "upperCase" | "capitalize"

      The case option

    • Optional language: string

      Optional parameter for language string that should comply to "IETF BCP 47 Tags for Identifying Languages". For example: 'en' or 'en-US' for English, 'tr' for Turkish. Default is the host environment’s current locale.

    Returns void

changeFontSize

  • changeFontSize(editor: IEditor, change: "increase" | "decrease"): void

changeImage

  • changeImage(editor: IEditor, file: File): void

clearFormat

  • clearFormat(editor: IEditor): void

clearSelectedCells

editTable

findListItemsInSameThread

formatImageWithContentModel

formatInsertPointWithContentModel

formatParagraphWithContentModel

formatSegmentWithContentModel

formatTable

formatTableWithContentModel

formatTextSegmentBeforeSelectionMarker

getFormatState

getListAnnounceData

insertEntity

  • Insert an entity into editor

    Parameters

    • editor: IEditor

      The editor object

    • type: string

      Type of entity

    • isBlock: boolean

      True to insert a block entity, false to insert an inline entity

    • position: "focus" | "begin" | "end" | DOMInsertPoint

      Position of the entity to insert. It can be Value of InsertEntityPosition: see InsertEntityPosition selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)

    • Optional options: InsertEntityOptions

      Move options to insert. See InsertEntityOptions

    Returns ContentModelEntity | null

  • Insert a block entity into editor

    Parameters

    • editor: IEditor

      The editor object

    • type: string

      Type of entity

    • isBlock: true

      Must be true for a block entity

    • position: InsertEntityPosition | DOMInsertPoint

      Position of the entity to insert. It can be Value of InsertEntityPosition: see InsertEntityPosition selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)

    • Optional options: InsertEntityOptions

      Move options to insert. See InsertEntityOptions

    Returns ContentModelEntity | null

insertImage

  • insertImage(editor: IEditor, imageFileOrSrc: File | string): void

insertLink

  • insertLink(editor: IEditor, link: string, anchorTitle?: string, displayText?: string, target?: string): void
  • Insert a hyperlink at cursor. When there is a selection, hyperlink will be applied to the selection, otherwise a hyperlink will be inserted to the cursor position.

    Parameters

    • editor: IEditor

      Editor object

    • link: string

      Link address, can be http(s), mailto, notes, file, unc, ftp, news, telnet, gopher, wais. When protocol is not specified, a best matched protocol will be predicted.

    • Optional anchorTitle: string

      Optional alt text of the link, will be shown when hover on the link

    • Optional displayText: string

      Optional display text for the link.

    • Optional target: string

      Optional display target for the link ("_blank"|"_self"|"_parent"|"_top"|"{framename}") If specified, the display text of link will be replaced with this text. If not specified and there wasn't a link, the link url will be used as display text.

    Returns void

insertTable

  • Insert table into editor at current selection

    Parameters

    • editor: IEditor

      The editor instance

    • columns: number

      Number of columns in table, it also controls the default table cell width: if columns <= 4, width = 120px; if columns <= 6, width = 100px; else width = 70px

    • rows: number

      Number of rows in table

    • Optional format: Partial<TableMetadataFormat>

      (Optional) The table format. If not passed, the default format will be applied: background color: #FFF; border color: #ABABAB

    Returns void

insertTableColumn

insertTableRow

matchLink

  • matchLink(url: string): LinkData | null

promoteLink

  • Promote the given text segment to a hyper link when the segment text is ending with a valid link format. When the whole text segment if of a link, promote the whole segment. When the text segment ends with a link format, split the segment and promote the second part When link is in middle of the text segment, no action. This is mainly used for doing auto link when there is a link before cursor

    Parameters

    Returns ContentModelText | null

    If a link is promoted, return this segment. Otherwise return null

queryContentModelBlocks

removeLink

  • removeLink(editor: IEditor): void
  • Remove link at selection. If no links at selection, do nothing. If selection contains multiple links, all of the link styles will be removed. If only part of a link is selected, the whole link style will be removed.

    Parameters

    • editor: IEditor

      The editor instance

    Returns void

setAlignment

  • setAlignment(editor: IEditor, alignment: "left" | "center" | "right" | "justify"): void

setBackgroundColor

  • setBackgroundColor(editor: IEditor, backgroundColor: string | null): void

setDirection

  • setDirection(editor: IEditor, direction: "ltr" | "rtl"): void

setFontName

  • setFontName(editor: IEditor, fontName: string): void

setFontSize

  • setFontSize(editor: IEditor, fontSize: string): void

setHeadingLevel

  • setHeadingLevel(editor: IEditor, headingLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6): void

setImageAltText

  • setImageAltText(editor: IEditor, altText: string): void

setImageBorder

  • setImageBorder(editor: IEditor, border: Border | null, borderRadius?: string): void
  • Set image border style for all selected images at selection.

    Parameters

    • editor: IEditor

      The editor instance

    • border: Border | null

      the border format object. Ex: { color: 'red', width: '10px', style: 'solid'}, if one of the value in object is undefined its value will not be changed. Passing null instead of an object will remove the border

    • Optional borderRadius: string

      the border radius value, if undefined, the border radius will keep the actual value

    Returns void

setImageBoxShadow

  • setImageBoxShadow(editor: IEditor, boxShadow: string, margin?: string | null): void

setIndentation

  • setIndentation(editor: IEditor, indentation: "indent" | "outdent", length?: number): void

setListStartNumber

  • setListStartNumber(editor: IEditor, value: number): void

setListStyle

setListType

setModelIndentation

setModelListStartNumber

setModelListStyle

setParagraphMargin

  • setParagraphMargin(editor: IEditor, marginTop?: string | null, marginBottom?: string | null): void

setSpacing

  • setSpacing(editor: IEditor, spacing: number | string): void

setTableCellShade

  • setTableCellShade(editor: IEditor, color: string | null): void

setTextColor

  • setTextColor(editor: IEditor, textColor: string | null): void

splitTextSegment

toggleBlockQuote

toggleBold

  • toggleBold(editor: IEditor): void

toggleBullet

  • toggleBullet(editor: IEditor, removeMargins?: boolean): void
  • Toggle bullet list type

    • When there are some blocks not in bullet list, set all blocks to the given type
    • When all blocks are already in bullet list, turn off / outdent there list type

    Parameters

    • editor: IEditor

      The editor to operate on

    • removeMargins: boolean = false

      true to remove margins, false to keep margins @default false

    Returns void

toggleCode

  • toggleCode(editor: IEditor): void

toggleItalic

  • toggleItalic(editor: IEditor): void

toggleNumbering

  • toggleNumbering(editor: IEditor, removeMargins?: boolean): void
  • Toggle numbering list type

    • When there are some blocks not in numbering list, set all blocks to the given type
    • When all blocks are already in numbering list, turn off / outdent there list type

    Parameters

    • editor: IEditor

      The editor to operate on

    • removeMargins: boolean = false

      true to remove margins, false to keep margins @default false

    Returns void

toggleStrikethrough

  • toggleStrikethrough(editor: IEditor): void

toggleSubscript

  • toggleSubscript(editor: IEditor): void

toggleSuperscript

  • toggleSuperscript(editor: IEditor): void

toggleUnderline

  • toggleUnderline(editor: IEditor): void

Generated using TypeDoc