Generic Text Fields Plugin

Plugin which adds one or more text fields to the right column (meta section) of Naviga Writer. The plugin can be used
several times with different configurations.

In addition, a legend can be defined for the group of fields. If such a legend exists, it will be displayed at the top of the field group.

Breaking Changes when upgrading 1.0.0 -> 2.0.0

1.0.0 contained a bug where fields.type-configuration never worked, and always placed the value in contentMeta, even if it was set to itemMeta.

Version 2.0.0 fixes this, so to ensure that nothing breaks and preserve compatibility please make sure:

If fields.type is set to "itemMeta", change this to "contentMeta"

Example:

Old configuration where type is set to "itemMeta"

"data": {
    "fields" : [
        {
            "name": "myProp",
            "label": "My Property",
            "type": "itemMeta"
        }
    ]
}

Set type to "contentMeta" to preserve functionality after upgrade:

"data": {
    "fields" : [
        {
            "name": "myProp",
            "label": "My Property",
            "type": "contentMeta"
        }
    ]
}

Plugin Configuration


{
    "id": "io.infomaker.generictextfields.headers",
    "name": "im-generictextfields",
    "url": "https://plugins.writer.infomaker.io/v1/infomaker/im-generictextfields/{PLUGIN_VERSION}/index.js",
    "style": "https://plugins.writer.infomaker.io/v1/infomaker/im-generictextfields/{PLUGIN_VERSION}/style.css",
    "enabled": true,
    "mandatory": false,
    "data": {
        "legend": "Headers",
        "fields" : [
            {
                "name": "header",
                "label": "Header (mandatory)",
                "mandatory": true,
                "type": "contentMeta"
            },
            {
                "name": "subheader",
                "label": "Sub Header",
                "validationPattern": "/^[a-zäåö]/i",
                "validationMessage": "Only letters allowed",
                "type": "itemMeta"
            },
            {
                "name": "superheader",
                "label": "Super Header",
                "type": "itemMeta"
            }
        ]
    }
}

Options

Property Type Required Description
legend String false Name of the field group
fields Array true The list of fields

Fields Options

Fields configuration example:

{
    "name": "unique-name",
    "label": "Unique Name",
    "placeholder": "A placeholder",
    "mandatory": true,
    "validationPattern": "/\w+/g",
    "validationMessage": "No spaces allowed",
    "type": "contentMeta"
},
Property Type Required Description
name String true Specify the name of the field that will be used to read and write to and from the XML (will be prefixed with imext:)
label String false The label to be displayed in the Naviga Writer sidebar. Will default to value of "name"-property if omitted
placeholder String false A placeholder displayed if the field has no value. Only used when there is no "legend"-property in config
validationPattern String false A regular expression, used as a validation pattern. Regular expression start and ends with a forward slash, and must adhere to the ECMA-262 standard, see https://www.ecma-international.org/ecma-262/6.0/#sec-regexp-regular-expression-objects
validationErrorMessage String false A message displayed if the validation fails
mandatory boolean false When set to true, validaton for field will fail if value is empty. Defaults to false
type String false Either "contentMeta" or "itemMeta". Defaults to "contentMeta" if omitted

Field names must be unique within one configured writer!

Output

The plugin generates the XML output described below. Note that the second part of the type attribute is
configured in the plugin. By convention, the type is set as imext:y, where y is the value of "name" set in the plugin configuration listed above.

<newsItem>
  <contentMeta>
    <contentMetaExtProperty type="imext:header" value="Cool header"/>
  </contentMeta>
  <itemMeta>
    <itemMetaExtProperty type="imext:subheader" value="Nicesubheader"/>
  </itemMeta>
</newsItem>