Skip to content

Commit 894bc0c

Browse files
committed
Merge branch 'development'
2 parents e9d58d2 + 39bfc8d commit 894bc0c

7 files changed

Lines changed: 36 additions & 5 deletions

File tree

File renamed without changes.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# WProofreader plugin for CKEditor 5 Changelog
22

3+
## 3.1.3 - 2025-05-01
4+
5+
* Fix issue when WEBSPELLCHECKER is undefined after script loading. [#92](https://github.com/WebSpellChecker/wproofreader-ckeditor5/issues/92).
6+
* Internal changes (updated dependencies, documentation, etc.).
7+
38
## 3.1.2 - 2024-08-16
49

510
Internal changes (updated dependencies, documentation, etc.).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@webspellchecker/wproofreader-ckeditor5",
3-
"version": "3.1.2",
3+
"version": "3.1.3",
44
"description": "Multilingual spelling and grammar checking plugin for CKEditor 5",
55
"repository": {
66
"type": "git",

src/wproofreader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ export default class WProofreader extends Plugin {
150150
_loadWscbundle() {
151151
const scriptLoader = new ScriptLoader(this._userOptions.srcUrl);
152152

153-
return scriptLoader.load();
153+
return scriptLoader.load()
154+
.then(() => {
155+
if (!window.WEBSPELLCHECKER) {
156+
throw new Error('WEBSPELLCHECKER is not defined.');
157+
}
158+
});
154159
}
155160

156161
/**
@@ -278,7 +283,7 @@ export default class WProofreader extends Plugin {
278283
* @private
279284
*/
280285
_createInstance(root) {
281-
WEBSPELLCHECKER.init(this._mergeOptions(root), this._handleInstanceCreated.bind(this));
286+
window.WEBSPELLCHECKER.init(this._mergeOptions(root), this._handleInstanceCreated.bind(this));
282287
}
283288

284289
/**

tests/mocks/mock-script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(function() { })()

tests/wproofreader.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,26 @@ describe('WProofreader', () => {
452452
expect(editor.editing.view.getDomRoot('main')).to.not.be.equal(span);
453453
});
454454
});
455+
456+
describe('_loadWscbundle() method', () => {
457+
it('should throw an error if WEBSPELLCHECKER is not defined', () => {
458+
const options = { srcUrl: 'http://localhost:3000/tests/mocks/mock-script.js' };
459+
const copy = window.WEBSPELLCHECKER;
460+
461+
delete window.WEBSPELLCHECKER;
462+
463+
const wproofreader = new WProofreader();
464+
wproofreader._userOptions = options;
465+
466+
return wproofreader._loadWscbundle()
467+
.catch((e) => {
468+
expect(e.message).to.be.equal('WEBSPELLCHECKER is not defined.');
469+
})
470+
.finally(() => {
471+
window.WEBSPELLCHECKER = copy;
472+
});
473+
});
474+
});
455475
});
456476

457477
describe('in CKEditor 5 restricted editing mode', () => {

0 commit comments

Comments
 (0)