Class Clip

A selection of math content that can be inserted into an Editor.

Clips can be converted to and from strings, making it easy to transfer them from one editor to another, even across windows, devices, or editing sessions.

Example: Capture a clip in one editor and paste it in another

let selectionClip = micd.Clip.from(editor);
let editor2 = new micd.Editor();
selectionClip.applyTo(editor2);

Hierarchy

  • Clip

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Clip(value?: string): Clip
  • Creates a new clip using content from the specified string value.

    Parameters

    • Optional value: string

      A string in the MICD clip format, or null for an empty clip.

    Returns Clip

Properties

value

value: string

A string representation of the clip content in the MICD clip format. The clip can be recreated by passing this value to the Clip constructor.

throws

TypeError If set to a string that is not a valid MICD clip.

Methods

applyTo

  • applyTo(editor: Editor): void
  • Inserts the clip content into the specified editor at the caret position, if possible.

    see

    canApplyTo

    Parameters

    • editor: Editor

      The editor to insert the clip into.

    Returns void

canApplyTo

  • canApplyTo(editor: Editor): boolean
  • Returns whether the clip can be inserted into the specified editor at the editor's current caret position.

    see

    applyTo

    Parameters

    • editor: Editor

      The editor that the clip would be inserted into.

    Returns boolean

    Returns true if the clip can be inserted.

Static from

  • Creates a new clip from the contents of the specified editor. The contents of the editor are not changed.

    Parameters

    • editor: Editor

      The editor instance to make a clip from.

    • Optional range: string

      A string describing the range the clip should cover; otherwise the editor's current selection is used.

    Returns Clip

  • Creates a new clip from the contents of the specified editor. The contents of the editor are not changed.

    Parameters

    • editor: Editor

      The editor instance to make a clip from.

    • line: number

      The line number of the editor document that the clip should cover, starting from 0.

    Returns Clip

This API is still under development and is subject to change. Copyright © Math I Can Do Solutions Incorporated and/or its licensors.