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/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.20.2
4
+ * Version: v4.20.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1830,7 +1830,7 @@ __webpack_require__.r(__webpack_exports__);
1830
1830
  * ```
1831
1831
  * @packageDocumentation
1832
1832
  * @module constants
1833
- */ const APP_VERSION = "4.20.2";
1833
+ */ const APP_VERSION = "4.20.3";
1834
1834
  // prettier-ignore
1835
1835
  const ES = "es2015";
1836
1836
  const IS_ES_MODERN = true;
@@ -21704,12 +21704,13 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21704
21704
  }), 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)=>{
21705
21705
  const image = self.c.element('img');
21706
21706
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_2__.attr)(image, 'src', src);
21707
+ (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_2__.attr)(image, 'alt', ga('data-name'));
21707
21708
  const onload = ()=>{
21708
21709
  var _self_events;
21709
21710
  if (self.isInDestruct) {
21710
21711
  return;
21711
21712
  }
21712
- self.e.off(image, 'load');
21713
+ self.e.off(image, 'load error');
21713
21714
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.detach(temp_content);
21714
21715
  if (opt.showPreviewNavigation) {
21715
21716
  if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.prevWithClass(item, self.files.getFullElName('item'))) {
@@ -21724,7 +21725,10 @@ const CLASS_PREVIEW = 'jodit-file-browser-preview', preview_tpl_next = (next = '
21724
21725
  preview.setPosition();
21725
21726
  self === null || self === void 0 ? void 0 : (_self_events = self.events) === null || _self_events === void 0 ? void 0 : _self_events.fire('previewOpenedAndLoaded');
21726
21727
  };
21727
- self.e.on(image, 'load', onload);
21728
+ // An image that can't load is shown too,
21729
+ // broken with the file's name, rather
21730
+ // than the loader for good
21731
+ self.e.on(image, 'load error', onload);
21728
21732
  if (image.complete) {
21729
21733
  onload();
21730
21734
  }
@@ -27390,7 +27394,9 @@ ToolbarEditorCollection = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1
27390
27394
  }
27391
27395
  function makeSelect(view, control, target = null) {
27392
27396
  const ToolbarSelect = (0,jodit_core_decorators_component_component__WEBPACK_IMPORTED_MODULE_0__.getComponentClass)('ToolbarSelect');
27393
- return new ToolbarSelect(view, control, target);
27397
+ const select = new ToolbarSelect(view, control, target);
27398
+ select.state.tabIndex = view.o.allowTabNavigation ? 0 : -1;
27399
+ return select;
27394
27400
  }
27395
27401
 
27396
27402
 
@@ -30790,7 +30796,7 @@ function moveContentAndRemoveEmpty(jodit, mainClosestBox, sibling, backspace) {
30790
30796
  * @private
30791
30797
  */ function checkNotCollapsed(jodit) {
30792
30798
  if (!jodit.s.isCollapsed()) {
30793
- jodit.execCommand('Delete');
30799
+ jodit.execCommand('delete', false, true);
30794
30800
  return true;
30795
30801
  }
30796
30802
  return false;
@@ -34233,6 +34239,13 @@ const KEEPS_SPACES = new Set([
34233
34239
  'pre-wrap',
34234
34240
  'break-spaces'
34235
34241
  ]);
34242
+ /**
34243
+ * Formatting that the next letter keeps once all of the text in it is
34244
+ * deleted with a key: a formatting tag, or a span with styles of its own.
34245
+ * Not a link, which new text isn't added to, or a wrapper such as a video's
34246
+ */ function keepsFormat(node) {
34247
+ 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'));
34248
+ }
34236
34249
  /**
34237
34250
  * A plain space beside this neighbor isn't shown: there is none, or it's a
34238
34251
  * line break, a block or text starting (or ending) with a plain space
@@ -34281,7 +34294,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34281
34294
  jodit.s.removeNode(node);
34282
34295
  }
34283
34296
  }
34284
- __onDeleteCommand() {
34297
+ __onDeleteCommand(command, showUI, keepFormat) {
34285
34298
  const { jodit } = this;
34286
34299
  if (jodit.s.isCollapsed()) {
34287
34300
  return;
@@ -34289,6 +34302,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34289
34302
  jodit.s.expandSelection();
34290
34303
  const range = jodit.s.range;
34291
34304
  this.__moveEdgesIntoCells(range);
34305
+ const format = keepFormat === true ? this.__formatTakenWhole(range) : [];
34292
34306
  const caret = this.__clearSelectedCells(range);
34293
34307
  if (caret && range.collapsed) {
34294
34308
  jodit.s.selectRange(caret);
@@ -34304,8 +34318,12 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34304
34318
  this.__keepSpacesVisibleBesideTable(fake);
34305
34319
  range.setStartBefore(fake);
34306
34320
  range.collapse(true);
34307
- this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
34308
- this.__addBrInEmptyBlock(fake, range);
34321
+ if (format.length && !caret) {
34322
+ this.__keepFormat(format, fake, range);
34323
+ } else {
34324
+ this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
34325
+ this.__addBrInEmptyBlock(fake, range);
34326
+ }
34309
34327
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.safeRemove(fake);
34310
34328
  jodit.s.selectRange(caret !== null && caret !== void 0 ? caret : range);
34311
34329
  return false;
@@ -34326,6 +34344,48 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
34326
34344
  range.setEnd(last, last.childNodes.length);
34327
34345
  }
34328
34346
  }
34347
+ /**
34348
+ * The formatting elements the deletion takes whole from its start,
34349
+ * outermost first: `<strong>` and `<em>` for all of the text in
34350
+ * `<strong><em>cd</em></strong>`
34351
+ */ __formatTakenWhole(range) {
34352
+ const format = [];
34353
+ const whole = this.jodit.s.createRange();
34354
+ const { startContainer, startOffset } = range;
34355
+ let node = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isText(startContainer) ? null : startContainer.childNodes[startOffset];
34356
+ // Through a block taken whole, as a line holding only the word is
34357
+ while(jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isHTMLElement(node)){
34358
+ whole.selectNode(node);
34359
+ if (range.compareBoundaryPoints(Range.END_TO_END, whole) < 0) {
34360
+ break;
34361
+ }
34362
+ if (keepsFormat(node)) {
34363
+ format.push(node);
34364
+ } else if (format.length || !jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isBlock(node)) {
34365
+ break;
34366
+ }
34367
+ node = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.toArray)(node.childNodes).find((child)=>{
34368
+ var _child_nodeValue;
34369
+ return !jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isText(child) || (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.trimInv)((_child_nodeValue = child.nodeValue) !== null && _child_nodeValue !== void 0 ? _child_nodeValue : '');
34370
+ });
34371
+ }
34372
+ return format;
34373
+ }
34374
+ /**
34375
+ * As the browsers do, the next letter typed keeps the formatting that was
34376
+ * deleted whole: empty copies go where it was, round an invisible space,
34377
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
34378
+ */ __keepFormat(format, fake, range) {
34379
+ const copies = format.map((element)=>element.cloneNode(false));
34380
+ for(let i = 1; i < copies.length; i += 1){
34381
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[i - 1], copies[i]);
34382
+ }
34383
+ const text = this.jodit.createInside.text(jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.INVISIBLE_SPACE);
34384
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.append(copies[copies.length - 1], text);
34385
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.before(fake, copies[0]);
34386
+ range.setStartAfter(text);
34387
+ range.collapse(true);
34388
+ }
34329
34389
  /**
34330
34390
  * A selection that starts or ends in a table cell clears the selected part
34331
34391
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -35075,7 +35135,13 @@ const brBoxes = new Set([
35075
35135
  // text; moving it before the `<br>` would put it on a line of its own
35076
35136
  // below the block (#1315)
35077
35137
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isOrContains(node, jodit.s.range.startContainer)) {
35078
- jodit.s.setCursorBefore(br);
35138
+ // Not with setCursorBefore: the text node it adds for the caret
35139
+ // stays after the inserted element once the `<br>` has gone, and
35140
+ // Right or End then take the caret into it, out of the element
35141
+ const range = jodit.s.createRange();
35142
+ range.setStartBefore(br);
35143
+ range.collapse(true);
35144
+ jodit.s.selectRange(range);
35079
35145
  }
35080
35146
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(br);
35081
35147
  }
@@ -45137,10 +45203,11 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
45137
45203
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
45138
45204
  /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28077);
45139
45205
  /* harmony import */ var jodit_core_helpers_checker_is_marker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23175);
45140
- /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7909);
45141
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(80991);
45142
- /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(18855);
45143
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(8257);
45206
+ /* harmony import */ var jodit_core_helpers_utils_anchor__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(85371);
45207
+ /* harmony import */ var jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7909);
45208
+ /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(80991);
45209
+ /* harmony import */ var jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(18855);
45210
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8257);
45144
45211
  /*!
45145
45212
  * Jodit Editor (https://xdsoft.net/jodit/)
45146
45213
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -45162,6 +45229,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
45162
45229
 
45163
45230
 
45164
45231
 
45232
+
45165
45233
  /**
45166
45234
  * Check if root node is empty
45167
45235
  * @private
@@ -45188,18 +45256,19 @@ function isBlank(root) {
45188
45256
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(first) && !next) {
45189
45257
  return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(first);
45190
45258
  }
45191
- 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')));
45259
+ // An anchor has no text, but it's content, shown as a marker
45260
+ 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')));
45192
45261
  }
45193
45262
  /**
45194
45263
  * Show placeholder inside empty editor
45195
- */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_9__.Plugin {
45264
+ */ class placeholder extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_10__.Plugin {
45196
45265
  afterInit(editor) {
45197
45266
  if (!editor.o.showPlaceholder) {
45198
45267
  return;
45199
45268
  }
45200
45269
  this.placeholderElm = editor.c.fromHTML(`<span data-ref="placeholder" style="display: none;" class="jodit-placeholder">${editor.i18n(editor.o.placeholder)}</span>`);
45201
45270
  if (editor.o.direction === 'rtl') {
45202
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
45271
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
45203
45272
  right: 0,
45204
45273
  direction: 'rtl'
45205
45274
  });
@@ -45228,19 +45297,19 @@ function isBlank(root) {
45228
45297
  const style2 = editor.ew.getComputedStyle(firstChild);
45229
45298
  marginTop = parseInt(style2.getPropertyValue('margin-top'), 10);
45230
45299
  marginLeft = parseInt(style2.getPropertyValue('margin-left'), 10);
45231
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
45300
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
45232
45301
  fontFamily: style2.getPropertyValue('font-family'),
45233
45302
  fontSize: parseInt(style2.getPropertyValue('font-size'), 10),
45234
45303
  lineHeight: style2.getPropertyValue('line-height')
45235
45304
  });
45236
45305
  } else {
45237
- (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
45306
+ (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
45238
45307
  fontFamily: style.getPropertyValue('font-family'),
45239
45308
  fontSize: parseInt(style.getPropertyValue('font-size'), 10),
45240
45309
  lineHeight: style.getPropertyValue('line-height')
45241
45310
  });
45242
45311
  }
45243
- ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.css)(this.placeholderElm, {
45312
+ ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_9__.css)(this.placeholderElm, {
45244
45313
  display: 'block',
45245
45314
  textAlign: style.getPropertyValue('text-align'),
45246
45315
  paddingTop: parseInt(styleEditor.paddingTop, 10) + 'px',
@@ -45278,7 +45347,7 @@ function isBlank(root) {
45278
45347
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "addEvents", ()=>{
45279
45348
  const editor = this.j;
45280
45349
  if (editor.o.useInputsPlaceholder && editor.element.hasAttribute('placeholder')) {
45281
- this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
45350
+ this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_8__.attr)(editor.element, 'placeholder') || '';
45282
45351
  }
45283
45352
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
45284
45353
  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);