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
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)