jodit 4.17.4 → 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 (63) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +5 -5
  4. package/es2015/jodit.js +131 -37
  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 +125 -37
  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 +125 -37
  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 +140 -37
  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.d.ts +5 -0
  52. package/esm/core/selection/selection.js +56 -5
  53. package/esm/modules/history/history.js +20 -12
  54. package/esm/plugins/line-height/line-height.js +1 -1
  55. package/esm/plugins/placeholder/placeholder.js +1 -1
  56. package/esm/plugins/select/select.d.ts +7 -0
  57. package/esm/plugins/select/select.js +19 -1
  58. package/esm/plugins/source/editor/engines/ace.d.ts +2 -0
  59. package/esm/plugins/source/editor/engines/ace.js +35 -3
  60. package/package.json +1 -1
  61. package/types/core/selection/selection.d.ts +5 -0
  62. package/types/plugins/select/select.d.ts +7 -0
  63. package/types/plugins/source/editor/engines/ace.d.ts +2 -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.17.4
4
+ * Version: v4.17.6
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1805,7 +1805,7 @@ __webpack_require__.r(__webpack_exports__);
1805
1805
  * ```
1806
1806
  * @packageDocumentation
1807
1807
  * @module constants
1808
- */ const APP_VERSION = "4.17.4";
1808
+ */ const APP_VERSION = "4.17.6";
1809
1809
  // prettier-ignore
1810
1810
  const ES = "es2015";
1811
1811
  const IS_ES_MODERN = true;
@@ -10901,6 +10901,12 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10901
10901
 
10902
10902
 
10903
10903
 
10904
+ /**
10905
+ * A text node that is empty or holds only invisible caret placeholders.
10906
+ */ function isBlankTextNode(node) {
10907
+ var _node_nodeValue;
10908
+ return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && ((_node_nodeValue = node.nodeValue) !== null && _node_nodeValue !== void 0 ? _node_nodeValue : '').replace(jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE_REG_EXP(), '').length === 0;
10909
+ }
10904
10910
  class Selection {
10905
10911
  /**
10906
10912
  * Short alias for this.jodit
@@ -11013,6 +11019,20 @@ class Selection {
11013
11019
  }
11014
11020
  });
11015
11021
  }
11022
+ /**
11023
+ * How many ranges the browser's own selection holds right now, as opposed
11024
+ * to the composed view that [[sel]] may answer from.
11025
+ */ __nativeRangeCount() {
11026
+ var _ref;
11027
+ var _this_win_getSelection;
11028
+ const { shadowRoot } = this.j.o;
11029
+ if (shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(shadowRoot.getSelection)) {
11030
+ var _ref1;
11031
+ var _shadowRoot_getSelection;
11032
+ return (_ref1 = (_shadowRoot_getSelection = shadowRoot.getSelection()) === null || _shadowRoot_getSelection === void 0 ? void 0 : _shadowRoot_getSelection.rangeCount) !== null && _ref1 !== void 0 ? _ref1 : 0;
11033
+ }
11034
+ return (_ref = (_this_win_getSelection = this.win.getSelection()) === null || _this_win_getSelection === void 0 ? void 0 : _this_win_getSelection.rangeCount) !== null && _ref !== void 0 ? _ref : 0;
11035
+ }
11016
11036
  /**
11017
11037
  * Return first selected range or create new
11018
11038
  */ get range() {
@@ -11138,10 +11158,22 @@ class Selection {
11138
11158
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(marker, this.j.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE));
11139
11159
  if (newRange) {
11140
11160
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
11141
- // Here need do unsafe inserting
11142
- // Deny Dom.safeInsertNode(newRange, marker);
11143
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11144
- newRange.insertNode(marker);
11161
+ var _node_nodeValue;
11162
+ const { startContainer: node, startOffset: offset } = newRange;
11163
+ // At either end of a text node the marker goes beside it. Splitting
11164
+ // the node there would leave the selection's boundary in an empty
11165
+ // text node, and WebKit neither repaints a selection that leaves one
11166
+ // nor moves a selection that follows one when it's removed.
11167
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && offset === 0) {
11168
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.before(node, marker);
11169
+ } else if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && offset === ((_node_nodeValue = node.nodeValue) === null || _node_nodeValue === void 0 ? void 0 : _node_nodeValue.length)) {
11170
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.after(node, marker);
11171
+ } else {
11172
+ // Here need do unsafe inserting
11173
+ // Deny Dom.safeInsertNode(newRange, marker);
11174
+ // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11175
+ newRange.insertNode(marker);
11176
+ }
11145
11177
  }
11146
11178
  }
11147
11179
  return marker;
@@ -11471,7 +11503,9 @@ class Selection {
11471
11503
  }
11472
11504
  ].forEach((getChildNode)=>{
11473
11505
  const childNode = getChildNode();
11474
- if (childNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(childNode)) {
11506
+ // Only a text node left with nothing in it by the split
11507
+ // goes; one holding a space is content (`<b>a</b> |`).
11508
+ if (childNode && isBlankTextNode(childNode)) {
11475
11509
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(childNode);
11476
11510
  }
11477
11511
  });
@@ -11821,6 +11855,16 @@ class Selection {
11821
11855
  if (backward && ranges.length === 1) {
11822
11856
  const range = ranges[0];
11823
11857
  sel.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
11858
+ } else if (ranges.length === 1 && !this.__nativeRangeCount() && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(sel.setBaseAndExtent)) {
11859
+ // `addRange` is specified to ignore a range whose root is not
11860
+ // the document, which is every range inside a shadow tree.
11861
+ // Chrome's `ShadowRoot.getSelection()` takes them anyway, but
11862
+ // Safari has only the window selection, so after
11863
+ // `removeAllRanges` the caret is simply gone: a character was
11864
+ // deleted and nothing was left to type into. `setBaseAndExtent`
11865
+ // does accept nodes inside a shadow tree.
11866
+ const range = ranges[0];
11867
+ sel.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
11824
11868
  }
11825
11869
  }
11826
11870
  /**
@@ -22475,19 +22519,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
22475
22519
  * Update history stack
22476
22520
  */ updateStack(replace = false) {
22477
22521
  const newValue = this.snapshot.make();
22478
- if (!_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22479
- const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22480
- if (replace) {
22481
- const command = this.__stack.current();
22482
- if (command && this.updateTick === command.tick) {
22483
- this.__stack.replace(newCommand);
22484
- }
22485
- } else {
22486
- this.__stack.push(newCommand);
22487
- }
22522
+ if (_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22523
+ return;
22524
+ }
22525
+ // Only the selection moved, for example when the selection markers
22526
+ // went in before a switch to the source view. There is nothing to
22527
+ // undo, but the next change has to start from this selection.
22528
+ if (newValue.html === this.startValue.html) {
22488
22529
  this.startValue = newValue;
22489
- this.fireChangeStack();
22530
+ return;
22531
+ }
22532
+ const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22533
+ if (replace) {
22534
+ const command = this.__stack.current();
22535
+ if (command && this.updateTick === command.tick) {
22536
+ this.__stack.replace(newCommand);
22537
+ }
22538
+ } else {
22539
+ this.__stack.push(newCommand);
22490
22540
  }
22541
+ this.startValue = newValue;
22542
+ this.fireChangeStack();
22491
22543
  }
22492
22544
  fireChangeStack() {
22493
22545
  var _this_j_events;
@@ -37348,7 +37400,7 @@ class lineHeight extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
37348
37400
  try {
37349
37401
  if (s.isCollapsed()) {
37350
37402
  const fake = c.fake();
37351
- s.insertNode(fake, false, false);
37403
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeInsertNode(s.range, fake);
37352
37404
  apply(fake);
37353
37405
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(fake);
37354
37406
  } else {
@@ -39386,7 +39438,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
39386
39438
  this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
39387
39439
  }
39388
39440
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
39389
- 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);
39441
+ 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);
39390
39442
  this.addNativeListeners();
39391
39443
  this.toggle();
39392
39444
  });
@@ -42095,13 +42147,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
42095
42147
  j.e.fire(e.type + 'Editor', target, e);
42096
42148
  }
42097
42149
  }
42150
+ onOutsidePress(e) {
42151
+ this.__pressTarget = e.target;
42152
+ }
42098
42153
  /**
42099
42154
  * @event outsideClick(e) - when user clicked on the outside of editor
42100
42155
  */ onOutsideClick(e) {
42101
- const node = e.target;
42156
+ const node = e.target, pressed = this.__pressTarget;
42157
+ this.__pressTarget = null;
42102
42158
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.up(node, (elm)=>elm === this.j.editor)) {
42103
42159
  return;
42104
42160
  }
42161
+ // Selecting the text of a popup input with the mouse and releasing
42162
+ // the button past the popup's edge is not a click outside of it.
42163
+ if (pressed && jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(pressed, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup)) {
42164
+ return;
42165
+ }
42105
42166
  const box = jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(node, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup);
42106
42167
  if (!box) {
42107
42168
  this.j.e.fire('outsideClick', e);
@@ -42207,12 +42268,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
42207
42268
  'touchstart',
42208
42269
  'mouseup',
42209
42270
  'touchend'
42210
- ]);
42271
+ ]), /**
42272
+ * Where the last press started. Chrome reports a drag that begins in one
42273
+ * element and ends in another as a `click` on their common ancestor, so a
42274
+ * press inside a popup is remembered to tell such a drag from a real click.
42275
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__pressTarget", null);
42211
42276
  }
42212
42277
  }
42213
42278
  ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
42214
42279
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.autobind
42215
42280
  ], select.prototype, "onStartSelection", null);
42281
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
42282
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)([
42283
+ 'ow:mousedown',
42284
+ 'ow:touchstart'
42285
+ ])
42286
+ ], select.prototype, "onOutsidePress", null);
42216
42287
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
42217
42288
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)('ow:click')
42218
42289
  ], select.prototype, "onOutsideClick", null);
@@ -42550,10 +42621,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42550
42621
  /* harmony export */ AceEditor: function() { return /* binding */ AceEditor; }
42551
42622
  /* harmony export */ });
42552
42623
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
42553
- /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
42554
- /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23211);
42555
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65946);
42556
- /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94193);
42624
+ /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635);
42625
+ /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81937);
42626
+ /* harmony import */ var jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(49574);
42627
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
42628
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
42629
+ /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(94193);
42557
42630
  /*!
42558
42631
  * Jodit Editor (https://xdsoft.net/jodit/)
42559
42632
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -42565,7 +42638,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42565
42638
 
42566
42639
 
42567
42640
 
42568
- class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_4__.SourceEditor {
42641
+
42642
+
42643
+ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_6__.SourceEditor {
42569
42644
  aceExists() {
42570
42645
  return this.j.ow.ace !== undefined;
42571
42646
  }
@@ -42623,7 +42698,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42623
42698
  return;
42624
42699
  }
42625
42700
  const fakeMirror = this.j.c.div('jodit-source__mirror-fake');
42626
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(this.container, fakeMirror);
42701
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append(this.container, fakeMirror);
42627
42702
  const ace = editor.ow.ace;
42628
42703
  this.instance = ace.edit(fakeMirror);
42629
42704
  if (editor.o.direction === 'rtl') {
@@ -42644,15 +42719,15 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42644
42719
  this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
42645
42720
  this.instance.getSession().setUseWorker(false);
42646
42721
  this.instance.$blockScrolling = Infinity;
42647
- this.instance.on('change', this.toWYSIWYG);
42722
+ this.instance.on('change', this.__onChange);
42648
42723
  this.instance.on('focus', this.proxyOnFocus);
42649
42724
  this.instance.on('mousedown', this.proxyOnMouseDown);
42650
42725
  this.instance.on('blur', this.proxyOnBlur);
42651
- if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_WYSIWYG) {
42726
+ if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_WYSIWYG) {
42652
42727
  this.setValue(this.getValue());
42653
42728
  }
42654
42729
  const onResize = this.j.async.throttle(()=>{
42655
- if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.MODE_WYSIWYG) {
42730
+ if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MODE_WYSIWYG) {
42656
42731
  return;
42657
42732
  }
42658
42733
  const hasFocus = this.instance.isFocused();
@@ -42670,7 +42745,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42670
42745
  };
42671
42746
  let loading = false;
42672
42747
  const initAceEditor = ()=>{
42673
- 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) {
42748
+ 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) {
42674
42749
  return;
42675
42750
  }
42676
42751
  // ACE (~400 KiB from the CDN) is only needed once the source view
@@ -42679,7 +42754,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42679
42754
  if (!this.aceExists()) {
42680
42755
  if (!loading) {
42681
42756
  loading = true;
42682
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(()=>null);
42757
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(()=>null);
42683
42758
  }
42684
42759
  return;
42685
42760
  }
@@ -42692,7 +42767,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42692
42767
  }
42693
42768
  destruct() {
42694
42769
  var _this_j_events, _this_j;
42695
- this.instance.off('change', this.toWYSIWYG);
42770
+ this.instance.off('change', this.__onChange);
42696
42771
  this.instance.off('focus', this.proxyOnFocus);
42697
42772
  this.instance.off('mousedown', this.proxyOnMouseDown);
42698
42773
  this.instance.destroy();
@@ -42701,13 +42776,29 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42701
42776
  setValue(value) {
42702
42777
  if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
42703
42778
  const html = this.j.e.fire('beautifyHTML', value);
42704
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.isString)(html)) {
42779
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.isString)(html)) {
42705
42780
  value = html;
42706
42781
  }
42707
42782
  }
42708
- this.instance.setValue(value);
42783
+ // ACE reports its own `setValue` as two changes, the removal of the
42784
+ // old text and the insertion of the new one. Fed back into the
42785
+ // editor they became two history entries, `content -> ''` and
42786
+ // `'' -> content`, so the first undo after a switch to the source
42787
+ // view and back emptied the editor. The text came from the editor
42788
+ // in the first place, so there is nothing to send back.
42789
+ this.__settingValue = true;
42790
+ try {
42791
+ this.instance.setValue(value);
42792
+ } finally{
42793
+ this.__settingValue = false;
42794
+ }
42709
42795
  this.instance.clearSelection();
42710
42796
  }
42797
+ __onChange() {
42798
+ if (!this.__settingValue) {
42799
+ this.toWYSIWYG();
42800
+ }
42801
+ }
42711
42802
  getValue() {
42712
42803
  return this.instance.getValue();
42713
42804
  }
@@ -42781,9 +42872,12 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42781
42872
  this.j.e.fire('focus', e);
42782
42873
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "proxyOnMouseDown", (e)=>{
42783
42874
  this.j.e.fire('mousedown', e);
42784
- });
42875
+ }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__settingValue", false);
42785
42876
  }
42786
42877
  }
42878
+ ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
42879
+ jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_3__.autobind
42880
+ ], AceEditor.prototype, "__onChange", null);
42787
42881
 
42788
42882
 
42789
42883
  /***/ }),