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
@@ -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.__queueMicrotaskNative = queueMicrotask?.bind(window) ??
1068
1068
  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 = window['requestIdleCallback']?.bind(window) ??
1070
+ this.__requestsIdle = new Set();
1071
+ this.__controllers = new Set();
1072
+ this.__requestsRaf = new Set();
1073
+ this.__requestIdleCallbackNative = window['requestIdleCallback']?.bind(window) ??
1073
1074
  ((callback, options) => {
1074
1075
  const start = Date.now();
1075
1076
  return this.setTimeout(() => {
@@ -1300,8 +1301,8 @@ class Async {
1300
1301
  return Promise.race([p, t]).then(v => (v === t ? 'pending' : 'fulfilled'), () => 'rejected');
1301
1302
  }
1302
1303
  requestIdleCallback(callback, options = { timeout: 100 }) {
1303
- const request = this.requestIdleCallbackNative(callback, options);
1304
- this.requestsIdle.add(request);
1304
+ const request = this.__requestIdleCallbackNative(callback, options);
1305
+ this.__requestsIdle.add(request);
1305
1306
  return request;
1306
1307
  }
1307
1308
  requestIdlePromise(options) {
@@ -1309,22 +1310,69 @@ class Async {
1309
1310
  const request = this.requestIdleCallback(() => res(request), options);
1310
1311
  });
1311
1312
  }
1313
+ /**
1314
+ * Try to use scheduler.postTask if it is available https://wicg.github.io/scheduling-apis/
1315
+ */
1316
+ schedulerPostTask(task, options = {
1317
+ delay: 0,
1318
+ priority: 'user-visible'
1319
+ }) {
1320
+ const controller = new AbortController();
1321
+ if (options.signal) {
1322
+ options.signal.addEventListener('abort', () => controller.abort());
1323
+ }
1324
+ this.__controllers.add(controller);
1325
+ // @ts-ignore
1326
+ if (typeof globalThis.scheduler !== 'undefined') {
1327
+ const scheduler = globalThis.scheduler;
1328
+ const promise = scheduler.postTask(task, {
1329
+ ...options,
1330
+ signal: controller.signal
1331
+ });
1332
+ promise
1333
+ .finally(() => {
1334
+ this.__controllers.delete(controller);
1335
+ })
1336
+ .catch(() => null);
1337
+ return promise;
1338
+ }
1339
+ return this.promise((resolve, reject) => {
1340
+ const timeout = this.setTimeout(() => {
1341
+ try {
1342
+ resolve(task());
1343
+ }
1344
+ catch (e) {
1345
+ reject(e);
1346
+ }
1347
+ this.__controllers.delete(controller);
1348
+ }, options.delay || 1);
1349
+ controller.signal.addEventListener('abort', () => {
1350
+ this.clearTimeout(timeout);
1351
+ this.__controllers.delete(controller);
1352
+ reject((0,jodit_core_helpers_utils_error_errors_abort_error__WEBPACK_IMPORTED_MODULE_10__/* .abort */ .h)());
1353
+ });
1354
+ });
1355
+ }
1356
+ schedulerYield() {
1357
+ return this.schedulerPostTask(() => { }, { priority: 'user-visible' });
1358
+ }
1312
1359
  cancelIdleCallback(request) {
1313
- this.requestsIdle.delete(request);
1360
+ this.__requestsIdle.delete(request);
1314
1361
  return this.__cancelIdleCallbackNative(request);
1315
1362
  }
1316
1363
  requestAnimationFrame(callback) {
1317
1364
  const request = requestAnimationFrame(callback);
1318
- this.requestsRaf.add(request);
1365
+ this.__requestsRaf.add(request);
1319
1366
  return request;
1320
1367
  }
1321
1368
  cancelAnimationFrame(request) {
1322
- this.requestsRaf.delete(request);
1369
+ this.__requestsRaf.delete(request);
1323
1370
  cancelAnimationFrame(request);
1324
1371
  }
1325
1372
  clear() {
1326
- this.requestsIdle.forEach(key => this.cancelIdleCallback(key));
1327
- this.requestsRaf.forEach(key => this.cancelAnimationFrame(key));
1373
+ this.__requestsIdle.forEach(key => this.cancelIdleCallback(key));
1374
+ this.__requestsRaf.forEach(key => this.cancelAnimationFrame(key));
1375
+ this.__controllers.forEach(controller => controller.abort());
1328
1376
  this.timers.forEach(key => (0,jodit_core_helpers_async__WEBPACK_IMPORTED_MODULE_1__/* .clearTimeout */ .D)(this.timers.get(key)));
1329
1377
  this.timers.clear();
1330
1378
  this.promisesRejections.forEach(reject => reject());
@@ -1743,7 +1791,7 @@ __webpack_require__.r(__webpack_exports__);
1743
1791
  * Released under MIT see LICENSE.txt in the project root for license information.
1744
1792
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
1745
1793
  */
1746
- const APP_VERSION = "4.5.9";
1794
+ const APP_VERSION = "4.5.11";
1747
1795
  // prettier-ignore
1748
1796
  const ES = "es2021";
1749
1797
  const IS_ES_MODERN = true;
@@ -3647,7 +3695,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3647
3695
  }
3648
3696
  this.workNodes = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.eachGen(root, !this.options.reverse);
3649
3697
  this.isFinished = false;
3650
- this.startIdleRequest();
3698
+ this._requestStarting();
3651
3699
  return this;
3652
3700
  }
3653
3701
  constructor(async, options = {}) {
@@ -3659,11 +3707,16 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3659
3707
  this.isWorked = false;
3660
3708
  this.isFinished = false;
3661
3709
  this.idleId = 0;
3710
+ this.__schedulerController = null;
3662
3711
  }
3663
- startIdleRequest() {
3664
- this.idleId = this.async.requestIdleCallback(this.workPerform, {
3665
- timeout: this.options.timeout ?? 10
3666
- });
3712
+ _requestStarting() {
3713
+ this.__schedulerController = new AbortController();
3714
+ this.async
3715
+ .schedulerPostTask(this.__workPerform, {
3716
+ delay: this.options.timeout,
3717
+ signal: this.__schedulerController.signal
3718
+ })
3719
+ .catch(() => null);
3667
3720
  }
3668
3721
  break(reason) {
3669
3722
  if (this.isWorked) {
@@ -3688,14 +3741,12 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3688
3741
  super.destruct();
3689
3742
  this.stop();
3690
3743
  }
3691
- workPerform(deadline) {
3744
+ __workPerform() {
3692
3745
  if (this.workNodes) {
3693
3746
  this.isWorked = true;
3694
3747
  let count = 0;
3695
3748
  const chunkSize = this.options.timeoutChunkSize ?? 50;
3696
- while (!this.isFinished &&
3697
- (deadline.timeRemaining() > 0 ||
3698
- (deadline.didTimeout && count <= chunkSize))) {
3749
+ while (!this.isFinished && count <= chunkSize) {
3699
3750
  const item = this.workNodes.next();
3700
3751
  count += 1;
3701
3752
  if (this.visitNode(item.value)) {
@@ -3711,7 +3762,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3711
3762
  this.end();
3712
3763
  }
3713
3764
  if (!this.isFinished) {
3714
- this.startIdleRequest();
3765
+ this._requestStarting();
3715
3766
  }
3716
3767
  }
3717
3768
  visitNode(nodeElm) {
@@ -3725,7 +3776,7 @@ class LazyWalker extends jodit_core_event_emitter_eventify__WEBPACK_IMPORTED_MOD
3725
3776
  }
3726
3777
  (0,tslib__WEBPACK_IMPORTED_MODULE_3__/* .__decorate */ .Cg)([
3727
3778
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_0__.autobind
3728
- ], LazyWalker.prototype, "workPerform", null);
3779
+ ], LazyWalker.prototype, "__workPerform", null);
3729
3780
 
3730
3781
 
3731
3782
  /***/ }),