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
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.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;
@@ -21535,11 +21535,12 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21535
21535
  }), 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)=>{
21536
21536
  const image = self.c.element('img');
21537
21537
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'src', src);
21538
+ (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'alt', ga('data-name'));
21538
21539
  const onload = ()=>{
21539
21540
  if (self.isInDestruct) {
21540
21541
  return;
21541
21542
  }
21542
- self.e.off(image, 'load');
21543
+ self.e.off(image, 'load error');
21543
21544
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.detach(temp_content);
21544
21545
  if (opt.showPreviewNavigation) {
21545
21546
  if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.prevWithClass(item, self.files.getFullElName('item'))) {
@@ -21554,7 +21555,10 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21554
21555
  preview.setPosition();
21555
21556
  self?.events?.fire('previewOpenedAndLoaded');
21556
21557
  };
21557
- self.e.on(image, 'load', onload);
21558
+ // An image that can't load is shown too,
21559
+ // broken with the file's name, rather
21560
+ // than the loader for good
21561
+ self.e.on(image, 'load error', onload);
21558
21562
  if (image.complete) {
21559
21563
  onload();
21560
21564
  }
@@ -27163,7 +27167,9 @@ ToolbarEditorCollection = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1
27163
27167
  }
27164
27168
  function makeSelect(view, control, target = null) {
27165
27169
  const ToolbarSelect = (0,jodit_core_decorators_component_component__WEBPACK_IMPORTED_MODULE_0__.getComponentClass)('ToolbarSelect');
27166
- return new ToolbarSelect(view, control, target);
27170
+ const select = new ToolbarSelect(view, control, target);
27171
+ select.state.tabIndex = view.o.allowTabNavigation ? 0 : -1;
27172
+ return select;
27167
27173
  }
27168
27174
 
27169
27175
 
@@ -30535,7 +30541,7 @@ function moveContentAndRemoveEmpty(jodit, mainClosestBox, sibling, backspace) {
30535
30541
  * @private
30536
30542
  */ function checkNotCollapsed(jodit) {
30537
30543
  if (!jodit.s.isCollapsed()) {
30538
- jodit.execCommand('Delete');
30544
+ jodit.execCommand('delete', false, true);
30539
30545
  return true;
30540
30546
  }
30541
30547
  return false;
@@ -33964,6 +33970,13 @@ const KEEPS_SPACES = new Set([
33964
33970
  'pre-wrap',
33965
33971
  'break-spaces'
33966
33972
  ]);
33973
+ /**
33974
+ * Formatting that the next letter keeps once all of the text in it is
33975
+ * deleted with a key: a formatting tag, or a span with styles of its own.
33976
+ * Not a link, which new text isn't added to, or a wrapper such as a video's
33977
+ */ function keepsFormat(node) {
33978
+ 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'));
33979
+ }
33967
33980
  /**
33968
33981
  * A plain space beside this neighbor isn't shown: there is none, or it's a
33969
33982
  * line break, a block or text starting (or ending) with a plain space
@@ -34011,7 +34024,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34011
34024
  jodit.s.removeNode(node);
34012
34025
  }
34013
34026
  }
34014
- __onDeleteCommand() {
34027
+ __onDeleteCommand(command, showUI, keepFormat) {
34015
34028
  const { jodit } = this;
34016
34029
  if (jodit.s.isCollapsed()) {
34017
34030
  return;
@@ -34019,6 +34032,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34019
34032
  jodit.s.expandSelection();
34020
34033
  const range = jodit.s.range;
34021
34034
  this.__moveEdgesIntoCells(range);
34035
+ const format = keepFormat === true ? this.__formatTakenWhole(range) : [];
34022
34036
  const caret = this.__clearSelectedCells(range);
34023
34037
  if (caret && range.collapsed) {
34024
34038
  jodit.s.selectRange(caret);
@@ -34034,8 +34048,12 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34034
34048
  this.__keepSpacesVisibleBesideTable(fake);
34035
34049
  range.setStartBefore(fake);
34036
34050
  range.collapse(true);
34037
- this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
34038
- this.__addBrInEmptyBlock(fake, range);
34051
+ if (format.length && !caret) {
34052
+ this.__keepFormat(format, fake, range);
34053
+ } else {
34054
+ this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
34055
+ this.__addBrInEmptyBlock(fake, range);
34056
+ }
34039
34057
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.safeRemove(fake);
34040
34058
  jodit.s.selectRange(caret ?? range);
34041
34059
  return false;
@@ -34056,6 +34074,45 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34056
34074
  range.setEnd(last, last.childNodes.length);
34057
34075
  }
34058
34076
  }
34077
+ /**
34078
+ * The formatting elements the deletion takes whole from its start,
34079
+ * outermost first: `<strong>` and `<em>` for all of the text in
34080
+ * `<strong><em>cd</em></strong>`
34081
+ */ __formatTakenWhole(range) {
34082
+ const format = [];
34083
+ const whole = this.jodit.s.createRange();
34084
+ const { startContainer, startOffset } = range;
34085
+ let node = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isText(startContainer) ? null : startContainer.childNodes[startOffset];
34086
+ // Through a block taken whole, as a line holding only the word is
34087
+ while(jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isHTMLElement(node)){
34088
+ whole.selectNode(node);
34089
+ if (range.compareBoundaryPoints(Range.END_TO_END, whole) < 0) {
34090
+ break;
34091
+ }
34092
+ if (keepsFormat(node)) {
34093
+ format.push(node);
34094
+ } else if (format.length || !jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isBlock(node)) {
34095
+ break;
34096
+ }
34097
+ 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 ?? ''));
34098
+ }
34099
+ return format;
34100
+ }
34101
+ /**
34102
+ * As the browsers do, the next letter typed keeps the formatting that was
34103
+ * deleted whole: empty copies go where it was, round an invisible space,
34104
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
34105
+ */ __keepFormat(format, fake, range) {
34106
+ const copies = format.map((element)=>element.cloneNode(false));
34107
+ for(let i = 1; i < copies.length; i += 1){
34108
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[i - 1], copies[i]);
34109
+ }
34110
+ const text = this.jodit.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.INVISIBLE_SPACE);
34111
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[copies.length - 1], text);
34112
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.before(fake, copies[0]);
34113
+ range.setStartAfter(text);
34114
+ range.collapse(true);
34115
+ }
34059
34116
  /**
34060
34117
  * A selection that starts or ends in a table cell clears the selected part
34061
34118
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -34798,7 +34855,13 @@ const brBoxes = new Set([
34798
34855
  // text; moving it before the `<br>` would put it on a line of its own
34799
34856
  // below the block (#1315)
34800
34857
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isOrContains(node, jodit.s.range.startContainer)) {
34801
- jodit.s.setCursorBefore(br);
34858
+ // Not with setCursorBefore: the text node it adds for the caret
34859
+ // stays after the inserted element once the `<br>` has gone, and
34860
+ // Right or End then take the caret into it, out of the element
34861
+ const range = jodit.s.createRange();
34862
+ range.setStartBefore(br);
34863
+ range.collapse(true);
34864
+ jodit.s.selectRange(range);
34802
34865
  }
34803
34866
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(br);
34804
34867
  }
@@ -44750,10 +44813,11 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
44750
44813
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
44751
44814
  /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28077);
44752
44815
  /* harmony import */ var jodit_core_helpers_checker_is_marker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23175);
44753
- /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7909);
44754
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(80991);
44755
- /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(18855);
44756
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8257);
44816
+ /* harmony import */ var jodit_core_helpers_utils_anchor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(85371);
44817
+ /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7909);
44818
+ /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(80991);
44819
+ /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(18855);
44820
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8257);
44757
44821
  /*!
44758
44822
  * Jodit Editor (https://xdsoft.net/jodit/)
44759
44823
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -44775,6 +44839,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
44775
44839
 
44776
44840
 
44777
44841
 
44842
+
44778
44843
  /**
44779
44844
  * Check if root node is empty
44780
44845
  * @private
@@ -44799,18 +44864,19 @@ function isBlank(root) {
44799
44864
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(first) && !next) {
44800
44865
  return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(first);
44801
44866
  }
44802
- 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')));
44867
+ // An anchor has no text, but it's content, shown as a marker
44868
+ 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')));
44803
44869
  }
44804
44870
  /**
44805
44871
  * Show placeholder inside empty editor
44806
- */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__.Plugin {
44872
+ */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__.Plugin {
44807
44873
  afterInit(editor) {
44808
44874
  if (!editor.o.showPlaceholder) {
44809
44875
  return;
44810
44876
  }
44811
44877
  this.placeholderElm = editor.c.fromHTML(`<span data-ref="placeholder" style="display: none;" class="jodit-placeholder">${editor.i18n(editor.o.placeholder)}</span>`);
44812
44878
  if (editor.o.direction === 'rtl') {
44813
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44879
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44814
44880
  right: 0,
44815
44881
  direction: 'rtl'
44816
44882
  });
@@ -44839,19 +44905,19 @@ function isBlank(root) {
44839
44905
  const style2 = editor.ew.getComputedStyle(firstChild);
44840
44906
  marginTop = parseInt(style2.getPropertyValue('margin-top'), 10);
44841
44907
  marginLeft = parseInt(style2.getPropertyValue('margin-left'), 10);
44842
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44908
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44843
44909
  fontFamily: style2.getPropertyValue('font-family'),
44844
44910
  fontSize: parseInt(style2.getPropertyValue('font-size'), 10),
44845
44911
  lineHeight: style2.getPropertyValue('line-height')
44846
44912
  });
44847
44913
  } else {
44848
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44914
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44849
44915
  fontFamily: style.getPropertyValue('font-family'),
44850
44916
  fontSize: parseInt(style.getPropertyValue('font-size'), 10),
44851
44917
  lineHeight: style.getPropertyValue('line-height')
44852
44918
  });
44853
44919
  }
44854
- ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
44920
+ ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
44855
44921
  display: 'block',
44856
44922
  textAlign: style.getPropertyValue('text-align'),
44857
44923
  paddingTop: parseInt(styleEditor.paddingTop, 10) + 'px',
@@ -44889,7 +44955,7 @@ function isBlank(root) {
44889
44955
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "addEvents", ()=>{
44890
44956
  const editor = this.j;
44891
44957
  if (editor.o.useInputsPlaceholder && editor.element.hasAttribute('placeholder')) {
44892
- this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
44958
+ this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__.attr)(editor.element, 'placeholder') || '';
44893
44959
  }
44894
44960
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
44895
44961
  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);