Lurch web app user interface

Class

SettingMetadata

Every setting in the app must come with some metadata, including its name (a unique key used for saving it), its label (what prompt will be shown on screen to the user when editing the setting), and its default value (which will be its value before the user has ever edited or even seen that setting). This abstract base class supports just those three features, but does not do anything useful with them yet, except provide generic functionality factored out of most subclasses.

This is not to be confused with SettingsMetadata (note the plural), which is for an entire collection of settings. This one (the singular) is the metadata for just one setting.

Constructor

new SettingMetadata(name, label, defaultValue)

Construct a metadata record about a setting in the app.

Parameters

  • name String

    the unique key for this setting

  • label String

    the prompt shown to the user when editing this setting

  • defaultValue any

    the default value for this setting

Source

Classes

SettingMetadata

Methods

control() → {Object}

Whenever this setting needs to be presented to the user in the UI, this function will be called to create JSON data representing the setting, which should be the kind of data representing a control in TinyMCE's custom dialog interface, documented here: https://www.tiny.cloud/docs/tinymce/6/dialog-components/

Returns

  • Object

    an object representing the UI control for this setting

Source

convert(data) → {any}

When a new value for this setting is provided, it may be of the wrong type (e.g., because it was loaded from localStorage, which can only store strings). This function can be used to convert the data back into the appropriate type for this setting.

Parameters

  • data any

    the data to convert to the appropriate type

Returns

  • any

    the same data, possibly converted to a new type

Source

validate(data) → {Array.<String>}

By default, a setting does not have any error checking built in. Thus its validate function always returns an empty array, meaning no errors. This can be customized in subclasses to return a list of error messages (each one a string suitable for display in a TinyMCE dialog).

Parameters

  • data Object

    the data currently in the UI for this setting, as produced by a call to getData() in the dialog, followed by looking up the specific value associated with this setting's name

Returns

  • Array.<String>

    an array of error messages, or an empty array if there are no errors (as in this default implementation)

Source