SCAYT

SCAYT

new SCAYT(options)

Represents a SpellCheckAsYouType (SCAYT) Application for Textboxes.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
container string | Node

DOM node with text or its selector.

autoStartup boolean <optional>
false

The parameter turns on/off SCAYT on the autostartup. If 'true', turns on SCAYT automatically after loading the SCAYT application.

enableGrayt boolean <optional>
false

The parameter turns Grammar As You Type on/off on the SCAYT startup. If 'true', it turns on grammar check functionality automatically once SCAYT has started.

contextMenuSections string <optional>
'probleminfo|suggest|moresuggest|control|clipboard|options'

The parameter defines the existence and the order of menu items inside of their sections. E.g. if you remove the "Control" section, then all its items (Ignore, Ignore All, Add Word) will not be included to the view. Please note that the "About" menu item and its tab aren’t allowed to be removed by default. Such a customization can be provided for an additional fee and for more details, please contact support@webspellchecker.

contextMenuCommands string <optional>
'problemdescription|ignore|ignoreall|addword|undo|redo|cut|copy|paste|settings|togglescayt|help'

The parameter defines existance and order of menu items inside of their sections.

spellcheckLang string <optional>
'en_US'

The parameter sets the default spell checking language for SCAYT. 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'.

suggestionsCount number <optional>
3

The parameter defines the number of SCAYT suggestions to show in the context menu. Possible values are: '0' (zero) – No suggestions are shown in the context menu. All suggestions will be listed in the "More Suggestions" sub-menu. Positive number – The maximum number of suggestions to show in the context menu. Other suggestions will be shown in the "More Suggestions" sub-menu. Negative number – 5 suggestions are shown in the context menu. All other suggestions will be listed in the "More Suggestions" sub-menu.

moreSuggestionsCount number <optional>
10

The parameter enables/disables the "More Suggestions" sub-menu in the context menu. Possible values are: '0' (zero) – No suggestions are shown in the "More Suggestions" sub-menu. Positive number – The maximum number of suggestions to show in "More Suggestions" sub-menu. Negative number – 10 suggestions are shown in "More Suggestions" sub-menu.

serviceProtocol string <optional>
'http'

The parameter allows to specify protocol for WSC service (entry point is ssrv.cgi) full path.

serviceHost string <optional>
'svc.webspellchecker.net'

The parameter allows to specify host for WSC service (entry point is ssrv.cgi) full path.

servicePort number <optional>
'80'

The parameter allows to specify default port for WSC service (entry point is ssrv.cgi) full path.

servicePath string <optional>
'spellcheck31/script/ssrv.cgi'

The parameter allows to specify path for WSC service (entry point is ssrv.cgi) full path.

additionalMenuItems Object.<string, Object> <optional>
{}

The parameter allows to specify user defined menu items with custom behavior. Please find an example of such implementation in the "Example" section below.

theme string <optional>
'classic-blue'

The parameter allows to specify a desired theme for UI. Possible values are: 'classic-blue'.

minWordLength number <optional>
4

The parameter defines minimum length of the letters that will be collected from container's text for spell checking. Possible value is any positive number.

customDictionaryIds string <optional>
''

The parameter links SCAYT to custom dictionaries. Here is a string containing dictionary IDs separated by commas (','). Further details can be found at http://wiki.webspellchecker.net/doku.php?id=installationandconfiguration:customdictionaries:licensed.

userDictionaryName string <optional>
''

The parameter activates a User Dictionary in SCAYT.

uiTabs string <optional>
'options,languages,dictionaries,about'

The parameter customizes the SCAYT dialog to show particular tabs. Please note that the "About" menu item and its tab aren’t allowed to be removed by default. Such a customization can be provided for an additional fee and for more details, please contact support@webspellchecker.

customerId string <optional>
'1:j47ai-r4SLN1-dG5xP1-UuonU-WqXUZ3-0bzqZ1-QI8OP1-bQZcb1-KQuPE3-nWbcY3-aA4Zk4-wT9'

The parameter sets the customer ID for SCAYT. It used for a migration from free, ad-supported version to paid, ad-free version.

customPunctuation string <optional>
'-'

The parameter that receives a string with characters that will considered as separators.

localization string <optional>
'en'

The parameter sets localization. If no parameter is specified by a user, it will be detected automatically from a browser settings. If the parameter can't be automatically detected, a default value will be used. Possible values are: 'af', 'ar', 'bg', 'bn', 'bs', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'en-us', 'en-au', 'en-ca', 'en-gb', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr-ca', 'fr', 'gl', 'gu', 'he', 'hi', 'hr', 'hu', 'is', 'it', 'ja', 'ka', 'km', 'ko', 'lt', 'lv', 'mk', 'mn', 'ms', 'nb', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr-latn', 'sr', 'sv', 'th', 'tr', 'ug', 'uk','ku', 'vi', 'zh-cn', 'zh'

elementsToIgnore string <optional>
'style|script'

The parameter specifies the names of tags which will be skipped while spell checking. It is a string containing tag names separated by '|' symbol. E.g.: 'style|del'. Please note that the "Style" and "Script" tags will be added to a specified tag list.

ignoreAllCapsWords boolean <optional>
false

The parameter enables the "Ignore All-Caps Words" option by default. You may need to options.disableOptionsStorage (disable option storing) for this setting to be effective because option storage has a higher priority.

ignoreDomainNames boolean <optional>
true

The parameter enables the "Ignore Domain Names" option by default. You may need to options.disableOptionsStorage (disable option storing) for this setting to be effective because option storage has a higher priority.

ignoreWordsWithMixedCases boolean <optional>
false

The parameter enables the "Ignore Words with Mixed Case" option by default. You may need to options.disableOptionsStorage (disable option storing) for this setting to be effective because option storage has a higher priority.

ignoreWordsWithNumbers boolean <optional>
false

The parameter enables the "Ignore Words with Numbers" option by default. You may need to options.disableOptionsStorage (disable option storing) for this setting to be effective because option storage has a higher priority.

disableOptionsStorage array <optional>
[]

The parameter disables storing of SCAYT options between sessions. Option storing will be turned off after a page refresh. The following settings can be used:

  • 'options' – Disables storing of all SCAYT Ignore options, except 'lang'.
  • 'ignore-all-caps-words' – Disables storing of the "Ignore All-Caps Words" option.
  • 'ignore-domain-names' – Disables storing of the "Ignore Domain Names" option.
  • 'ignore-words-with-mixed-cases' – Disables storing of the "Ignore Words with Mixed Case" option.
  • 'ignore-words-with-numbers' – Disables storing of the "Ignore Words with Numbers" option.
  • 'lang' – Disables storing of the SCAYT spell check language.
  • 'all' – Disables storing of all SCAYT options.
shortcutsList array <optional>
[]

The parameter sets a shortcuts list. It is an array containing objects with a shortcut and callback function. See example below.
Use the next combinations for modifier keys:

  • SCAYT.CTRL - for 'ctrl' (on Windows) or 'command' (on Mac) key.
  • SCAYT.ALT - for 'alt' key.
  • SCAYT.SHIFT - for 'shift' key.

For other keys use numerical code from the next link:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode

undoDataSize number <optional>
20

The parameter sets length of the Undo array.

enableOnTouchDevices boolean <optional>
false

The parameter enables SCAYT support on the touch devices.

onLoad function

This is the SCAYT onLoad callback.

Example
var instance = new SCAYT.SCAYT({
    container: document.getElementById('elementId'),
    autoStartup: true,
    enableGrayt: true,
    spellcheckLang: 'de_DE',
    localization: 'de',
    contextMenuSections: 'probleminfo|suggest|moresuggest|control|clipboard|options',
    contextMenuCommands: 'problemdescription|ignore|ignoreall|addword|undo|redo|cut|copy|paste|customItem1|settings|togglescayt|help|customItem2',
    serviceProtocol: 'http',
    servicePort: '80',
    serviceHost: document.location.host,
    servicePath: 'spellcheck/script/ssrv.cgi',
    ignoreAllCapsWords: true,
    ignoreDomainNames: false,
    ignoreWordsWithMixedCases: true,
    ignoreWordsWithNumbers: true,
    disableOptionsStorage: ['lang', 'ignore-domain-names'],
    undoDataSize: 10,
    enableOnTouchDevices: true,
    additionalMenuItems: {
        'customItem1': {
            itemTitle: 'I am in clipboard section',
            order: 0,
            group: 'clipboard',
            extraClass: 'some-class-1',
            onClick: function() {return true;}
        },
        'customItem2': {
            itemTitle: 'I am in default section',
            extraClass: 'some-class-2',
            onClick: function() {return true;}
        }
    },
    shortcutsList: [
        {
            shortcut: SCAYT.CTRL + 'B'.charCodeAt(0), // 'B'.charCodeAt(0) === 66. Char code of the letter 'B'.
            callback: function() {
                console.log('ctrl+B from user');
            }
        },
        {
            shortcut: SCAYT.CTRL + SCAYT.SHIFT + 66, // 66 is the char code of the letter 'B'.
            callback: function() {
                console.log('ctrl+shift+B from user');
            }
        }
    ],
    onLoad: function() {
        // 'this' refers to SCAYT instance
        this.setDisabled(true);
    }
});

// For iframe based instance
var iframeInstance;
var iframeElement = document.getElementById('iframeElementId');
SCAYT.SCAYT.createScaytControl(iframeElement, {
        autoStartup: true,
        spellcheckLang: 'de_DE',
        localization: 'de',
        serviceProtocol: 'http',
        servicePort: '80',
        serviceHost: document.location.host,
        servicePath: 'spellcheck/script/ssrv.cgi'
    },
    function(instance) {
        iframeInstance = instance;
    }
);

Members

(static) options :Object

Represents default SCAYT for Textboxes application options

Type:
  • Object
Properties:
Name Type Description
dataAttributeName string

It is a default attribute name that is used for storing of the SCAYT misspelling word. Default value : ['data-scayt-word']

misspelledWordClass string

It is a default class name that is used for marking of the SCAYT misspellings. Default value : ['scayt-misspell-word']

problemGrammarDataAttribute string

It is a default attribute name that is used for storing of the GRAYT problem phrase. Default value : ['data-grayt-phrase']

problemGrammarClass string

It is a default class name that is used for marking of the GRAYT problems. Default value : ['gramm-problem']

supportedThemes Object

It is a set of supported themes.

supportedThemes boolean

['classic-blue'] - The property indicates whether the 'Classic-blue' theme is supported or not. Default value : [true]

Default Value:
  • [{ dataAttributeName: 'data-scayt-word', misspelledWordClass: 'scayt-misspell-word', problemGrammarDataAttribute: 'data-grayt-phrase', problemGrammarClass: 'gramm-problem', supportedThemes: { 'classic-blue': true } }]

basePath :string

Represents absolute path to SCAYT application

Type:
  • string

Methods

(static) createScaytControl(selector, options, callback)

Create a SCAYT instance by ID or from passed HTML element.

Parameters:
Name Type Description
selector String | Node

ID of the original element or HTML element.

options Object

Options.

callback function

Callback function.

Example
var scaytInstance1;
SCAYT.SCAYT.createScaytControl('originalElementId', {
        autoStartup: true,
        spellcheckLang: 'de_DE',
        localization: 'de',
        serviceProtocol: 'http',
        servicePort: '80',
        serviceHost: document.location.host,
        servicePath: 'spellcheck/script/ssrv.cgi'
    },
    function(instance) {
        scaytInstance1 = instance;
    }
);

var scaytInstance2;
var htmlElement = document.getElementById('originalElementId');
SCAYT.SCAYT.createScaytControl(htmlElement, {
        autoStartup: true,
        spellcheckLang: 'de_DE',
        localization: 'de',
        serviceProtocol: 'http',
        servicePort: '80',
        serviceHost: document.location.host,
        servicePath: 'spellcheck/script/ssrv.cgi'
    },
    function(instance) {
        scaytInstance2 = instance;
    }
);

(static) createScaytControlById(id, options) → {object}

Create a SCAYT instance by ID.

Parameters:
Name Type Description
id String

ID of the original element.

options Object

Options.

Returns:
  • SCAYT instance.
Type
object
Example
var scaytInstance = SCAYT.SCAYT.createScaytControlById('originalElementId', {
    autoStartup: true,
    spellcheckLang: 'de_DE',
    localization: 'de',
    serviceProtocol: 'http',
    servicePort: '80',
    serviceHost: document.location.host,
    servicePath: 'spellcheck/script/ssrv.cgi'
});

(static) getScaytControlById(id) → {object}

Get a SCAYT instance by ID.

Parameters:
Name Type Description
id String

ID of the original element.

Returns:
  • SCAYT instance.
Type
object
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');

commitOption(options)

Change the main SCAYT options.

Parameters:
Name Type Description
options Object

Configuration object.

Properties
Name Type Description
ignore-all-caps-words Boolean

Ignore all caps word like 'EXAMPL'.

ignore-domain-names Boolean

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

ignore-words-with-mixed-cases Boolean

Ignore words with mixed cases like 'eXaMpL'.

ignore-words-with-numbers Boolean

Ignore words with numbers like 'exampl7'.

lang String

Change language.

Example
scaytInstance.commitOption({
    'ignore-all-caps-words': true,
    lang: 'de_DE'
});

destroy()

Destroy a SCAYT instance.

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.destroy();

getData() → {String}

Get data from container.

Returns:
  • Data from container.
Type
String
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
var data = scaytInstance.getData(); // if original element is input/textarea - method returns text, else - html

getLang() → {string}

Get a spelling check language.

Returns:
  • Spelling check language.
Type
string
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.getLang(); // 'en_US'

getOption(optionName) → {Object}

Get a SCAYT 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
scaytInstance.getOption(['userDictionaryName', 'ignore-all-caps-words']); // {userDictionaryName: null, ignore-all-caps-words: false}

getProblemsCount() → {Number}

Get count of problems (SCAYT and GRAYT nodes) in the container.

Returns:
  • Count of problems in the container.
Type
Number
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
var count = scaytInstance.getProblemsCount();

getSuggestions(word, lang) → {array|null}

Get suggestions for a specified word.

Parameters:
Name Type Description
word String

Word.

lang String

Language.

Returns:
  • Array of the suggestions or null.
Type
array | null
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId'); // any element id
scaytInstance.getSuggestions('exampl', 'en_US');

getTextLength() → {number}

Get length of text in the container.

Returns:
  • Length of text in the container.
Type
number
Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
var textLength = scaytInstance.getTextLength();

isDisabled()

Return information about disabled or enabled SCAYT instance.

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.isDisabled(); // if 'true' - disabled, if 'false' - enabled

openDialog(dialogName, callback)

Open SCAYT dialog.
Type of the dialog is 'pasteDialog' and 'scaytDialog'.

Parameters:
Name Type Description
dialogName String

Type of the dialog. Can be 'pasteDialog' and 'scaytDialog'.

callback function

Callback function

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.openDialog('dialogName', function() {});

refresh()

Refresh a SCAYT instance.
The method should be used when the native HTML element's content was changed programmatically.
After calling scaytInstance.refresh(), the SCAYT markup in the SCAYT control will be updated.

Example
var originalElement = document.getElementById('originalElementId');
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');

originalElement.value = 'Some new value';
scaytInstance.refresh();

removeShortcuts(shortcuts)

Remove a shortcuts combination.
Use the next combinations for modifier keys:

SCAYT.CTRL - for 'ctrl' (on Windows) or 'command' (on Mac) key.
SCAYT.ALT - for 'alt' key.
SCAYT.SHIFT - for 'shift' key.
For other keys use numerical code from the next link:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode

Parameters:
Name Type Description
shortcuts Array

Array of the Objects contains shortcuts combinations and callback function

Example
var callback1 = function() {};
var callback2 = function() {};
var context = {};
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setShortcuts([
    {
        shortcut: SCAYT.CTRL + 66, // for 'ctrl + B' combination
        callback: callback1
    },
    {
        shortcut: SCAYT.CTRL + SCAYT.SHIFT + 66, // for 'ctrl + shift + B' combination
        callback: callback2, // 'this' in callback2 function will be the 'context' object
        context: context
    }
]);

scaytInstance.removeShortcuts([
    {
        shortcut: SCAYT.CTRL + 66, // for 'ctrl + B' combination
        callback: callback1
    },
    {
        shortcut: SCAYT.CTRL + SCAYT.SHIFT + 66, // for 'ctrl + shift + B' combination
        callback: callback2 // 'this' in callback2 function will be the 'context' object
    }
]);

setCssStyles(styles)

Set CSS styles to a specified HTML control.

Parameters:
Name Type Description
styles Object

Object with CSS styles.

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setCssStyles({
    color: 'red',
    width: '400px'
});

setData(data)

Set data to a container.

Parameters:
Name Type Description
data String

Data to set to a container

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setData('Some data'); // if original element is input/textarea - pass text, else - text or html

setDisabled(flag)

Set a SCAYT instance to disabled/enabled.

Parameters:
Name Type Description
flag Boolean

Flag: If the flag equals 'true' - disable instance, if 'false' - enable instance.

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setDisabled(true);

setLang(lang)

Set a spelling check 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.

Example
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setLang('en_GB');

setShortcuts(shortcuts)

Set a shortcuts combination.
Use the next combinations for modifier keys:

SCAYT.CTRL - for 'ctrl' (on Windows) or 'command' (on Mac) key.
SCAYT.ALT - for 'alt' key.
SCAYT.SHIFT - for 'shift' key.
For other keys use numerical code from the next link:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode

Parameters:
Name Type Description
shortcuts Array

Array of the Objects contains shortcuts combinations, callback function and context for callback function

Example
var callback1 = function() {};
var callback2 = function() {};
var context = {};
var scaytInstance = SCAYT.SCAYT.getScaytControlById('originalElementId');
scaytInstance.setShortcuts([
    {
        shortcut: SCAYT.CTRL + 66, // for 'ctrl + B' combination
        callback: callback1
    },
    {
        shortcut: SCAYT.CTRL + SCAYT.SHIFT + 66, // for 'ctrl + shift + B' combination
        callback: callback2, // 'this' in callback2 function will be the 'context' object
        context: context
    }
]);