AppInstance

AppInstance

Represent a WEBSPELLCHECKER Application instance. Result of WEBSPELLCHECKER._createApp method.

Methods

addWordToUserDictionary(word, onSuccess, onError)

Adds a word to the User Dictionary.

Parameters:
Name Type Description
word String

Word that will be added to the User Dictionary.

onSuccess function

On success callback.

onError function

On error callback.

Example
// The word 'exampl' will be added to the User Dictionary.
appInstance.addWordToUserDictionary('exampl');
// If the cursor is set in the Spelling node (for Basic markup only), the word from this node will be added to the User Dictionary.
appInstance.addWordToUserDictionary('');

commitOption(options, settings)

Changes the main APP options.

Parameters:
Name Type Description
options Object

Configuration object.

Properties
Name Type Description
ignoreAllCapsWords Boolean

Ignore all caps words like 'EXAMPL'.

ignoreDomainNames Boolean

Ignore domain names like 'http://example.com'.

ignoreWordsWithMixedCases Boolean

Ignore words with mixed cases like 'eXaMpL'.

ignoreWordsWithNumbers Boolean

Ignore words with numbers like 'exampl7'.

lang String

Language.

settings Object

Extra settings for 'commitOption' method.

Properties
Name Type Description
ignoreCallback Boolean

Ignore 'commitOptions' callback.

Example
appInstance.commitOption({
    'ignoreAllCapsWords': true,
    lang: 'de_DE'
});

appInstance.commitOption(
    { lang: 'de_DE' },
    { ignoreCallback: true }
);

createUserDictionary(name, onSuccess, onError)

Creates a new User Dictionary.

Parameters:
Name Type Description
name String

User Dictionary name.

onSuccess function

On success callback.

onError function

On error callback.

Example
var onSuccess = function() { // Some code here };
var onError = function() { // Some code here };

appInstance.createUserDictionary('test', onSuccess, onError);

deleteWordFromUserDictionary(word, onSuccess, onError)

Deletes a word from the User Dictionary.

Parameters:
Name Type Description
word String

Word that will be deleted from the User Dictionary.

onSuccess function

On success callback.

onError function

On error callback.

Example
// The word 'exampl' will be deleted from the User Dictionary.
appInstance.deleteWordFromUserDictionary('exampl');

destroy()

Destroys an instance.

Example
appInstance.destroy();

disable(options)

Disables the proofreader.

Parameters:
Name Type Description
options Object

Extra options for the 'disable' method.

Properties
Name Type Description
ignoreCallback Boolean

Ignore 'onToggle' callback.

Example
appInstance.disable(); // It will disable proofreader if it was enabled.
appInstance.disable({ ignoreCallback: true }); // It will disable proofreader if it was enabled and 'onToggle' callback will be skipped.

disconnectFromUserDictionary(name, onSuccess, onError)

Disconnects from the User Dictionary.

Parameters:
Name Type Description
name String

User Dictionary name.

onSuccess function

On success callback.

onError function

On error callback.

Example
var onSuccess = function() { // Some code here };
var onError = function() { // Some code here };

appInstance.disconnectFromUserDictionary('test', onSuccess, onError);

enable(options)

Enables the proofreader.

Parameters:
Name Type Description
options Object

Extra options for the 'enable' method.

Properties
Name Type Description
ignoreCallback Boolean

Ignore 'onToggle' callback.

Example
appInstance.enable(); // It will enable proofreader if it was disabled.
appInstance.enable({ ignoreCallback: true }); // It will enable proofreader if it was disabled and 'onToggle' callback will be skipped.

getApplicationConfig() → {Object}

Returns the application config data.

Returns:
  • List of application config data.
Type
Object
Example
// {ignoreAllCapsWords: false, ignoreDomainNames: true, ignoreAllCapsWords: false, ignoreWordsWithNumbers: false}
appInstance.getApplicationConfig();

getAttributeInfo() → {Object}

Returns attributes and classes names.

Returns:
  • Object with attributes and classes names.
Type
Object
Example
appInstance.getAttributeInfo();

getBrandingInfo() → {Object}

Returns branding info.

Returns:
  • Object with branding fields.
Type
Object
Example
appInstance.getBrandingInfo();

getContainerNode() → {Node}

Returns a container node.

Returns:
  • Container node.
Type
Node
Example
appInstance.getContainerNode();

getCustomDictionary() → {String}

Returns a Custom Dictionary name.

Returns:
  • Custom Dictionary name.
Type
String
Example
appInstance.getCustomDictionary(); // '1'

getLang() → {String}

Returns a problem checking language.

Returns:
  • Problem checking language.
Type
String
Example
appInstance.getLang(); // 'en_US'

getLangAttribute() → {String}

Returns lang list attribute name.

Returns:
  • Lang list attribute name.
Type
String
Example
appInstance.getLangAttribute(); // 'data-wsc-lang'

getLangList() → {Object}

Returns a list of all available languages.

Returns:
  • List of all available languages.
Type
Object
Example
appInstance.getLangList();

Returns a path to the logo.

Returns:
  • Path to the logo.
Type
String
Example
appInstance.getLogo();

getOption(optionName) → {Object}

Returns an APP option value.

Parameters:
Name Type Description
optionName String | Array

Option name or array with options names.

Returns:
  • List of application config data.
Type
Object
Example
// {userDictionaryName: null, ignore-all-caps-words: false}
appInstance.getOption(['userDictionaryName', 'ignoreAllCapsWords']);

getProblemsCount() → {Number}

Returns count of problems (Problem nodes) in the container.

Returns:
  • Count of problems in the container.
Type
Number
Example
var count = appInstance.getProblemsCount();

getUserDictionary(userDictionaryName, callback)

Returns the User Dictionary.

Parameters:
Name Type Description
userDictionaryName String

User Dictionary name.

callback function

Callback function.

Example
appInstance.getUserDictionary('userDictionaryName', function(userDictionary) {
     console.log(userDictionary.wordlist)
});

getUserDictionaryName() → {String|Null}

Returns the User Dictionary name.

Returns:
  • User Dictionary name or null.
Type
String | Null
Example
appInstance.getUserDictionaryName();

getVersion() → {String}

Returns a version.

Returns:
  • Version.
Type
String
Example
appInstance.getVersion();

isAllModulesReady() → {Boolean}

Returns true if all modules (sync and async) initialized.

Returns:
  • All modules ready flag.
Type
Boolean
Example
if ( appInstance.isAllModulesReady() ) {};

isDisabled() → {Boolean}

Returns the information if the instance is disabled or enabled.

Returns:
  • true if instance is disabled, false otherwise.
Type
Boolean
Example
appInstance.isDisabled(); // If 'true' - disabled, if 'false' - enabled.

isUserDictionaryExist() → {Boolean}

Checks if the User Dictionary name exists or not.

Returns:
  • true if User Dictionary exists, false otherwise.
Type
Boolean
Example
appInstance.isUserDictionaryExist();

reloadMarkup()

Reloads the markup in the instance. Use it for cases when some text was added without browser events (like innerHTML).

Example
appInstance.reloadMarkup();

removeMarkupFromString(str) → {String}

Removes Problem nodes from the string.

Parameters:
Name Type Description
str String

String with Problem nodes.

Returns:
  • String without Problem nodes.
Type
String
Example
// "<p>This is an exampl of a sentence with one misspelled word.</p>"
appInstance.removeMarkupFromString('<p>This is an <span class="wsc-spelling-problem" data-spelling-word="exampl" data-wsc-lang="en_US">exampl</span> of a sentence with one misspelled word.</p>');

removeUserDictionary(name, onSuccess, onError)

Removes the User Dictionary.

Parameters:
Name Type Description
name String

User Dictionary name.

onSuccess function

On success callback.

onError function

On error callback.

Example
var onSuccess = function() {//Some code here};
var onError = function() {//Some code here};

appInstance.removeUserDictionary('test1', onSuccess, onError);

renameUserDictionary(name, onSuccess, onError)

Renames an existing User Dictionary.

Parameters:
Name Type Description
name String

User Dictionary name.

onSuccess function

On success callback.

onError function

On error callback.

Example
var onSuccess = function() { //Some code here };
var onError = function() { // Some code here };

appInstance.renameUserDictionary('test1', onSuccess, onError);

restoreUserDictionary(name, onSuccess, onError)

Connects a User Dictionary.

Parameters:
Name Type Description
name String

User Dictionary name.

onSuccess function

On success callback.

onError function

On error callback.

Example
var onSuccess = function() { // Some code here };
var onError = function() { // Some code here };

appInstance.restoreUserDictionary('test', onSuccess, onError);

setLang(lang, settings)

Sets a problem checking language. Possible values are:

'en_US', 'en_GB', 'pt_BR', 'da_DK',
'nl_NL', 'en_CA', 'fi_FI', 'fr_FR',
'fr_CA', 'de_DE', 'el_GR', 'it_IT',
'nb_NO', 'pt_PT', 'es_ES', 'sv_SE'.
Parameters:
Name Type Description
lang String

Language.

settings Object

Extra settings for setLang method.

Properties
Name Type Description
ignoreCallback Boolean

Ignore commitOptions callback.

Example
appInstance.setLang('en_GB');

appInstance.setLang('de_DE', { ignoreCallback: true });

setMarkupPaused(flag)

Sets the markup mechanism to pause/unpause.

Parameters:
Name Type Description
flag Boolean

Flag: If the flag equals true - set the markup mechanism on pause, false - unpause.

Example
appInstance.setMarkupPaused(true);

setUserDictionaryName(name)

Sets a User Dictionary name.

Parameters:
Name Type Description
name String

User Dictionary name.

Example
appInstance.setUserDictionaryName('test2', onSuccess, onError);