The online document editor provides a default merge field behavior including a specific highlight color, a doubled input position and a highlight mode. When loading an Office Open XML (DOCX) document, this behavior can be adjusted programmatically to provide the same look and feel.

The following screenshot shows the default behavior of merge fields in the document editor:

Default merge field behavior

After loading an Office Open XML (DOCX) document into the editor, the fields are imported, but the default behavior is different. The user is only able to see that there is a field at the input position by hovering over the field using the mouse or by checking the enabled ribbon bar buttons such as Field Properties:

Default merge field behavior

The reason why this behavior is not restored is that these properties can be adjusted for each field individually and that the MS Word format (DOCX) doesn't provide such a feature. If you store the document in the internal TX Text Control format, those properties are stored and loaded automatically.

To restore this behavior after loading a document, it is possible to use the JavaScript API to loop through all fields in order to set the specific properties:

TXTextControl.applicationFields.forEach(function(field) {
field.setHighlightColor("rgba(0, 0, 0, 0.235)");
view raw test.js hosted with ❤ by GitHub

After this, the fields are highlighted in the default color and the doubled input position is added:

Default merge field behavior