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/es5/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
  */
@@ -2129,7 +2129,7 @@ __webpack_require__.r(__webpack_exports__);
2129
2129
  * @packageDocumentation
2130
2130
  * @module constants
2131
2131
  */
2132
- var APP_VERSION = "4.17.5";
2132
+ var APP_VERSION = "4.17.6";
2133
2133
  // prettier-ignore
2134
2134
  var ES = "es5";
2135
2135
  var IS_ES_MODERN = false;
@@ -12309,6 +12309,12 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
12309
12309
 
12310
12310
 
12311
12311
 
12312
+ /**
12313
+ * A text node that is empty or holds only invisible caret placeholders.
12314
+ */ function isBlankTextNode(node) {
12315
+ var _node_nodeValue;
12316
+ return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(node) && ((_node_nodeValue = node.nodeValue) !== null && _node_nodeValue !== void 0 ? _node_nodeValue : '').replace(jodit_core_constants__WEBPACK_IMPORTED_MODULE_8__.INVISIBLE_SPACE_REG_EXP(), '').length === 0;
12317
+ }
12312
12318
  var Selection = /*#__PURE__*/ function() {
12313
12319
  "use strict";
12314
12320
  function Selection(jodit) {
@@ -12641,10 +12647,22 @@ var Selection = /*#__PURE__*/ function() {
12641
12647
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.append(marker, this.j.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_8__.INVISIBLE_SPACE));
12642
12648
  if (newRange) {
12643
12649
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
12644
- // Here need do unsafe inserting
12645
- // Deny Dom.safeInsertNode(newRange, marker);
12646
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
12647
- newRange.insertNode(marker);
12650
+ var _node_nodeValue;
12651
+ var node = newRange.startContainer, offset = newRange.startOffset;
12652
+ // At either end of a text node the marker goes beside it. Splitting
12653
+ // the node there would leave the selection's boundary in an empty
12654
+ // text node, and WebKit neither repaints a selection that leaves one
12655
+ // nor moves a selection that follows one when it's removed.
12656
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(node) && offset === 0) {
12657
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.before(node, marker);
12658
+ } else if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(node) && offset === ((_node_nodeValue = node.nodeValue) === null || _node_nodeValue === void 0 ? void 0 : _node_nodeValue.length)) {
12659
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.after(node, marker);
12660
+ } else {
12661
+ // Here need do unsafe inserting
12662
+ // Deny Dom.safeInsertNode(newRange, marker);
12663
+ // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
12664
+ newRange.insertNode(marker);
12665
+ }
12648
12666
  }
12649
12667
  }
12650
12668
  return marker;
@@ -13061,7 +13079,9 @@ var Selection = /*#__PURE__*/ function() {
13061
13079
  }
13062
13080
  ].forEach(function(getChildNode) {
13063
13081
  var childNode = getChildNode();
13064
- if (childNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isEmptyTextNode(childNode)) {
13082
+ // Only a text node left with nothing in it by the split
13083
+ // goes; one holding a space is content (`<b>a</b> |`).
13084
+ if (childNode && isBlankTextNode(childNode)) {
13065
13085
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.safeRemove(childNode);
13066
13086
  }
13067
13087
  });
@@ -27105,19 +27125,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_10__.Config.prototype.history = {
27105
27125
  */ function updateStack() {
27106
27126
  var replace = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
27107
27127
  var newValue = this.snapshot.make();
27108
- if (!_snapshot__WEBPACK_IMPORTED_MODULE_12__.Snapshot.equal(newValue, this.startValue)) {
27109
- var newCommand = new _command__WEBPACK_IMPORTED_MODULE_11__.Command(this.startValue, newValue, this, this.updateTick);
27110
- if (replace) {
27111
- var command = this.__stack.current();
27112
- if (command && this.updateTick === command.tick) {
27113
- this.__stack.replace(newCommand);
27114
- }
27115
- } else {
27116
- this.__stack.push(newCommand);
27117
- }
27128
+ if (_snapshot__WEBPACK_IMPORTED_MODULE_12__.Snapshot.equal(newValue, this.startValue)) {
27129
+ return;
27130
+ }
27131
+ // Only the selection moved, for example when the selection markers
27132
+ // went in before a switch to the source view. There is nothing to
27133
+ // undo, but the next change has to start from this selection.
27134
+ if (newValue.html === this.startValue.html) {
27118
27135
  this.startValue = newValue;
27119
- this.fireChangeStack();
27136
+ return;
27120
27137
  }
27138
+ var newCommand = new _command__WEBPACK_IMPORTED_MODULE_11__.Command(this.startValue, newValue, this, this.updateTick);
27139
+ if (replace) {
27140
+ var command = this.__stack.current();
27141
+ if (command && this.updateTick === command.tick) {
27142
+ this.__stack.replace(newCommand);
27143
+ }
27144
+ } else {
27145
+ this.__stack.push(newCommand);
27146
+ }
27147
+ this.startValue = newValue;
27148
+ this.fireChangeStack();
27121
27149
  }
27122
27150
  },
27123
27151
  {
@@ -44074,7 +44102,7 @@ var lineHeight = /*#__PURE__*/ function(Plugin) {
44074
44102
  try {
44075
44103
  if (s.isCollapsed()) {
44076
44104
  var fake = c.fake();
44077
- s.insertNode(fake, false, false);
44105
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.safeInsertNode(s.range, fake);
44078
44106
  apply(fake);
44079
44107
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.safeRemove(fake);
44080
44108
  } else {
@@ -46374,7 +46402,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
46374
46402
  _this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_12__.attr)(editor.element, 'placeholder') || '';
46375
46403
  }
46376
46404
  editor.e.fire('placeholder', _this.placeholderElm.innerHTML);
46377
- 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);
46405
+ 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);
46378
46406
  _this.addNativeListeners();
46379
46407
  _this.toggle();
46380
46408
  });
@@ -50396,10 +50424,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
50396
50424
  /* harmony import */ var _swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(53429);
50397
50425
  /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(25045);
50398
50426
  /* harmony import */ var _swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(34918);
50399
- /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(81937);
50400
- /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23211);
50401
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(65946);
50402
- /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(94193);
50427
+ /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(31635);
50428
+ /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(81937);
50429
+ /* harmony import */ var jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(49574);
50430
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(23211);
50431
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(65946);
50432
+ /* harmony import */ var jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(94193);
50403
50433
  /*!
50404
50434
  * Jodit Editor (https://xdsoft.net/jodit/)
50405
50435
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -50415,6 +50445,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.source = {
50415
50445
 
50416
50446
 
50417
50447
 
50448
+
50449
+
50418
50450
  var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50419
50451
  "use strict";
50420
50452
  (0,_swc_helpers_inherits__WEBPACK_IMPORTED_MODULE_4__._)(AceEditor, SourceEditor);
@@ -50429,7 +50461,7 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50429
50461
  _this.j.e.fire('focus', e);
50430
50462
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "proxyOnMouseDown", function(e) {
50431
50463
  _this.j.e.fire('mousedown', e);
50432
- });
50464
+ }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_3__._)(_this, "__settingValue", false);
50433
50465
  return _this;
50434
50466
  }
50435
50467
  ;(0,_swc_helpers_create_class__WEBPACK_IMPORTED_MODULE_2__._)(AceEditor, [
@@ -50511,7 +50543,7 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50511
50543
  return;
50512
50544
  }
50513
50545
  var fakeMirror = _this.j.c.div('jodit-source__mirror-fake');
50514
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_6__.Dom.append(_this.container, fakeMirror);
50546
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.append(_this.container, fakeMirror);
50515
50547
  var ace = editor.ow.ace;
50516
50548
  _this.instance = ace.edit(fakeMirror);
50517
50549
  if (editor.o.direction === 'rtl') {
@@ -50532,15 +50564,15 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50532
50564
  _this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
50533
50565
  _this.instance.getSession().setUseWorker(false);
50534
50566
  _this.instance.$blockScrolling = Infinity;
50535
- _this.instance.on('change', _this.toWYSIWYG);
50567
+ _this.instance.on('change', _this.__onChange);
50536
50568
  _this.instance.on('focus', _this.proxyOnFocus);
50537
50569
  _this.instance.on('mousedown', _this.proxyOnMouseDown);
50538
50570
  _this.instance.on('blur', _this.proxyOnBlur);
50539
- if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_5__.MODE_WYSIWYG) {
50571
+ if (editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_6__.MODE_WYSIWYG) {
50540
50572
  _this.setValue(_this.getValue());
50541
50573
  }
50542
50574
  var onResize = _this.j.async.throttle(function() {
50543
- if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_5__.MODE_WYSIWYG) {
50575
+ if (editor.isInDestruct || editor.getMode() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_6__.MODE_WYSIWYG) {
50544
50576
  return;
50545
50577
  }
50546
50578
  var hasFocus = _this.instance.isFocused();
@@ -50558,7 +50590,7 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50558
50590
  };
50559
50591
  var loading = false;
50560
50592
  var initAceEditor = function initAceEditor1() {
50561
- if (editor.isInDestruct || editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_5__.MODE_SOURCE && editor.getMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_5__.MODE_SPLIT) {
50593
+ if (editor.isInDestruct || editor.getRealMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_6__.MODE_SOURCE && editor.getMode() !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_6__.MODE_SPLIT) {
50562
50594
  return;
50563
50595
  }
50564
50596
  // ACE (~400 KiB from the CDN) is only needed once the source view
@@ -50567,7 +50599,7 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50567
50599
  if (!_this.aceExists()) {
50568
50600
  if (!loading) {
50569
50601
  loading = true;
50570
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_7__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(function() {
50602
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_9__.loadNext)(editor, editor.o.sourceEditorCDNUrlsJS).then(initAceEditor).catch(function() {
50571
50603
  return null;
50572
50604
  });
50573
50605
  }
@@ -50585,7 +50617,7 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50585
50617
  key: "destruct",
50586
50618
  value: function destruct() {
50587
50619
  var _this_j_events, _this_j;
50588
- this.instance.off('change', this.toWYSIWYG);
50620
+ this.instance.off('change', this.__onChange);
50589
50621
  this.instance.off('focus', this.proxyOnFocus);
50590
50622
  this.instance.off('mousedown', this.proxyOnMouseDown);
50591
50623
  this.instance.destroy();
@@ -50597,14 +50629,33 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50597
50629
  value: function setValue(value) {
50598
50630
  if (!this.j.o.editHTMLDocumentMode && this.j.o.beautifyHTML) {
50599
50631
  var html = this.j.e.fire('beautifyHTML', value);
50600
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_7__.isString)(html)) {
50632
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_9__.isString)(html)) {
50601
50633
  value = html;
50602
50634
  }
50603
50635
  }
50604
- this.instance.setValue(value);
50636
+ // ACE reports its own `setValue` as two changes, the removal of the
50637
+ // old text and the insertion of the new one. Fed back into the
50638
+ // editor they became two history entries, `content -> ''` and
50639
+ // `'' -> content`, so the first undo after a switch to the source
50640
+ // view and back emptied the editor. The text came from the editor
50641
+ // in the first place, so there is nothing to send back.
50642
+ this.__settingValue = true;
50643
+ try {
50644
+ this.instance.setValue(value);
50645
+ } finally{
50646
+ this.__settingValue = false;
50647
+ }
50605
50648
  this.instance.clearSelection();
50606
50649
  }
50607
50650
  },
50651
+ {
50652
+ key: "__onChange",
50653
+ value: function __onChange() {
50654
+ if (!this.__settingValue) {
50655
+ this.toWYSIWYG();
50656
+ }
50657
+ }
50658
+ },
50608
50659
  {
50609
50660
  key: "getValue",
50610
50661
  value: function getValue() {
@@ -50707,7 +50758,10 @@ var AceEditor = /*#__PURE__*/ function(SourceEditor) {
50707
50758
  }
50708
50759
  ]);
50709
50760
  return AceEditor;
50710
- }(jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_8__.SourceEditor);
50761
+ }(jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORTED_MODULE_10__.SourceEditor);
50762
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_5__.__decorate)([
50763
+ jodit_core_decorators_autobind_autobind__WEBPACK_IMPORTED_MODULE_7__.autobind
50764
+ ], AceEditor.prototype, "__onChange", null);
50711
50765
 
50712
50766
 
50713
50767
  /***/ }),
package/es5/jodit.min.css CHANGED
@@ -1,14 +1,14 @@
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
  */
8
8
  /*!
9
9
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
10
10
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
11
- * Version: v4.17.5
11
+ * Version: v4.17.6
12
12
  * Url: https://xdsoft.net/jodit/
13
13
  * License(s): MIT
14
14
  */