Options
All
  • Public
  • Public/Protected
  • All
Menu

It is the base class of the editor's class hierarchy. It allows creation of the editor in memory and communicating with it via API. It does not have ability to render. Usually it is used for the cases when one needs some calculation with the editor itself or some of its plugins. Also it is useful for testing as it does not depend on DOM. Use createAPI function to create an instance of this class.

Hierarchy

Index

Properties

heuristics

heuristics: Heuristic[]

API Methods

addOnNotify

  • Allows listening to all the events that do not change the editor's model: neither change expression nor cursor nor selection.

    Parameters

    Returns void

addOnUpdate

  • addOnUpdate(cb: (updateInfo: NotifyUpdateObject[], confirmation: ConfirmRequiredOperation) => void): void
  • Add listener to listen for all the editor updates.

    Parameters

    • cb: (updateInfo: NotifyUpdateObject[], confirmation: ConfirmRequiredOperation) => void

      The listener will receive two parameters: updateInfo - what exactly were updated and confirmation - what was not yet updated, but the user was asked to confirm the operation instead

    Returns void

applyAdvice

  • applyAdvice(advice: IAdvice): this
  • Applies advice received from the getAdvices method.

    Parameters

    • advice: IAdvice

    Returns this

applyHeuristics

  • applyHeuristics(): boolean
  • Applies all the previously installed heuristics.

    Returns boolean

    true if the heuristics have changed the current expression, false if not.

copy

  • copy(): string
  • Copies selected expression to the clipboard.

    Returns string

    • copied expression

cut

  • cut(): string
  • Cuts selected expression to the clipboard.

    Returns string

    • cut expression

defineEditableCell

  • defineEditableCell(editableCells: { avoidParenthesesWrap?: boolean; borderVisible?: boolean; nodeId: number }[]): MathEditorAPI
  • Makes editor readonly and creates editable cells inside.

    Parameters

    • editableCells: { avoidParenthesesWrap?: boolean; borderVisible?: boolean; nodeId: number }[]

      nodeId - node id for editable cell borderVisible - whether the border of editable cell visible or not avoidParenthesesWrap - whether the wrap editable cell with parens or not

    Returns MathEditorAPI

delete

  • Deletes node near the current cursor position or replaces the selection. This method allows programmatically emulate pressing delete/backspace button. It requires cursor or non-empty selection inside the editor. Otherwise, it does nothing.

    Parameters

    • direction: HorizontalDirection

      left for backspace button and right for delete button

    • Optional force: boolean

      whether node or ask user for confirmation

    Returns this

dropSelection

  • dropSelection(placeCursorAtSelectionEnd: boolean): void
  • Drops the current selection.

    Parameters

    • placeCursorAtSelectionEnd: boolean

      whether put the cursor to the end of selection after dropping

    Returns void

getAdvices

  • getAdvices(): IAdvice[]
  • Returns advices for the current cursor position. Advice is a suggestion to end user what can be inserted into the current cursor position. For example, if user enters 'in' then we can suggest him 'Indefinite integral'.

    Returns IAdvice[]

getCharacterSpeech

  • getCharacterSpeech(): string
  • Returns description of the current expression as character-by-character text.

    Returns string

getCursor

  • Returns Cursor

    representation of current cursor See Cursor for details.

getLatex

  • getLatex(): string
  • Returns string

    current expression as latex

getSelectionTree

getSemantic

getSemanticSpeech

  • getSemanticSpeech(): string
  • Returns description of the current expression as human readable math text.

    Returns string

getSemanticText

  • getSemanticText(): string
  • Returns string

    current expression in context free semantic language

getSymbolsAtCursor

  • getSymbolsAtCursor(includeHidden?: boolean): number[]
  • Returns symbols located near the cursor.

    gradarius

    Parameters

    • Optional includeHidden: boolean

      include hidden symbols (such as implicit multiplication) or not

    Returns number[]

getTree

  • Parameters

    • Optional settings: MathTreeSettings

      allow to post process semantic tree to omit information (eg selection, cursor, etc)

    Returns MathStructure

    current expression as semantic tree

hasSelection

  • hasSelection(): boolean
  • Returns whether selection exists or not.

    Returns boolean

insertSymbol

  • insertSymbol(s: string): boolean
  • Inserts character to the right of the current cursor position or replaces the selection. This method allows programmatically emulate user input. It requires cursor or non-empty selection or empty expression inside the editor. Otherwise, it does nothing.

    Parameters

    • s: string

      character to insert

    Returns boolean

    true if the character was successfully inserted

insertTree

  • insertTree(tree: MathStructure, overrideContext?: boolean): boolean
  • Inserts tree to the right of the current cursor position or replaces the selection. This method allows programmatically to insert one semantic tree into another. It requires cursor or non-empty selection or empty expression inside the editor. Otherwise, it does nothing.

    Parameters

    • tree: MathStructure

      semantic tree to insert

    • Default value overrideContext: boolean = true

      if true then overrides semantic context of the insertable tree to match current one (default) if false then throws an exception on context conflicts

    Returns boolean

    true if the tree was successfully inserted

moveSelectionHorizontalBoundary

  • Programmatically moves the selection boundary horizontally.

    Parameters

    • leftBoundary: boolean

      whether move left or right boundary

    • direction: HorizontalDirection

      direction to move selection boundary

    Returns MathEditorAPI

moveSelectionVerticalBoundary

  • Programmatically moves the selection boundary vertically.

    Parameters

    • topBoundary: boolean

      whether move top or bottom boundary

    • direction: VerticalDirection

      direction to move selection boundary

    Returns MathEditorAPI

navigate

  • Programmatically moves cursor to the given direction. It requires cursor inside the editor. Otherwise, it does nothing.

    Parameters

    Returns boolean

paste

  • paste(latex: string): boolean
  • Pastes expression from the clipboard to the right of the current cursor position or replaces the selection. It requires cursor or non-empty selection or empty expression inside the editor. Otherwise, it does nothing.

    Parameters

    • latex: string

    Returns boolean

    true if the expression was successfully pasted

placeCursor

  • placeCursor(nodeId: number, side: CursorSide): boolean
  • Places cursor at the left or at the right of the given symbol

    Parameters

    • nodeId: number

      identifier of the given symbol (can be found in model classes)

    • side: CursorSide

      where to place the cursor - at the right of the symbol or at the left

    Returns boolean

redo

removeCursor

  • removeCursor(): boolean
  • Removes cursor from the editor

    Returns boolean

    true if the cursor was actually in the editor

removeOnNotify

removeOnUpdate

  • removeOnUpdate(cb: (updateInfo: NotifyUpdateObject[], confirmation: ConfirmRequiredOperation) => void): void
  • Remove the listener previously added with addOnUpdate.

    Parameters

    • cb: (updateInfo: NotifyUpdateObject[], confirmation: ConfirmRequiredOperation) => void

      the listener to remove

    Returns void

select

  • Programmatically increases selection in a given direction. It requires cursor or non-empty selection inside the editor.

    Parameters

    • direction: NavDirection

      direction to increase the selection

    Returns MathEditorAPI

selectByNodeIds

  • Programmatically creates selection between given nodes using the provided horizontal and vertical direction.

    gradarius

    Parameters

    • startNodeId: number

      start node id

    • endNodeId: number

      end node id

    • horizontalDirection: HorizontalDirection

      horizontal direction

    • verticalDirection: VerticalDirection

      vertical direction

    • Default value includeStartNode: boolean = true

      whether include start node to selection or not (default true)

    Returns MathEditorAPI

setTree

  • Updates current expression with the given semantic tree

    Parameters

    Returns MathStructure

    updated math tree (original one can be changed by hints)

undo

Internal Methods

getCurrentState

  • getCurrentState(): string
  • Returns internal editor state as JSON.

    Returns string

getCurrentStateWithHistory

  • getCurrentStateWithHistory(): string
  • Returns internal editor state with history as JSON.

    Returns string

getExpressionInternalRepresentation

  • getExpressionInternalRepresentation(): string
  • Returns internal expression representation.

    Returns string

setCurrentState

  • setCurrentState(state: string): void
  • Sets internal editor state using provided JSON.

    Parameters

    • state: string

      internal editor state

    Returns void

setCurrentStateWithHistory

  • setCurrentStateWithHistory(state: string): void
  • Sets internal editor state with history using provided JSON.

    Parameters

    • state: string

      internal editor state

    Returns void

setExpressionInternalRepresentation

  • setExpressionInternalRepresentation(mathExpression: string): number[]
  • Sets internal expression representation. Returns an array of node ids, ordered left to right according to initial order in the math expression.

    Parameters

    • mathExpression: string

      internal expression representation

    Returns number[]

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc