editor_function
applyToElem
charesar
getContentEditableValues
getLineAndColNumber
getSimpleValues
getWordBoundaries
needs_text
setContentEditableValues
setSimpleValues
shuffle
wrap_input
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
      • Optionalarg: any

      Returns [string, number, number]

  • Parameters

    • c: string
    • n: number = 13

    Returns string

  • Returns values necessary for editor functions to work on contentEditable elements

    Parameters

    • e: any

      a contentEditable element

    Returns [string, number, number]

    [string, number, number] The content of the element, the position of the caret, the position of the end of the visual selection

  • Returns line and column number.

    Parameters

    • text: string
    • start: number

    Returns [string, number, number]

  • Returns values necessary for editor functions to work on textarea/input elements

    Parameters

    • e: any

      the element

    Returns any

    [string, number, number] The content of the element, the position of the caret, the position of the end of the visual selection

  • 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]

  • 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

  • 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

  • Shuffles input string

    Parameters

    • text: string

      string to be shuffled

    Returns string

  • 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

    • fn: editor_function

      A function that takes a [string, selectionStart, selectionEnd] tuple as argument and returns a [string, selectionStart, selectionEnd] tuple corresponding to the new state of the text.

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

    boolean Whether the editor function was actually called or not