Editor

The widget can be used to show any kind of text like JSON or scripting code.

Model

{
    "type": "editor",
    "actions": {},
    "content": {},
    "contentToCompare" : {},
    "dataSource": {},
    "editorOptions": {},
    "language" : "json",
    "name": "Editor",
    "schema": {},
    "toolbars": {}
}
Name Description

actions

Optional property used to implement action pipelines for selected trigger events

content

Primary editor content. This can be either text or JSON.

contentToCompare

Setting this property activates the editor’s compare functionality which shows the difference between the content and the contentToCompare side by side.

dataSource

Optional property, used to retrieve data from the system

editorOptions

Optional configuration to define styling for the editor. See Editor Options for all the available editor options.

When the editor is used to compare content, either of the panels can be configured to be editable or read-only by setting the readOnly and originalEditable options as follows:

Editable Panels readOnly originalEditable

Both panels

false

true

Neither panel

true

false

Only the content

true

true

Only the contentToCompare

false

false

id

Unique widget identifier

language

The language setting is used to activate the editor’s syntax coloring and checking. Supported languages:

  • json Default

  • lua

  • markdown

  • txt

  • xml

schema

This property is used when the language is set to "json". It must be assigned a valid JSON Schema definition, which is used by the editor to perform code-completion and schema validation.

toolbars

Optional configuration to add, customise and hide toolbars. See the toolbars section below.

Options

{
    "options": {
        "showToolbar": false
    }
}

Actions

Supported actions:

  • collect

  • send

  • onContentChange

onContentChange

In case onContentChange is defined this will be invoked every time the textual content of the widget is updated. Can be used together with the send action pipeline to send the content to an other widget.

{
    "onContentChange": [
        {
            "type": "send",
            "to": "Place here the ID of the widget"
        }
    ]
}

DataSource

If the dataSource property is defined as an object, the message returned by the data is usually determined by the type field. If dataSource type field does not match the widget type, then the content and contentToCompare fields is checked in the payload and merged into the widget model. However, if these fields are not specified then the payload is assigned to the content field.

If either the content or contentToCompare fields are string values, then the fields may be parsed as a JSON.

Toolbars

The editor widget can have one or more custom toolbars. Additional tools can be added to the default toolbars. To do this, see the toolbars section in the widget documentation.

Tools

The following tools have a default implementation on the editor widget:

Icon Name Description

Editor Language Menu

Editor Language

This tool can be used to change the language of the editor widget. Default is JSON.

JSON Format

Format

This tool can be used to format the text in the editor if required.

Refresh Btn

Refresh

Refreshes the widget

Spacer

This tool is used to specify the alignment of tools in the widget toolbar.

Update Behavior

The update logic of this widget accepts a payload, which is a string or a JSON element. In case the value of the payload is a string, the value will be used to update the content in the model. When the language in the model model is set to json, the widget tries to convert the string into a JSON element. In case the JSON conversion fails, the initial payload string value will be used to update the content in the model.

When the payload is a JSON object, the widget uses the fields content and language to update the fields in the model accordingly. In case the payload does not contain the content field, the JSON object in the payload will be used to update the content in the model. When the content field in the payload is a string and the language field in the model or payload is set to json, the widget tries to convert the value of the content in the payload to a JSON element.