jodit 4.17.5 → 4.17.6

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 (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +5 -5
  4. package/es2015/jodit.js +86 -35
  5. package/es2015/jodit.min.js +5 -5
  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.fat.min.js +5 -5
  13. package/es2018/jodit.min.js +5 -5
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +7 -7
  18. package/es2021/jodit.js +84 -35
  19. package/es2021/jodit.min.js +7 -7
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +7 -7
  28. package/es2021.en/jodit.js +84 -35
  29. package/es2021.en/jodit.min.js +8 -8
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +89 -35
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/core/constants.js +1 -1
  51. package/esm/core/selection/selection.js +31 -5
  52. package/esm/modules/history/history.js +20 -12
  53. package/esm/plugins/line-height/line-height.js +1 -1
  54. package/esm/plugins/placeholder/placeholder.js +1 -1
  55. package/esm/plugins/source/editor/engines/ace.d.ts +2 -0
  56. package/esm/plugins/source/editor/engines/ace.js +35 -3
  57. package/package.json +1 -1
  58. package/types/plugins/source/editor/engines/ace.d.ts +2 -0
package/es2021/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.17.5
4
+ * Version: v4.17.6
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1799,7 +1799,7 @@ __webpack_require__.r(__webpack_exports__);
1799
1799
  * ```
1800
1800
  * @packageDocumentation
1801
1801
  * @module constants
1802
- */ const APP_VERSION = "4.17.5";
1802
+ */ const APP_VERSION = "4.17.6";
1803
1803
  // prettier-ignore
1804
1804
  const ES = "es2021";
1805
1805
  const IS_ES_MODERN = true;
@@ -10845,6 +10845,11 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10845
10845
 
10846
10846
 
10847
10847
 
10848
+ /**
10849
+ * A text node that is empty or holds only invisible caret placeholders.
10850
+ */ function isBlankTextNode(node) {
10851
+ return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && (node.nodeValue ?? '').replace(jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE_REG_EXP(), '').length === 0;
10852
+ }
10848
10853
  class Selection {
10849
10854
  /**
10850
10855
  * Short alias for this.jodit
@@ -11089,10 +11094,21 @@ class Selection {
11089
11094
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(marker, this.j.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE));
11090
11095
  if (newRange) {
11091
11096
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
11092
- // Here need do unsafe inserting
11093
- // Deny Dom.safeInsertNode(newRange, marker);
11094
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11095
- newRange.insertNode(marker);
11097
+ const { startContainer: node, startOffset: offset } = newRange;
11098
+ // At either end of a text node the marker goes beside it. Splitting
11099
+ // the node there would leave the selection's boundary in an empty
11100
+ // text node, and WebKit neither repaints a selection that leaves one
11101
+ // nor moves a selection that follows one when it's removed.
11102
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && offset === 0) {
11103
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.before(node, marker);
11104
+ } else if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && offset === node.nodeValue?.length) {
11105
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.after(node, marker);
11106
+ } else {
11107
+ // Here need do unsafe inserting
11108
+ // Deny Dom.safeInsertNode(newRange, marker);
11109
+ // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11110
+ newRange.insertNode(marker);
11111
+ }
11096
11112
  }
11097
11113
  }
11098
11114
  return marker;
@@ -11414,7 +11430,9 @@ class Selection {
11414
11430
  ()=>firstChild?.previousSibling?.lastChild
11415
11431
  ].forEach((getChildNode)=>{
11416
11432
  const childNode = getChildNode();
11417
- if (childNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(childNode)) {
11433
+ // Only a text node left with nothing in it by the split
11434
+ // goes; one holding a space is content (`<b>a</b> |`).
11435
+ if (childNode && isBlankTextNode(childNode)) {
11418
11436
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(childNode);
11419
11437
  }
11420
11438
  });
@@ -22318,19 +22336,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
22318
22336
  * Update history stack
22319
22337
  */ updateStack(replace = false) {
22320
22338
  const newValue = this.snapshot.make();
22321
- if (!_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22322
- const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22323
- if (replace) {
22324
- const command = this.__stack.current();
22325
- if (command && this.updateTick === command.tick) {
22326
- this.__stack.replace(newCommand);
22327
- }
22328
- } else {
22329
- this.__stack.push(newCommand);
22330
- }
22339
+ if (_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22340
+ return;
22341
+ }
22342
+ // Only the selection moved, for example when the selection markers
22343
+ // went in before a switch to the source view. There is nothing to
22344
+ // undo, but the next change has to start from this selection.
22345
+ if (newValue.html === this.startValue.html) {
22331
22346
  this.startValue = newValue;
22332
- this.fireChangeStack();
22347
+ return;
22333
22348
  }
22349
+ const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22350
+ if (replace) {
22351
+ const command = this.__stack.current();
22352
+ if (command && this.updateTick === command.tick) {
22353
+ this.__stack.replace(newCommand);
22354
+ }
22355
+ } else {
22356
+ this.__stack.push(newCommand);
22357
+ }
22358
+ this.startValue = newValue;
22359
+ this.fireChangeStack();
22334
22360
  }
22335
22361
  fireChangeStack() {
22336
22362
  this.j && !this.j.isInDestruct && this.j.events?.fire('changeStack');
@@ -37099,7 +37125,7 @@ class lineHeight extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
37099
37125
  try {
37100
37126
  if (s.isCollapsed()) {
37101
37127
  const fake = c.fake();
37102
- s.insertNode(fake, false, false);
37128
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeInsertNode(s.range, fake);
37103
37129
  apply(fake);
37104
37130
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(fake);
37105
37131
  } else {
@@ -39122,7 +39148,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
39122
39148
  this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
39123
39149
  }
39124
39150
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
39125
- editor.e.off('.placeholder').on('changePlace.placeholder', this.addNativeListeners).on('change.placeholder focus.placeholder keyup.placeholder mouseup.placeholder keydown.placeholder ' + 'mousedown.placeholder afterSetMode.placeholder changePlace.placeholder ' + 'internalChange.placeholder', this.toggle).on(window, 'load', this.toggle);
39151
+ editor.e.off('.placeholder').on('changePlace.placeholder', this.addNativeListeners).on('change.placeholder focus.placeholder keyup.placeholder mouseup.placeholder keydown.placeholder ' + 'mousedown.placeholder afterSetMode.placeholder changePlace.placeholder ' + 'internalChange.placeholder afterCommand.placeholder', this.toggle).on(window, 'load', this.toggle);
39126
39152
  this.addNativeListeners();
39127
39153
  this.toggle();
39128
39154
  });
@@ -42267,10 +42293,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42267
42293
  /* harmony export */ AceEditor: function() { return /* binding */ AceEditor; }
42268
42294
  /* harmony export */ });
42269
42295
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
42270
- /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
42271
- /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23211);
42272
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65946);
42273
- /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94193);
42296
+ /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635);
42297
+ /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81937);
42298
+ /* harmony import */ var jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(49574);
42299
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
42300
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
42301
+ /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(94193);
42274
42302
  /*!
42275
42303
  * Jodit Editor (https://xdsoft.net/jodit/)
42276
42304
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -42282,7 +42310,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42282
42310
 
42283
42311
 
42284
42312
 
42285
- class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_4__.SourceEditor {
42313
+
42314
+
42315
+ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_6__.SourceEditor {
42286
42316
  aceExists() {
42287
42317
  return this.j.ow.ace !== undefined;
42288
42318
  }
@@ -42340,7 +42370,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42340
42370
  return;
42341
42371
  }
42342
42372
  const fakeMirror = this.j.c.div('jodit-source__mirror-fake');
42343
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(this.container, fakeMirror);
42373
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(this.container, fakeMirror);
42344
42374
  const ace = editor.ow.ace;
42345
42375
  this.instance = ace.edit(fakeMirror);
42346
42376
  if (editor.o.direction === 'rtl') {
@@ -42361,15 +42391,15 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42361
42391
  this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
42362
42392
  this.instance.getSession().setUseWorker(false);
42363
42393
  this.instance.$blockScrolling = Infinity;
42364
- this.instance.on('change', this.toWYSIWYG);
42394
+ this.instance.on('change', this.__onChange);
42365
42395
  this.instance.on('focus', this.proxyOnFocus);
42366
42396
  this.instance.on('mousedown', this.proxyOnMouseDown);
42367
42397
  this.instance.on('blur', this.proxyOnBlur);
42368
- if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_WYSIWYG) {
42398
+ if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_WYSIWYG) {
42369
42399
  this.setValue(this.getValue());
42370
42400
  }
42371
42401
  const onResize = this.j.async.throttle(()=>{
42372
- if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_WYSIWYG) {
42402
+ if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_WYSIWYG) {
42373
42403
  return;
42374
42404
  }
42375
42405
  const hasFocus = this.instance.isFocused();
@@ -42387,7 +42417,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42387
42417
  };
42388
42418
  let loading = false;
42389
42419
  const initAceEditor = ()=>{
42390
- if (editor.isInDestruct || editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_SOURCE && editor.getMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_SPLIT) {
42420
+ if (editor.isInDestruct || editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_SOURCE && editor.getMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_SPLIT) {
42391
42421
  return;
42392
42422
  }
42393
42423
  // ACE (~400 KiB from the CDN) is only needed once the source view
@@ -42396,7 +42426,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42396
42426
  if (!this.aceExists()) {
42397
42427
  if (!loading) {
42398
42428
  loading = true;
42399
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(()=>null);
42429
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(()=>null);
42400
42430
  }
42401
42431
  return;
42402
42432
  }
@@ -42408,7 +42438,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42408
42438
  initAceEditor();
42409
42439
  }
42410
42440
  destruct() {
42411
- this.instance.off('change', this.toWYSIWYG);
42441
+ this.instance.off('change', this.__onChange);
42412
42442
  this.instance.off('focus', this.proxyOnFocus);
42413
42443
  this.instance.off('mousedown', this.proxyOnMouseDown);
42414
42444
  this.instance.destroy();
@@ -42417,13 +42447,29 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42417
42447
  setValue(value) {
42418
42448
  if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
42419
42449
  const html = this.j.e.fire('beautifyHTML', value);
42420
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.isString)(html)) {
42450
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.isString)(html)) {
42421
42451
  value = html;
42422
42452
  }
42423
42453
  }
42424
- this.instance.setValue(value);
42454
+ // ACE reports its own `setValue` as two changes, the removal of the
42455
+ // old text and the insertion of the new one. Fed back into the
42456
+ // editor they became two history entries, `content -> ''` and
42457
+ // `'' -> content`, so the first undo after a switch to the source
42458
+ // view and back emptied the editor. The text came from the editor
42459
+ // in the first place, so there is nothing to send back.
42460
+ this.__settingValue = true;
42461
+ try {
42462
+ this.instance.setValue(value);
42463
+ } finally{
42464
+ this.__settingValue = false;
42465
+ }
42425
42466
  this.instance.clearSelection();
42426
42467
  }
42468
+ __onChange() {
42469
+ if (!this.__settingValue) {
42470
+ this.toWYSIWYG();
42471
+ }
42472
+ }
42427
42473
  getValue() {
42428
42474
  return this.instance.getValue();
42429
42475
  }
@@ -42497,9 +42543,12 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42497
42543
  this.j.e.fire('focus', e);
42498
42544
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "proxyOnMouseDown", (e)=>{
42499
42545
  this.j.e.fire('mousedown', e);
42500
- });
42546
+ }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__settingValue", false);
42501
42547
  }
42502
42548
  }
42549
+ ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
42550
+ jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_3__.autobind
42551
+ ], AceEditor.prototype, "__onChange", null);
42503
42552
 
42504
42553
 
42505
42554
  /***/ }),