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/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.5
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.5";
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
@@ -11152,10 +11158,22 @@ class Selection {
11152
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));
11153
11159
  if (newRange) {
11154
11160
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
11155
- // Here need do unsafe inserting
11156
- // Deny Dom.safeInsertNode(newRange, marker);
11157
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
11158
- 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
+ }
11159
11177
  }
11160
11178
  }
11161
11179
  return marker;
@@ -11485,7 +11503,9 @@ class Selection {
11485
11503
  }
11486
11504
  ].forEach((getChildNode)=>{
11487
11505
  const childNode = getChildNode();
11488
- 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)) {
11489
11509
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(childNode);
11490
11510
  }
11491
11511
  });
@@ -22499,19 +22519,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.history = {
22499
22519
  * Update history stack
22500
22520
  */ updateStack(replace = false) {
22501
22521
  const newValue = this.snapshot.make();
22502
- if (!_snapshot__WEBPACK_IMPORTED_MODULE_6__.Snapshot.equal(newValue, this.startValue)) {
22503
- const newCommand = new _command__WEBPACK_IMPORTED_MODULE_5__.Command(this.startValue, newValue, this, this.updateTick);
22504
- if (replace) {
22505
- const command = this.__stack.current();
22506
- if (command && this.updateTick === command.tick) {
22507
- this.__stack.replace(newCommand);
22508
- }
22509
- } else {
22510
- this.__stack.push(newCommand);
22511
- }
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) {
22512
22529
  this.startValue = newValue;
22513
- this.fireChangeStack();
22530
+ return;
22514
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);
22540
+ }
22541
+ this.startValue = newValue;
22542
+ this.fireChangeStack();
22515
22543
  }
22516
22544
  fireChangeStack() {
22517
22545
  var _this_j_events;
@@ -37372,7 +37400,7 @@ class lineHeight extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
37372
37400
  try {
37373
37401
  if (s.isCollapsed()) {
37374
37402
  const fake = c.fake();
37375
- s.insertNode(fake, false, false);
37403
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeInsertNode(s.range, fake);
37376
37404
  apply(fake);
37377
37405
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(fake);
37378
37406
  } else {
@@ -39410,7 +39438,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
39410
39438
  this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
39411
39439
  }
39412
39440
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
39413
- 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);
39414
39442
  this.addNativeListeners();
39415
39443
  this.toggle();
39416
39444
  });
@@ -42593,10 +42621,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42593
42621
  /* harmony export */ AceEditor: function() { return /* binding */ AceEditor; }
42594
42622
  /* harmony export */ });
42595
42623
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
42596
- /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
42597
- /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(23211);
42598
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65946);
42599
- /* 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);
42600
42630
  /*!
42601
42631
  * Jodit Editor (https://xdsoft.net/jodit/)
42602
42632
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -42608,7 +42638,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
42608
42638
 
42609
42639
 
42610
42640
 
42611
- 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 {
42612
42644
  aceExists() {
42613
42645
  return this.j.ow.ace !== undefined;
42614
42646
  }
@@ -42666,7 +42698,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42666
42698
  return;
42667
42699
  }
42668
42700
  const fakeMirror = this.j.c.div('jodit-source__mirror-fake');
42669
- 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);
42670
42702
  const ace = editor.ow.ace;
42671
42703
  this.instance = ace.edit(fakeMirror);
42672
42704
  if (editor.o.direction === 'rtl') {
@@ -42687,15 +42719,15 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42687
42719
  this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
42688
42720
  this.instance.getSession().setUseWorker(false);
42689
42721
  this.instance.$blockScrolling = Infinity;
42690
- this.instance.on('change', this.toWYSIWYG);
42722
+ this.instance.on('change', this.__onChange);
42691
42723
  this.instance.on('focus', this.proxyOnFocus);
42692
42724
  this.instance.on('mousedown', this.proxyOnMouseDown);
42693
42725
  this.instance.on('blur', this.proxyOnBlur);
42694
- 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) {
42695
42727
  this.setValue(this.getValue());
42696
42728
  }
42697
42729
  const onResize = this.j.async.throttle(()=>{
42698
- 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) {
42699
42731
  return;
42700
42732
  }
42701
42733
  const hasFocus = this.instance.isFocused();
@@ -42713,7 +42745,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42713
42745
  };
42714
42746
  let loading = false;
42715
42747
  const initAceEditor = ()=>{
42716
- 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) {
42717
42749
  return;
42718
42750
  }
42719
42751
  // ACE (~400 KiB from the CDN) is only needed once the source view
@@ -42722,7 +42754,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42722
42754
  if (!this.aceExists()) {
42723
42755
  if (!loading) {
42724
42756
  loading = true;
42725
- (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);
42726
42758
  }
42727
42759
  return;
42728
42760
  }
@@ -42735,7 +42767,7 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42735
42767
  }
42736
42768
  destruct() {
42737
42769
  var _this_j_events, _this_j;
42738
- this.instance.off('change', this.toWYSIWYG);
42770
+ this.instance.off('change', this.__onChange);
42739
42771
  this.instance.off('focus', this.proxyOnFocus);
42740
42772
  this.instance.off('mousedown', this.proxyOnMouseDown);
42741
42773
  this.instance.destroy();
@@ -42744,13 +42776,29 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42744
42776
  setValue(value) {
42745
42777
  if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
42746
42778
  const html = this.j.e.fire('beautifyHTML', value);
42747
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.isString)(html)) {
42779
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.isString)(html)) {
42748
42780
  value = html;
42749
42781
  }
42750
42782
  }
42751
- 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
+ }
42752
42795
  this.instance.clearSelection();
42753
42796
  }
42797
+ __onChange() {
42798
+ if (!this.__settingValue) {
42799
+ this.toWYSIWYG();
42800
+ }
42801
+ }
42754
42802
  getValue() {
42755
42803
  return this.instance.getValue();
42756
42804
  }
@@ -42824,9 +42872,12 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42824
42872
  this.j.e.fire('focus', e);
42825
42873
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "proxyOnMouseDown", (e)=>{
42826
42874
  this.j.e.fire('mousedown', e);
42827
- });
42875
+ }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__settingValue", false);
42828
42876
  }
42829
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);
42830
42881
 
42831
42882
 
42832
42883
  /***/ }),