jodit 4.20.2 → 4.20.3

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 (61) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +6 -6
  4. package/es2015/jodit.js +90 -21
  5. package/es2015/jodit.min.js +6 -6
  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 +6 -6
  13. package/es2018/jodit.min.js +6 -6
  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 +6 -6
  18. package/es2021/jodit.js +87 -21
  19. package/es2021/jodit.min.js +6 -6
  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 +6 -6
  28. package/es2021.en/jodit.js +87 -21
  29. package/es2021.en/jodit.min.js +6 -6
  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 +98 -21
  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/modules/file-browser/builders/context-menu.js +6 -2
  52. package/esm/modules/toolbar/factory.js +3 -1
  53. package/esm/plugins/backspace/cases/check-not-collapsed.js +1 -1
  54. package/esm/plugins/delete/delete.d.ts +12 -0
  55. package/esm/plugins/delete/delete.js +66 -4
  56. package/esm/plugins/delete/interface.d.ts +4 -2
  57. package/esm/plugins/dtd/after-insert/remove-extra-br.js +7 -1
  58. package/esm/plugins/placeholder/placeholder.js +3 -1
  59. package/package.json +1 -1
  60. package/types/plugins/delete/delete.d.ts +12 -0
  61. package/types/plugins/delete/interface.d.ts +4 -2
@@ -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.20.2
4
+ * Version: v4.20.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1824,7 +1824,7 @@ __webpack_require__.r(__webpack_exports__);
1824
1824
  * ```
1825
1825
  * @packageDocumentation
1826
1826
  * @module constants
1827
- */ const APP_VERSION = "4.20.2";
1827
+ */ const APP_VERSION = "4.20.3";
1828
1828
  // prettier-ignore
1829
1829
  const ES = "es2021";
1830
1830
  const IS_ES_MODERN = true;
@@ -21511,11 +21511,12 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21511
21511
  }), temp_content = self.c.div(CLASS_PREVIEW, '<div class="jodit-icon_loader"></div>'), preview_box = self.c.div(CLASS_PREVIEW + '__box'), next = self.c.fromHTML(preview_tpl_next()), prev = self.c.fromHTML(preview_tpl_next('prev', 'left')), addLoadHandler = (src)=>{
21512
21512
  const image = self.c.element('img');
21513
21513
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'src', src);
21514
+ (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'alt', ga('data-name'));
21514
21515
  const onload = ()=>{
21515
21516
  if (self.isInDestruct) {
21516
21517
  return;
21517
21518
  }
21518
- self.e.off(image, 'load');
21519
+ self.e.off(image, 'load error');
21519
21520
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.detach(temp_content);
21520
21521
  if (opt.showPreviewNavigation) {
21521
21522
  if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.prevWithClass(item, self.files.getFullElName('item'))) {
@@ -21530,7 +21531,10 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21530
21531
  preview.setPosition();
21531
21532
  self?.events?.fire('previewOpenedAndLoaded');
21532
21533
  };
21533
- self.e.on(image, 'load', onload);
21534
+ // An image that can't load is shown too,
21535
+ // broken with the file's name, rather
21536
+ // than the loader for good
21537
+ self.e.on(image, 'load error', onload);
21534
21538
  if (image.complete) {
21535
21539
  onload();
21536
21540
  }
@@ -27139,7 +27143,9 @@ ToolbarEditorCollection = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1
27139
27143
  }
27140
27144
  function makeSelect(view, control, target = null) {
27141
27145
  const ToolbarSelect = (0,jodit_core_decorators_component_component__WEBPACK_IMPORTED_MODULE_0__.getComponentClass)('ToolbarSelect');
27142
- return new ToolbarSelect(view, control, target);
27146
+ const select = new ToolbarSelect(view, control, target);
27147
+ select.state.tabIndex = view.o.allowTabNavigation ? 0 : -1;
27148
+ return select;
27143
27149
  }
27144
27150
 
27145
27151
 
@@ -30461,7 +30467,7 @@ function moveContentAndRemoveEmpty(jodit, mainClosestBox, sibling, backspace) {
30461
30467
  * @private
30462
30468
  */ function checkNotCollapsed(jodit) {
30463
30469
  if (!jodit.s.isCollapsed()) {
30464
- jodit.execCommand('Delete');
30470
+ jodit.execCommand('delete', false, true);
30465
30471
  return true;
30466
30472
  }
30467
30473
  return false;
@@ -33577,6 +33583,13 @@ const KEEPS_SPACES = new Set([
33577
33583
  'pre-wrap',
33578
33584
  'break-spaces'
33579
33585
  ]);
33586
+ /**
33587
+ * Formatting that the next letter keeps once all of the text in it is
33588
+ * deleted with a key: a formatting tag, or a span with styles of its own.
33589
+ * Not a link, which new text isn't added to, or a wrapper such as a video's
33590
+ */ function keepsFormat(node) {
33591
+ return jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isHTMLElement(node) && !node.hasAttribute('contenteditable') && !jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTemporary(node) && (/^(STRONG|B|EM|I|U|S|SUB|SUP)$/.test(node.nodeName) || jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(node, 'span') && node.hasAttribute('style'));
33592
+ }
33580
33593
  /**
33581
33594
  * A plain space beside this neighbor isn't shown: there is none, or it's a
33582
33595
  * line break, a block or text starting (or ending) with a plain space
@@ -33624,7 +33637,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33624
33637
  jodit.s.removeNode(node);
33625
33638
  }
33626
33639
  }
33627
- __onDeleteCommand() {
33640
+ __onDeleteCommand(command, showUI, keepFormat) {
33628
33641
  const { jodit } = this;
33629
33642
  if (jodit.s.isCollapsed()) {
33630
33643
  return;
@@ -33632,6 +33645,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33632
33645
  jodit.s.expandSelection();
33633
33646
  const range = jodit.s.range;
33634
33647
  this.__moveEdgesIntoCells(range);
33648
+ const format = keepFormat === true ? this.__formatTakenWhole(range) : [];
33635
33649
  const caret = this.__clearSelectedCells(range);
33636
33650
  if (caret && range.collapsed) {
33637
33651
  jodit.s.selectRange(caret);
@@ -33647,8 +33661,12 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33647
33661
  this.__keepSpacesVisibleBesideTable(fake);
33648
33662
  range.setStartBefore(fake);
33649
33663
  range.collapse(true);
33650
- this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
33651
- this.__addBrInEmptyBlock(fake, range);
33664
+ if (format.length && !caret) {
33665
+ this.__keepFormat(format, fake, range);
33666
+ } else {
33667
+ this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
33668
+ this.__addBrInEmptyBlock(fake, range);
33669
+ }
33652
33670
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.safeRemove(fake);
33653
33671
  jodit.s.selectRange(caret ?? range);
33654
33672
  return false;
@@ -33669,6 +33687,45 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33669
33687
  range.setEnd(last, last.childNodes.length);
33670
33688
  }
33671
33689
  }
33690
+ /**
33691
+ * The formatting elements the deletion takes whole from its start,
33692
+ * outermost first: `<strong>` and `<em>` for all of the text in
33693
+ * `<strong><em>cd</em></strong>`
33694
+ */ __formatTakenWhole(range) {
33695
+ const format = [];
33696
+ const whole = this.jodit.s.createRange();
33697
+ const { startContainer, startOffset } = range;
33698
+ let node = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isText(startContainer) ? null : startContainer.childNodes[startOffset];
33699
+ // Through a block taken whole, as a line holding only the word is
33700
+ while(jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isHTMLElement(node)){
33701
+ whole.selectNode(node);
33702
+ if (range.compareBoundaryPoints(Range.END_TO_END, whole) < 0) {
33703
+ break;
33704
+ }
33705
+ if (keepsFormat(node)) {
33706
+ format.push(node);
33707
+ } else if (format.length || !jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isBlock(node)) {
33708
+ break;
33709
+ }
33710
+ node = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.toArray)(node.childNodes).find((child)=>!jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isText(child) || (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.trimInv)(child.nodeValue ?? ''));
33711
+ }
33712
+ return format;
33713
+ }
33714
+ /**
33715
+ * As the browsers do, the next letter typed keeps the formatting that was
33716
+ * deleted whole: empty copies go where it was, round an invisible space,
33717
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
33718
+ */ __keepFormat(format, fake, range) {
33719
+ const copies = format.map((element)=>element.cloneNode(false));
33720
+ for(let i = 1; i < copies.length; i += 1){
33721
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[i - 1], copies[i]);
33722
+ }
33723
+ const text = this.jodit.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.INVISIBLE_SPACE);
33724
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[copies.length - 1], text);
33725
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.before(fake, copies[0]);
33726
+ range.setStartAfter(text);
33727
+ range.collapse(true);
33728
+ }
33672
33729
  /**
33673
33730
  * A selection that starts or ends in a table cell clears the selected part
33674
33731
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -34411,7 +34468,13 @@ const brBoxes = new Set([
34411
34468
  // text; moving it before the `<br>` would put it on a line of its own
34412
34469
  // below the block (#1315)
34413
34470
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isOrContains(node, jodit.s.range.startContainer)) {
34414
- jodit.s.setCursorBefore(br);
34471
+ // Not with setCursorBefore: the text node it adds for the caret
34472
+ // stays after the inserted element once the `<br>` has gone, and
34473
+ // Right or End then take the caret into it, out of the element
34474
+ const range = jodit.s.createRange();
34475
+ range.setStartBefore(br);
34476
+ range.collapse(true);
34477
+ jodit.s.selectRange(range);
34415
34478
  }
34416
34479
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(br);
34417
34480
  }
@@ -43997,10 +44060,11 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
43997
44060
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
43998
44061
  /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28077);
43999
44062
  /* harmony import */ var jodit_core_helpers_checker_is_marker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23175);
44000
- /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7909);
44001
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(80991);
44002
- /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(18855);
44003
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8257);
44063
+ /* harmony import */ var jodit_core_helpers_utils_anchor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(85371);
44064
+ /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7909);
44065
+ /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(80991);
44066
+ /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(18855);
44067
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8257);
44004
44068
  /*!
44005
44069
  * Jodit Editor (https://xdsoft.net/jodit/)
44006
44070
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -44022,6 +44086,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
44022
44086
 
44023
44087
 
44024
44088
 
44089
+
44025
44090
  /**
44026
44091
  * Check if root node is empty
44027
44092
  * @private
@@ -44046,18 +44111,19 @@ function isBlank(root) {
44046
44111
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(first) && !next) {
44047
44112
  return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(first);
44048
44113
  }
44049
- return !next && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.each(first, (elm)=>!(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isLeaf(elm) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isList(elm)) && (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmpty(elm) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTag(elm, 'br')));
44114
+ // An anchor has no text, but it's content, shown as a marker
44115
+ return !next && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.each(first, (elm)=>!(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isLeaf(elm) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isList(elm) || (0,jodit_core_helpers_utils_anchor__WEBPACK_IMPORTED_MODULE_7__.isAnchor)(elm)) && (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmpty(elm) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTag(elm, 'br')));
44050
44116
  }
44051
44117
  /**
44052
44118
  * Show placeholder inside empty editor
44053
- */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__.Plugin {
44119
+ */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__.Plugin {
44054
44120
  afterInit(editor) {
44055
44121
  if (!editor.o.showPlaceholder) {
44056
44122
  return;
44057
44123
  }
44058
44124
  this.placeholderElm = editor.c.fromHTML(`<span data-ref="placeholder" style="display: none;" class="jodit-placeholder">${editor.i18n(editor.o.placeholder)}</span>`);
44059
44125
  if (editor.o.direction === 'rtl') {
44060
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44126
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44061
44127
  right: 0,
44062
44128
  direction: 'rtl'
44063
44129
  });
@@ -44086,19 +44152,19 @@ function isBlank(root) {
44086
44152
  const style2 = editor.ew.getComputedStyle(firstChild);
44087
44153
  marginTop = parseInt(style2.getPropertyValue('margin-top'), 10);
44088
44154
  marginLeft = parseInt(style2.getPropertyValue('margin-left'), 10);
44089
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44155
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44090
44156
  fontFamily: style2.getPropertyValue('font-family'),
44091
44157
  fontSize: parseInt(style2.getPropertyValue('font-size'), 10),
44092
44158
  lineHeight: style2.getPropertyValue('line-height')
44093
44159
  });
44094
44160
  } else {
44095
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44161
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44096
44162
  fontFamily: style.getPropertyValue('font-family'),
44097
44163
  fontSize: parseInt(style.getPropertyValue('font-size'), 10),
44098
44164
  lineHeight: style.getPropertyValue('line-height')
44099
44165
  });
44100
44166
  }
44101
- ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44167
+ ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44102
44168
  display: 'block',
44103
44169
  textAlign: style.getPropertyValue('text-align'),
44104
44170
  paddingTop: parseInt(styleEditor.paddingTop, 10) + 'px',
@@ -44136,7 +44202,7 @@ function isBlank(root) {
44136
44202
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "addEvents", ()=>{
44137
44203
  const editor = this.j;
44138
44204
  if (editor.o.useInputsPlaceholder && editor.element.hasAttribute('placeholder')) {
44139
- this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
44205
+ this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__.attr)(editor.element, 'placeholder') || '';
44140
44206
  }
44141
44207
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
44142
44208
  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 resize.placeholder', this.toggle).on(window, 'load', this.toggle);