Index

Type aliases

editor_function

editor_function: (text: string, start: number, end: number, arg?: any) => [string, number, number]

Type declaration

    • (text: string, start: number, end: number, arg?: any): [string, number, number]
    • Parameters

      • text: string
      • start: number
      • end: number
      • Optional arg: any

      Returns [string, number, number]

Functions

applyToElem

  • applyToElem(e: any, fn: any): any

Const charesar

  • charesar(c: string, n?: number): string

getContentEditableValues

  • getContentEditableValues(e: any): [string, number, number]
  • Returns values necessary for editor functions to work on contentEditable elements

    Parameters

    • e: any

      a contentEditable element

    Returns [string, number, number]

    The content of the element, the position of the caret, the position of the end of the visual selection

getLineAndColNumber

  • getLineAndColNumber(text: string, start: number, end: number): [string, number, number]
  • Returns line and column number.

    Parameters

    • text: string
    • start: number
    • end: number

    Returns [string, number, number]

getSimpleValues

  • getSimpleValues(e: any): any
  • Returns values necessary for editor functions to work on textarea/input elements

    Parameters

    • e: any

      the element

    Returns any

    The content of the element, the position of the caret, the position of the end of the visual selection

getWordBoundaries

  • getWordBoundaries(text: string, position: number, before: boolean): [number, number]
  • Detects the boundaries of a word in text according to the wordpattern setting. If POSITION is in a word, the boundaries of this word are returned. If POSITION is out of a word and BEFORE is true, the word before POSITION is returned. If BEFORE is false, the word after the caret is returned.

    Parameters

    • text: string
    • position: number
    • before: boolean

    Returns [number, number]

needs_text

setContentEditableValues

  • setContentEditableValues(e: any, text: any, start: any, end: any): void
  • Change text in contentEditable elements in a non-destructive way (i.e. C-z will undo changes).

    Parameters

    • e: any

      The content editable element

    • text: any

      The new content the element should have. null if you just want to move the caret around

    • start: any

      The new caret position. null if you just want to change text.

    • end: any

      The end of the visual selection. null if you just want to move the caret.

    Returns void

setSimpleValues

  • setSimpleValues(e: any, text: any, start: any, end: any): any
  • Change text in regular textarea/input fields. Note: this destroys the field's history (i.e. C-z won't work).

    Parameters

    • e: any

      The element

    • text: any

      The new content of the element, null if it shouldn't change

    • start: any

      The new position of the caret, null if the caret shouldn't move

    • end: any

      The end of the visual selection, null if you just want to move the caret

    Returns any

wrap_input

  • Take an editor function as parameter and return it wrapped in a function that will handle grabbing text and caret position from the HTML element it takes as parameter

    Parameters

    Returns (e: HTMLElement, arg?: any) => boolean

    boolean Whether the editor function was actually called or not

      • (e: HTMLElement, arg?: any): boolean
      • Parameters

        • e: HTMLElement
        • Optional arg: any

        Returns boolean