jodit 4.5.9 → 4.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +71 -24
  5. package/es2015/jodit.min.js +2 -2
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.css +1 -1
  13. package/es2018/jodit.fat.min.js +2 -2
  14. package/es2018/jodit.js +74 -24
  15. package/es2018/jodit.min.js +2 -2
  16. package/es2018/plugins/debug/debug.css +1 -1
  17. package/es2018/plugins/debug/debug.js +1 -1
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  20. package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  22. package/es2021/jodit.css +1 -1
  23. package/es2021/jodit.fat.min.js +2 -2
  24. package/es2021/jodit.js +74 -23
  25. package/es2021/jodit.min.js +2 -2
  26. package/es2021/plugins/debug/debug.css +1 -1
  27. package/es2021/plugins/debug/debug.js +1 -1
  28. package/es2021/plugins/debug/debug.min.js +1 -1
  29. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  30. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  32. package/es2021.en/jodit.css +1 -1
  33. package/es2021.en/jodit.fat.min.js +2 -2
  34. package/es2021.en/jodit.js +74 -23
  35. package/es2021.en/jodit.min.js +2 -2
  36. package/es2021.en/plugins/debug/debug.css +1 -1
  37. package/es2021.en/plugins/debug/debug.js +1 -1
  38. package/es2021.en/plugins/debug/debug.min.js +1 -1
  39. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  40. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  42. package/es5/415.fat.min.js +1 -1
  43. package/es5/415.min.js +1 -1
  44. package/es5/5.fat.min.js +1 -1
  45. package/es5/5.min.js +1 -1
  46. package/es5/jodit.css +2 -2
  47. package/es5/jodit.fat.min.js +2 -2
  48. package/es5/jodit.js +73 -24
  49. package/es5/jodit.min.css +2 -2
  50. package/es5/jodit.min.js +2 -2
  51. package/es5/plugins/debug/debug.css +1 -1
  52. package/es5/plugins/debug/debug.js +1 -1
  53. package/es5/plugins/debug/debug.min.js +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  56. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  57. package/esm/core/async/async.d.ts +13 -3
  58. package/esm/core/async/async.js +58 -10
  59. package/esm/core/constants.js +1 -1
  60. package/esm/core/dom/lazy-walker.d.ts +4 -3
  61. package/esm/core/dom/lazy-walker.js +14 -12
  62. package/esm/types/async.d.ts +6 -0
  63. package/package.json +1 -1
  64. package/types/core/async/async.d.ts +13 -3
  65. package/types/core/dom/lazy-walker.d.ts +4 -3
  66. package/types/types/async.d.ts +6 -0
package/es2015/jodit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.5.9
4
+ * Version: v4.5.11
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1067,9 +1067,10 @@ class Async {
1067
1067
  this.__callbacks = new Map();
1068
1068
  this.__queueMicrotaskNative = (_a = queueMicrotask === null || queueMicrotask === void 0 ? void 0 : queueMicrotask.bind(window)) !== null && _a !== void 0 ? _a : Promise.resolve().then.bind(Promise.resolve());
1069
1069
  this.promisesRejections = new Set();
1070
- this.requestsIdle = new Set();
1071
- this.requestsRaf = new Set();
1072
- this.requestIdleCallbackNative = (_c = (_b = window['requestIdleCallback']) === null || _b === void 0 ? void 0 : _b.bind(window)) !== null && _c !== void 0 ? _c : ((callback, options) => {
1070
+ this.__requestsIdle = new Set();
1071
+ this.__controllers = new Set();
1072
+ this.__requestsRaf = new Set();
1073
+ this.__requestIdleCallbackNative = (_c = (_b = window['requestIdleCallback']) === null || _b === void 0 ? void 0 : _b.bind(window)) !== null && _c !== void 0 ? _c : ((callback, options) => {
1073
1074
  var _a;
1074
1075
  const start = Date.now();
1075
1076
  return this.setTimeout(() => {
@@ -1299,8 +1300,8 @@ class Async {
1299
1300
  return Promise.race([p, t]).then(v => (v === t ? 'pending' : 'fulfilled'), () => 'rejected');
1300
1301
  }
1301
1302
  requestIdleCallback(callback, options = { timeout: 100 }) {
1302
- const request = this.requestIdleCallbackNative(callback, options);
1303
- this.requestsIdle.add(request);
1303
+ const request = this.__requestIdleCallbackNative(callback, options);
1304
+ this.__requestsIdle.add(request);
1304
1305
  return request;
1305
1306
  }
1306
1307
  requestIdlePromise(options) {
@@ -1308,22 +1309,66 @@ class Async {
1308
1309
  const request = this.requestIdleCallback(() => res(request), options);
1309
1310
  });
1310
1311
  }
1312
+ /**
1313
+ * Try to use scheduler.postTask if it is available https://wicg.github.io/scheduling-apis/
1314
+ */
1315
+ schedulerPostTask(task, options = {
1316
+ delay: 0,
1317
+ priority: 'user-visible'
1318
+ }) {
1319
+ const controller = new AbortController();
1320
+ if (options.signal) {
1321
+ options.signal.addEventListener('abort', () => controller.abort());
1322
+ }
1323
+ this.__controllers.add(controller);
1324
+ // @ts-ignore
1325
+ if (typeof globalThis.scheduler !== 'undefined') {
1326
+ const scheduler = globalThis.scheduler;
1327
+ const promise = scheduler.postTask(task, Object.assign(Object.assign({}, options), { signal: controller.signal }));
1328
+ promise
1329
+ .finally(() => {
1330
+ this.__controllers.delete(controller);
1331
+ })
1332
+ .catch(() => null);
1333
+ return promise;
1334
+ }
1335
+ return this.promise((resolve, reject) => {
1336
+ const timeout = this.setTimeout(() => {
1337
+ try {
1338
+ resolve(task());
1339
+ }
1340
+ catch (e) {
1341
+ reject(e);
1342
+ }
1343
+ this.__controllers.delete(controller);
1344
+ }, options.delay || 1);
1345
+ controller.signal.addEventListener('abort', () => {
1346
+ this.clearTimeout(timeout);
1347
+ this.__controllers.delete(controller);
1348
+ reject((0,jodit_core_helpers_utils_error_errors_abort_error__WEBPACK_IMPORTED_MODULE_10__/* .abort */ .h)());
1349
+ });
1350
+ });
1351
+ }
1352
+ schedulerYield() {
1353
+ return this.schedulerPostTask(() => { }, { priority: 'user-visible' });
1354
+ }
1311
1355
  cancelIdleCallback(request) {
1312
- this.requestsIdle.delete(request);
1356
+ this.__requestsIdle.delete(request);
1313
1357
  return this.__cancelIdleCallbackNative(request);
1314
1358
  }
1315
1359
  requestAnimationFrame(callback) {
1316
1360
  const request = requestAnimationFrame(callback);
1317
- this.requestsRaf.add(request);
1361
+ this.__requestsRaf.add(request);
1318
1362
  return request;
1319
1363
  }
1320
1364
  cancelAnimationFrame(request) {
1321
- this.requestsRaf.delete(request);
1365
+ this.__requestsRaf.delete(request);
1322
1366
  cancelAnimationFrame(request);
1323
1367
  }
1324
1368
  clear() {
1325
- this.requestsIdle.forEach(key => this.cancelIdleCallback(key));
1326
- this.requestsRaf.forEach(key => this.cancelAnimationFrame(key));
1369
+ this.__requestsIdle.forEach(key => this.cancelIdleCallback(key));
1370
+ this.__requestsRaf.forEach(key => this.cancelAnimationFrame(key));
1371
+ this.__controllers.forEach(controller => controller.abort());
1327
1372
  this.timers.forEach(key => (0,jodit_core_helpers_async__WEBPACK_IMPORTED_MODULE_1__/* .clearTimeout */ .D)(this.timers.get(key)));
1328
1373
  this.timers.clear();
1329
1374
  this.promisesRejections.forEach(reject => reject());
@@ -1742,7 +1787,7 @@ __webpack_require__.r(__webpack_exports__);
1742
1787
  * Released under MIT see LICENSE.txt in the project root for license information.
1743
1788
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
1744
1789
  */
1745
- const APP_VERSION = "4.5.9";
1790
+ const APP_VERSION = "4.5.11";
1746
1791
  // prettier-ignore
1747
1792
  const ES = "es2015";
1748
1793
  const IS_ES_MODERN = true;
@@ -3654,7 +3699,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3654
3699
  }
3655
3700
  this.workNodes = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.eachGen(root, !this.options.reverse);
3656
3701
  this.isFinished = false;
3657
- this.startIdleRequest();
3702
+ this._requestStarting();
3658
3703
  return this;
3659
3704
  }
3660
3705
  constructor(async, options = {}) {
@@ -3666,12 +3711,16 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3666
3711
  this.isWorked = false;
3667
3712
  this.isFinished = false;
3668
3713
  this.idleId = 0;
3714
+ this.__schedulerController = null;
3669
3715
  }
3670
- startIdleRequest() {
3671
- var _a;
3672
- this.idleId = this.async.requestIdleCallback(this.workPerform, {
3673
- timeout: (_a = this.options.timeout) !== null && _a !== void 0 ? _a : 10
3674
- });
3716
+ _requestStarting() {
3717
+ this.__schedulerController = new AbortController();
3718
+ this.async
3719
+ .schedulerPostTask(this.__workPerform, {
3720
+ delay: this.options.timeout,
3721
+ signal: this.__schedulerController.signal
3722
+ })
3723
+ .catch(() => null);
3675
3724
  }
3676
3725
  break(reason) {
3677
3726
  if (this.isWorked) {
@@ -3696,15 +3745,13 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3696
3745
  super.destruct();
3697
3746
  this.stop();
3698
3747
  }
3699
- workPerform(deadline) {
3748
+ __workPerform() {
3700
3749
  var _a;
3701
3750
  if (this.workNodes) {
3702
3751
  this.isWorked = true;
3703
3752
  let count = 0;
3704
3753
  const chunkSize = (_a = this.options.timeoutChunkSize) !== null && _a !== void 0 ? _a : 50;
3705
- while (!this.isFinished &&
3706
- (deadline.timeRemaining() > 0 ||
3707
- (deadline.didTimeout && count <= chunkSize))) {
3754
+ while (!this.isFinished && count <= chunkSize) {
3708
3755
  const item = this.workNodes.next();
3709
3756
  count += 1;
3710
3757
  if (this.visitNode(item.value)) {
@@ -3720,7 +3767,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3720
3767
  this.end();
3721
3768
  }
3722
3769
  if (!this.isFinished) {
3723
- this.startIdleRequest();
3770
+ this._requestStarting();
3724
3771
  }
3725
3772
  }
3726
3773
  visitNode(nodeElm) {
@@ -3735,7 +3782,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3735
3782
  }
3736
3783
  (0,tslib__WEBPACK_IMPORTED_MODULE_3__/* .__decorate */ .Cg)([
3737
3784
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_0__.autobind
3738
- ], LazyWalker.prototype, "workPerform", null);
3785
+ ], LazyWalker.prototype, "__workPerform", null);
3739
3786
 
3740
3787
 
3741
3788
  /***/ }),