Tansa JavaScript API Guide

Note: This guide uses the following Tansa server address: https://d02.tansa.com. This is an example and can usually be used during development, but needs to be changed to a production Tansa server, before the solution can be put into production.

Common JavaScript code block

The following block of JavaScript code is part of several JavaScripts further down. For consistency, the code block is shown and described only here and it is represented by the following placeholder in later JavaScripts: [insert code from earlier in this document].

Please modify the values according to comments.

Add the below code into your HTML files under the header section/tag. Modify the values according to comments.

To add the Tansa menus, use the below code.

Override Tansa Text Manipulation JavaScript Functions
selectText, replaceText, getTexts etc.

Changes to your HTML Page:

Attribute handling

Ignore text element

Tansa provides two solutions to ignore text elements in proofing.

  1. Using the predefined attribute name

By adding (tansa.settings.requireProofingAttribute="true") as a line of code into your HTML files under the header section/tag and by adding attribute (tansa-proofing="true") in your HTML element, to only those text element you want to proof.          

This setting will ignores all text elements except the ones that has the tansa-proofing set to "true".

If tansa.settings.requireProofingAttribute is not specified then all text elements will be processed. So, by default, this setting does not need to be specified.

Note: If you do not use the JS implementation as described earlier in this document, but instead rely on one of the Tansa browser Extensions, you can still utilize the requireProofingAttribute setting by adding this under the header section/tag:

  1. Using custom attribute names

Define the following attribute handling setting in <tomcat folder>\conf\defaultClientSettings.properties

general.SpellcheckAttributes=attributename1: "true/false", attributename2: "true/false"

Example 1:

general.SpellcheckAttributes=run-proofing: true, spellcheck: true

Tansa ignores all text elements except the ones that has the attribute run-proofing set to "true" or (if run-proofing is not found) spellcheck set to "true".

Example 2:

general.SpellcheckAttributes=run-proofing: false
Tansa processes all text elements except the ones that has the attribute
run-proofing set to "false". 

Example 3:

general.SpellcheckAttributes=run-proofing: false, spellcheck: true

Tansa will process all texts except the ones with run-proofing="false" in one page, and also ignore all texts except the ones with spellcheck="true" in another page.
If both of these attributes are defined in the same proofing session (page), then there will be conflicting rules. To avoid this, Tansa will always consider only one attribute and apply that rule on all elements.

Note

If no custom attribute rules have been defined in defaultClientSettings.properties then Tansa will follow the "tansa-proofing: false" rule by default and process all texts except the ones with tansa -proofing="false".

Single line handling

Tansa provides a global setting in <tomcat folder>\conf\defaultClientSettings.properties that controls whether to process single line edit fields or not:

general.SingleLineHandling=1

1 = Tansa will process single line edit fields.

0 = Tansa won’t process single line edit fields.

Integrate with TinyMCE

Changes to your TinyMCE HTML Page:

Example:


Screen shots of a Tansa integration in TinyMCE:

Integrate with CKEditor

Changes to your CKEditor HTML Page:

Screen shots of a Tansa integration in CKEditor:

Integrate with AlloyEditor

Changes to your AlloyEditor HTML Page:

Screen shots of a Tansa integration in AlloyEditor: