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/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.4
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.4";
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
@@ -10957,6 +10962,16 @@ class Selection {
10957
10962
  }
10958
10963
  });
10959
10964
  }
10965
+ /**
10966
+ * How many ranges the browser's own selection holds right now, as opposed
10967
+ * to the composed view that [[sel]] may answer from.
10968
+ */ __nativeRangeCount() {
10969
+ const { shadowRoot } = this.j.o;
10970
+ if (shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(shadowRoot.getSelection)) {
10971
+ return shadowRoot.getSelection()?.rangeCount ?? 0;
10972
+ }
10973
+ return this.win.getSelection()?.rangeCount ?? 0;
10974
+ }
10960
10975
  /**
10961
10976
  * Return first selected range or create new
10962
10977
  */ get range() {
@@ -11079,10 +11094,21 @@ class Selection {
11079
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));
11080
11095
  if (newRange) {
11081
11096
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
11082
- // Here need do unsafe inserting
11083
- // Deny Dom.safeInsertNode(newRange, marker);
11084
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11085
- 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
+ }
11086
11112
  }
11087
11113
  }
11088
11114
  return marker;
@@ -11404,7 +11430,9 @@ class Selection {
11404
11430
  ()=>firstChild?.previousSibling?.lastChild
11405
11431
  ].forEach((getChildNode)=>{
11406
11432
  const childNode = getChildNode();
11407
- 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)) {
11408
11436
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(childNode);
11409
11437
  }
11410
11438
  });
@@ -11751,6 +11779,16 @@ class Selection {
11751
11779
  if (backward && ranges.length === 1) {
11752
11780
  const range = ranges[0];
11753
11781
  sel.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
11782
+ } else if (ranges.length === 1 && !this.__nativeRangeCount() && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(sel.setBaseAndExtent)) {
11783
+ // `addRange` is specified to ignore a range whose root is not
11784
+ // the document, which is every range inside a shadow tree.
11785
+ // Chrome's `ShadowRoot.getSelection()` takes them anyway, but
11786
+ // Safari has only the window selection, so after
11787
+ // `removeAllRanges` the caret is simply gone: a character was
11788
+ // deleted and nothing was left to type into. `setBaseAndExtent`
11789
+ // does accept nodes inside a shadow tree.
11790
+ const range = ranges[0];
11791
+ sel.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
11754
11792
  }
11755
11793
  }
11756
11794
  /**
@@ -22298,19 +22336,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
22298
22336
  * Update history stack
22299
22337
  */ updateStack(replace = false) {
22300
22338
  const newValue = this.snapshot.make();
22301
- if (!_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22302
- const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22303
- if (replace) {
22304
- const command = this.__stack.current();
22305
- if (command && this.updateTick === command.tick) {
22306
- this.__stack.replace(newCommand);
22307
- }
22308
- } else {
22309
- this.__stack.push(newCommand);
22310
- }
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) {
22311
22346
  this.startValue = newValue;
22312
- this.fireChangeStack();
22347
+ return;
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);
22313
22357
  }
22358
+ this.startValue = newValue;
22359
+ this.fireChangeStack();
22314
22360
  }
22315
22361
  fireChangeStack() {
22316
22362
  this.j && !this.j.isInDestruct && this.j.events?.fire('changeStack');
@@ -37079,7 +37125,7 @@ class lineHeight extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
37079
37125
  try {
37080
37126
  if (s.isCollapsed()) {
37081
37127
  const fake = c.fake();
37082
- s.insertNode(fake, false, false);
37128
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeInsertNode(s.range, fake);
37083
37129
  apply(fake);
37084
37130
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(fake);
37085
37131
  } else {
@@ -39102,7 +39148,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
39102
39148
  this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
39103
39149
  }
39104
39150
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
39105
- 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);
39106
39152
  this.addNativeListeners();
39107
39153
  this.toggle();
39108
39154
  });
@@ -41776,13 +41822,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
41776
41822
  j.e.fire(e.type + 'Editor', target, e);
41777
41823
  }
41778
41824
  }
41825
+ onOutsidePress(e) {
41826
+ this.__pressTarget = e.target;
41827
+ }
41779
41828
  /**
41780
41829
  * @event outsideClick(e) - when user clicked on the outside of editor
41781
41830
  */ onOutsideClick(e) {
41782
- const node = e.target;
41831
+ const node = e.target, pressed = this.__pressTarget;
41832
+ this.__pressTarget = null;
41783
41833
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.up(node, (elm)=>elm === this.j.editor)) {
41784
41834
  return;
41785
41835
  }
41836
+ // Selecting the text of a popup input with the mouse and releasing
41837
+ // the button past the popup's edge is not a click outside of it.
41838
+ if (pressed && jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(pressed, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup)) {
41839
+ return;
41840
+ }
41786
41841
  const box = jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(node, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup);
41787
41842
  if (!box) {
41788
41843
  this.j.e.fire('outsideClick', e);
@@ -41886,12 +41941,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
41886
41941
  'touchstart',
41887
41942
  'mouseup',
41888
41943
  'touchend'
41889
- ]);
41944
+ ]), /**
41945
+ * Where the last press started. Chrome reports a drag that begins in one
41946
+ * element and ends in another as a `click` on their common ancestor, so a
41947
+ * press inside a popup is remembered to tell such a drag from a real click.
41948
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__pressTarget", null);
41890
41949
  }
41891
41950
  }
41892
41951
  ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41893
41952
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.autobind
41894
41953
  ], select.prototype, "onStartSelection", null);
41954
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41955
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)([
41956
+ 'ow:mousedown',
41957
+ 'ow:touchstart'
41958
+ ])
41959
+ ], select.prototype, "onOutsidePress", null);
41895
41960
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41896
41961
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)('ow:click')
41897
41962
  ], select.prototype, "onOutsideClick", null);
@@ -42228,10 +42293,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42228
42293
  /* harmony export */ AceEditor: function() { return /* binding */ AceEditor; }
42229
42294
  /* harmony export */ });
42230
42295
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
42231
- /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
42232
- /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23211);
42233
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65946);
42234
- /* 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);
42235
42302
  /*!
42236
42303
  * Jodit Editor (https://xdsoft.net/jodit/)
42237
42304
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -42243,7 +42310,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42243
42310
 
42244
42311
 
42245
42312
 
42246
- 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 {
42247
42316
  aceExists() {
42248
42317
  return this.j.ow.ace !== undefined;
42249
42318
  }
@@ -42301,7 +42370,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42301
42370
  return;
42302
42371
  }
42303
42372
  const fakeMirror = this.j.c.div('jodit-source__mirror-fake');
42304
- 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);
42305
42374
  const ace = editor.ow.ace;
42306
42375
  this.instance = ace.edit(fakeMirror);
42307
42376
  if (editor.o.direction === 'rtl') {
@@ -42322,15 +42391,15 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42322
42391
  this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
42323
42392
  this.instance.getSession().setUseWorker(false);
42324
42393
  this.instance.$blockScrolling = Infinity;
42325
- this.instance.on('change', this.toWYSIWYG);
42394
+ this.instance.on('change', this.__onChange);
42326
42395
  this.instance.on('focus', this.proxyOnFocus);
42327
42396
  this.instance.on('mousedown', this.proxyOnMouseDown);
42328
42397
  this.instance.on('blur', this.proxyOnBlur);
42329
- 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) {
42330
42399
  this.setValue(this.getValue());
42331
42400
  }
42332
42401
  const onResize = this.j.async.throttle(()=>{
42333
- 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) {
42334
42403
  return;
42335
42404
  }
42336
42405
  const hasFocus = this.instance.isFocused();
@@ -42348,7 +42417,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42348
42417
  };
42349
42418
  let loading = false;
42350
42419
  const initAceEditor = ()=>{
42351
- 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) {
42352
42421
  return;
42353
42422
  }
42354
42423
  // ACE (~400 KiB from the CDN) is only needed once the source view
@@ -42357,7 +42426,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42357
42426
  if (!this.aceExists()) {
42358
42427
  if (!loading) {
42359
42428
  loading = true;
42360
- (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);
42361
42430
  }
42362
42431
  return;
42363
42432
  }
@@ -42369,7 +42438,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42369
42438
  initAceEditor();
42370
42439
  }
42371
42440
  destruct() {
42372
- this.instance.off('change', this.toWYSIWYG);
42441
+ this.instance.off('change', this.__onChange);
42373
42442
  this.instance.off('focus', this.proxyOnFocus);
42374
42443
  this.instance.off('mousedown', this.proxyOnMouseDown);
42375
42444
  this.instance.destroy();
@@ -42378,13 +42447,29 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42378
42447
  setValue(value) {
42379
42448
  if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
42380
42449
  const html = this.j.e.fire('beautifyHTML', value);
42381
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.isString)(html)) {
42450
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.isString)(html)) {
42382
42451
  value = html;
42383
42452
  }
42384
42453
  }
42385
- 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
+ }
42386
42466
  this.instance.clearSelection();
42387
42467
  }
42468
+ __onChange() {
42469
+ if (!this.__settingValue) {
42470
+ this.toWYSIWYG();
42471
+ }
42472
+ }
42388
42473
  getValue() {
42389
42474
  return this.instance.getValue();
42390
42475
  }
@@ -42458,9 +42543,12 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42458
42543
  this.j.e.fire('focus', e);
42459
42544
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "proxyOnMouseDown", (e)=>{
42460
42545
  this.j.e.fire('mousedown', e);
42461
- });
42546
+ }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__settingValue", false);
42462
42547
  }
42463
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);
42464
42552
 
42465
42553
 
42466
42554
  /***/ }),