PluginProbe
WProofreader spell & grammar check plugin for WordPress / trunk
WProofreader spell & grammar check plugin for WordPress vtrunk
3.2.1 3.2.2 3.2.0 trunk 1.0 1.1 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.6.1 2.6.10 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7.1 All 28 releases
webspellchecker / assets / environmentChecker.js

environmentChecker.js in WProofreader spell & grammar check plugin for WordPress trunk, at assets/environmentChecker.js

44 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 window.addEventListener("load", (event) => {
2 var serviceConfig = window.WSCServiceConfig || {};
3 var bundlePath = serviceConfig.bundleUrl || 'https://svc.webspellchecker.net/spellcheck31/wscbundle/wscbundle.js';
4
5 function loadScript(doc, src) {
6 // One bundle copy per document. This script runs both in the top frame
7 // and inside the editor-canvas iframe, and the top copy also injects
8 // into the iframe, so without the flag the bundle could load twice.
9 var win = doc.defaultView;
10 if (!win || win.__wscBundleRequested) {
11 return;
12 }
13 win.__wscBundleRequested = true;
14
15 const script = doc.createElement('script');
16 const appendTo = doc.head || doc.documentElement;
17
18 script.type = 'text/javascript';
19 script.async = false;
20 script.src = src;
21
22 appendTo.appendChild(script);
23 }
24
25 if (!window.WEBSPELLCHECKER_CONFIG) {
26 return;
27 }
28
29 window.gutenbergIframe = document.querySelector('[name=editor-canvas]');
30
31 if (window.gutenbergIframe) {
32 // The iframe document hosts the editable content and shows the badge;
33 // the top frame keeps a badge-less SDK for classic metabox fields.
34 const iframeConfig = window.gutenbergIframe.contentWindow.WEBSPELLCHECKER_CONFIG;
35 if (iframeConfig && window.WEBSPELLCHECKER_CONFIG.globalBadge) {
36 window.WEBSPELLCHECKER_CONFIG.globalBadge = false;
37 }
38 loadScript(window.gutenbergIframe.contentWindow.document, bundlePath);
39 window.gutenbergIframe = null;
40 }
41
42 loadScript(document, bundlePath);
43 });
44