Interface DocumentMetadata

Allows reading and writing the metadata associated a math document. Document metadata consists of a map with strings for both keys and values. If you wish to add your own custom keys to a document, include at least one dash - in the key name to avoid conflicts with any new keys added by future versions of the API.

Example: Observe while adding, changing, and removing a custom key

let editor = new micd.Editor();
editor.metadata.addEventListener("change", ev => {
  console.log(`${ev.oldValue} => ${ev.newValue}`);
});
editor.metadata.put("custom-key", "value");
editor.metadata.put("custom-key", "new value");
console.log(editor.metadata.get("custom-key"));
editor.metadata.remove("custom-key");
see

Editor.metadata

Hierarchy

  • DocumentMetadata

Index

Properties

Readonly editor

editor: Editor

Returns the editor for which this provides metadata.

Readonly keys

keys: string[]

Gets a new array containing a copy of all of the defined keys. The order of the keys in the array is not guaranteed.

Methods

addEventListener

  • addEventListener<E>(type: E, listener: EventListener<DocumentMetadataEventTypes[E]>): void
  • Adds a listener for the specified type of event.

    throws

    TypeError If the event type is not a known type.

    see

    removeEventListener

    Type parameters

    • E: "change"

    Parameters

    • type: E

      A string naming the event type.

    • listener: EventListener<DocumentMetadataEventTypes[E]>

      The event listener to call when the event occurs.

    Returns void

clear

  • clear(): void
  • Removes all keys and their values.

    Returns void

get

  • get(key: string, defaultValue?: string): string
  • Returns the value of the specified key, or the default value if the key is not present.

    Parameters

    • key: string

      The name of the desired metadata property.

    • Optional defaultValue: string

      An optional default returned if the key is not present.

    Returns string

    The value of the key, if present; otherwise the default value, or undefined if no default was specified.

put

  • put(key: string, value: string): void
  • Sets the value of the specified key. Setting a key to undefined or null has the same effect as removing the key.

    Parameters

    • key: string

      The name of the desired metadata property.

    • value: string

      The value to associate with the key.

    Returns void

remove

  • remove(key: string): void
  • Removes the specified key from the metadata, if it is present.

    Parameters

    • key: string

      The name of the desired metadata property.

    Returns void

removeEventListener

  • removeEventListener<E>(type: E, listener: EventListener<DocumentMetadataEventTypes[E]>): void
  • Removes a previously added listener for the specified type of event. This method does nothing if the listener was never added.

    see

    addEventListener

    Type parameters

    • E: "change"

    Parameters

    • type: E

      A string naming the event type.

    • listener: EventListener<DocumentMetadataEventTypes[E]>

      The event listener to stop notifying when the event occurs.

    Returns void

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