StyleGuard Pro JavaScript API Guide

Note: This guide uses the following StyleGuard Pro server address: https://dev.styleguard.com. This is an example and can usually be used during development, but needs to be changed to a production StyleGuard Pro 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].

  1. Add the below code into your HTML files under the header section/tag
  2. Replace parentAppIdProvidedByStyleGuard with value provided by StyleGuard Pro.
  3. Replace "%dynamicParentAppVersion%"with the appropriate version of the parent application.

Notes:

parentAppId: Use the value provided for you by StyleGuard Pro.

parentAppVersion: This should reflect the version of the parent system (editor or CMS system) at any given time, so that error logs and other logs reflect the version of the system being used, making debugging and tracking easier. Example value: "1.0.6.265".

Changes to your HTML-files:

To add the StyleGuard Pro menus, use the below code.

Override StyleGuard Pro Text Manipulation JavaScript Functions
selectText, replaceText, getTexts etc.

Changes to your HTML Page:

Attribute handling

Ignore text element

StyleGuard Pro provides two solutions to ignore text elements in proofing.

  1. Using the predefined attribute name

By adding (lingofy.settings.requireProofingAttribute="true") as a line of code into your HTML files under the header section/tag and by adding attribute (lingofy-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 lingofy-proofing set to "true".

If lingofy.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 StyleGuard Pro 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

StyleGuard Pro 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
StyleGuard Pro 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

StyleGuard Pro 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, StyleGuard Pro 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 StyleGuard Pro will follow the "lingofy-proofing: false" rule by default and process all texts except the ones with lingofy-proofing="false".

Single line handling

StyleGuard Pro 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 = StyleGuard Pro will process single line edit fields.

0 = StyleGuard Pro won’t process single line edit fields.

Integrate with TinyMCE

Changes to your TinyMCE HTML Page:

Example:


Screen shots of a StyleGuard Pro integration in TinyMCE:

Integrate with CKEditor

Changes to your CKEditor HTML Page:

Screen shots of a StyleGuard integration in CKEditor: