Page History
...
Excerpt | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1. Initialization OptionsThere are several options letting you initialize WProofreader functionality in your web app, namely using:
The WEBSPELLCHECKER_CONFIG can be added in a script or loaded from the file as mentioned in Get Started with WProofreader Server (autoSearch) guide for Server version and Get Started with WProofreader Cloud autoSearch. After you have initialized WProofreader, you can customize the above-mentioned settings using WebSpellChecker API.
Below you can find the samples showing how different WProofreader initialization approaches work depending on the integration and expected launch behavior. Example1.1: InitializingWProofreaderusing autoSearch
Example A: Initializing WProofreader with autoSearchfunctionalityanddefiningconfiguration options inCONFIGCONFIG
Example B: Initializing WProofreader with autoSearchfunctionalityand defining configuration options using inline data attributesThis is an example of WProofreader initialization with autoSearch. All the configuration options are defined using inline data attributes.
Example 2: Initializing WProofreader using autoSearch and init() methodWhen you initialize WProofreader using this method, in init () method we declare the container where WProofreader should be started. The options are to be obtained from the settings.
Initializing WProofreader using init() method in a defined container (div element) on the page and specifying configuration options directly in the init() function:
1.2: Initialization using init() methodin a defined containerinfoWhen you initialize WProofreader using this method, in init () method weyou declare the container where WProofreader should be started. The options are to be obtained from the settings. The init() method is a reasonable choice when you clearly know in which control you want to initialize in WProofreader. More than that you are aware of your page controls, and additional controls do not appear dynamically.
With dynamic web page load using init() method, administrator needs to be monitor when it’s necessary to start WProofreader. Example 1: Initializing WProofreader in HTML element using init() methodInitializing WProofreader using init() method in a defined container (div element) on the page and specifying configuration options directly in the init() function:
Example 2: Initializating WProofreader in multiple HTML elements using init() methodInitializing WProofreader using init() method in a defined container(s) on the page and specifying configuration options in WEBSPELLCHECKER_CONFIG is shown in the sample below. You can see two containers, namely, div and textarea which use a single configuration script:
Example43: Initializing WProofreaderby redefining options priorityin HTML elements using data-wsc-autocreateThis is an example of WProofreader initialization in HTML editable elements and elements with and contenteditable attribute set to true Initializing WProofreader in HTML controls using data-wsc-autocreate="true" and specifying . The configuration options are to be defined separately in WEBSPELLCHECKER_CONFIG. This approach is similar to initializing WProofreader using init() method.
Example 4: Initializing WProofreader in WYSIWYG editors using init() methodThere is an option to explicitly initialize WProofreader in such Rich text editors using autoSearch and autoDestroy in WYSIWYG editors such as Froala Editor 3, CKEditor 4, and CKEditor 5 and specifying the options in CONFIG.
using init() method. However, it is strongly recommended to use this method with autoSearch and autoDestroy options in WEBSPELLCHECKER_CONFIG. Turn on autoDestroy parameter to monitor the state of the WEBSPELLCHECKER instance and handle its destroy after removal (deleted or hidden) of an editable container from the page. At the same time enabled autoSearch parameter will restore an instance when it is needed. It can be useful for example, when switching to the code editing mode in the editor, WEBSPELLCHECKER instance must be deleted and then restored after returning back to the editor. Thus, it is the autoSearch that restores it. Initializing WProofreader using init() in Froala Editor
Example 5: Using init() method with autoSearch and autoDestroy in WYSIWYG editorsWhen initializingInitializing WProofreader using init()method with autoSearch and autoDestroyinWYSIWYG editors such as Froala Editor 3,CKEditor 4, and CKEditor 5 and specifying the options in CONFIG, the autoDestroy parameter turns on/off the auto-destroy functionality of a WebSpellChecker instance. By default, it is enabled for WProofreader initialized using autoSearch. It can be used to avoid monitoring the state of the instance and handling its destroying after removal of an editable container from the page.It can be useful for example, when we have created our instance, and later we don’t need to worry to remove it in certain cases. Deleting an instance from the page takes place when an edited element is deleted or hidden. When switching to the code editing mode in the editor we need to delete our instance and then to restore it after returning back to the editor. Thus, it is the autoSearch that restores it.
Initializing WProofreader using init() in CKEditor 5
|