jodit 4.4.7 → 4.5.1

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 (63) hide show
  1. package/CHANGELOG.md +25 -3
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +82 -40
  5. package/es2015/jodit.min.js +2 -2
  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.css +1 -1
  13. package/es2018/jodit.fat.min.js +2 -2
  14. package/es2018/jodit.js +82 -40
  15. package/es2018/jodit.min.js +2 -2
  16. package/es2018/plugins/debug/debug.css +1 -1
  17. package/es2018/plugins/debug/debug.js +1 -1
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  20. package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  22. package/es2021/jodit.css +1 -1
  23. package/es2021/jodit.fat.min.js +2 -2
  24. package/es2021/jodit.js +82 -40
  25. package/es2021/jodit.min.js +2 -2
  26. package/es2021/plugins/debug/debug.css +1 -1
  27. package/es2021/plugins/debug/debug.js +1 -1
  28. package/es2021/plugins/debug/debug.min.js +1 -1
  29. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  30. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  32. package/es2021.en/jodit.css +1 -1
  33. package/es2021.en/jodit.fat.min.js +2 -2
  34. package/es2021.en/jodit.js +82 -40
  35. package/es2021.en/jodit.min.js +2 -2
  36. package/es2021.en/plugins/debug/debug.css +1 -1
  37. package/es2021.en/plugins/debug/debug.js +1 -1
  38. package/es2021.en/plugins/debug/debug.min.js +1 -1
  39. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  40. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  42. package/es5/5.fat.min.js +1 -1
  43. package/es5/5.min.js +1 -1
  44. package/es5/975.fat.min.js +1 -1
  45. package/es5/975.min.js +1 -1
  46. package/es5/jodit.css +2 -2
  47. package/es5/jodit.fat.min.js +2 -2
  48. package/es5/jodit.js +82 -40
  49. package/es5/jodit.min.css +2 -2
  50. package/es5/jodit.min.js +2 -2
  51. package/es5/plugins/debug/debug.css +1 -1
  52. package/es5/plugins/debug/debug.js +1 -1
  53. package/es5/plugins/debug/debug.min.js +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  56. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  57. package/esm/core/constants.js +1 -1
  58. package/esm/core/dom/dom.d.ts +5 -0
  59. package/esm/core/dom/dom.js +36 -12
  60. package/esm/plugins/clean-html/helpers/visitor/filters/try-remove-node.js +11 -5
  61. package/esm/plugins/indent/indent.js +34 -22
  62. package/package.json +1 -1
  63. package/types/core/dom/dom.d.ts +5 -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.4.7
4
+ * Version: v4.5.1
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1742,7 +1742,7 @@ __webpack_require__.r(__webpack_exports__);
1742
1742
  * Released under MIT see LICENSE.txt in the project root for license information.
1743
1743
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
1744
1744
  */
1745
- const APP_VERSION = "4.4.7";
1745
+ const APP_VERSION = "4.5.1";
1746
1746
  // prettier-ignore
1747
1747
  const ES = "es2015";
1748
1748
  const IS_ES_MODERN = true;
@@ -2887,28 +2887,25 @@ class Dom {
2887
2887
  }
2888
2888
  }
2889
2889
  /**
2890
- * Wrap all inline siblings
2890
+ * Wrap all inline next siblings
2891
2891
  */
2892
- static wrapInline(current, tag, editor) {
2893
- let tmp, first = current, last = current;
2892
+ static wrapNextInline(current, tag, editor) {
2893
+ let tmp;
2894
+ const first = current;
2895
+ let last = current;
2894
2896
  editor.s.save();
2895
2897
  let needFindNext = false;
2896
- do {
2897
- needFindNext = false;
2898
- tmp = first.previousSibling;
2899
- if (tmp && !Dom.isBlock(tmp)) {
2900
- needFindNext = true;
2901
- first = tmp;
2902
- }
2903
- } while (needFindNext);
2904
2898
  do {
2905
2899
  needFindNext = false;
2906
2900
  tmp = last.nextSibling;
2907
- if (tmp && !Dom.isBlock(tmp)) {
2901
+ if (tmp && !Dom.isBlock(tmp) && !Dom.isTag(tmp, 'br')) {
2908
2902
  needFindNext = true;
2909
2903
  last = tmp;
2910
2904
  }
2911
2905
  } while (needFindNext);
2906
+ return Dom.__wrapElements(tag, editor, first, last);
2907
+ }
2908
+ static __wrapElements(tag, editor, first, last) {
2912
2909
  const wrapper = (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isString */ .Kg)(tag) ? editor.createInside.element(tag) : tag;
2913
2910
  if (first.parentNode) {
2914
2911
  first.parentNode.insertBefore(wrapper, first);
@@ -2925,6 +2922,33 @@ class Dom {
2925
2922
  editor.s.restore();
2926
2923
  return wrapper;
2927
2924
  }
2925
+ /**
2926
+ * Wrap all inline siblings
2927
+ */
2928
+ static wrapInline(current, tag, editor) {
2929
+ let tmp;
2930
+ let first = current;
2931
+ let last = current;
2932
+ editor.s.save();
2933
+ let needFindNext = false;
2934
+ do {
2935
+ needFindNext = false;
2936
+ tmp = first.previousSibling;
2937
+ if (tmp && !Dom.isBlock(tmp)) {
2938
+ needFindNext = true;
2939
+ first = tmp;
2940
+ }
2941
+ } while (needFindNext);
2942
+ do {
2943
+ needFindNext = false;
2944
+ tmp = last.nextSibling;
2945
+ if (tmp && !Dom.isBlock(tmp)) {
2946
+ needFindNext = true;
2947
+ last = tmp;
2948
+ }
2949
+ } while (needFindNext);
2950
+ return Dom.__wrapElements(tag, editor, first, last);
2951
+ }
2928
2952
  /**
2929
2953
  * Wrap node inside another node
2930
2954
  */
@@ -27871,12 +27895,18 @@ function tryRemoveNode(jodit, nodeElm, hadEffect, allowTags, denyTags, currentSe
27871
27895
  * @private
27872
27896
  */
27873
27897
  function isRemovableNode(jodit, node, current, allow, deny) {
27874
- if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isText(node) &&
27875
- ((allow && !allow[node.nodeName]) || (deny && deny[node.nodeName]))) {
27876
- return true;
27898
+ if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isText(node)) {
27899
+ if (allow && !allow[node.nodeName]) {
27900
+ return true;
27901
+ }
27902
+ if (!allow && deny && deny[node.nodeName]) {
27903
+ return true;
27904
+ }
27877
27905
  }
27878
- return (jodit.o.cleanHTML.removeEmptyElements &&
27879
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isElement(node) &&
27906
+ if (!jodit.o.cleanHTML.removeEmptyElements) {
27907
+ return false;
27908
+ }
27909
+ return (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isElement(node) &&
27880
27910
  node.nodeName.match(jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.IS_INLINE) != null &&
27881
27911
  !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isTemporary(node) &&
27882
27912
  (0,jodit_core_helpers_string_trim__WEBPACK_IMPORTED_MODULE_2__/* .trim */ .Bq)(node.innerHTML).length === 0 &&
@@ -33179,7 +33209,7 @@ const getKey = (direction, box) => `${jodit_core_dom_dom__WEBPACK_IMPORTED_MODUL
33179
33209
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17352);
33180
33210
  /* harmony import */ var jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71842);
33181
33211
  /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(56298);
33182
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(65147);
33212
+ /* harmony import */ var jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(97369);
33183
33213
  /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(97767);
33184
33214
  /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3392);
33185
33215
  /*!
@@ -33193,6 +33223,22 @@ const getKey = (direction, box) => `${jodit_core_dom_dom__WEBPACK_IMPORTED_MODUL
33193
33223
 
33194
33224
 
33195
33225
 
33226
+ const applyIndentToBox = (processedElements, currentBox, editor, command) => {
33227
+ if (!currentBox) {
33228
+ return;
33229
+ }
33230
+ if (processedElements.has(currentBox)) {
33231
+ return;
33232
+ }
33233
+ const key = (0,_helpers__WEBPACK_IMPORTED_MODULE_5__/* .getKey */ .i)(editor.o.direction, currentBox);
33234
+ processedElements.add(currentBox);
33235
+ let value = currentBox.style[key] ? parseInt(currentBox.style[key], 10) : 0;
33236
+ value += editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
33237
+ currentBox.style[key] = value > 0 ? value + 'px' : '';
33238
+ if (!(0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_3__.attr)(currentBox, 'style')) {
33239
+ (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_3__.attr)(currentBox, 'style', null);
33240
+ }
33241
+ };
33196
33242
  /**
33197
33243
  * Indents the line containing the selection or insertion point.
33198
33244
  */
@@ -33206,46 +33252,42 @@ function indent(editor) {
33206
33252
  name: 'outdent',
33207
33253
  group: 'indent'
33208
33254
  });
33209
- const callback = (command) => {
33210
- const processedElements = [];
33255
+ const indentCommand = (command) => {
33256
+ const processedElements = new Set();
33257
+ const { enter, enterBlock } = editor.o;
33258
+ const isBrMode = enter.toLowerCase() === jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.BR;
33259
+ const current = editor.s.current();
33260
+ if (isBrMode && editor.s.isCollapsed()) {
33261
+ if (current) {
33262
+ const box = jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.wrapNextInline(current, enterBlock, editor);
33263
+ applyIndentToBox(processedElements, box, editor, command);
33264
+ return false;
33265
+ }
33266
+ }
33211
33267
  editor.s.eachSelection((current) => {
33212
33268
  editor.s.save();
33213
33269
  let currentBox = current
33214
33270
  ? jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.up(current, jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isBlock, editor.editor)
33215
33271
  : false;
33216
- const { enter } = editor.o;
33217
33272
  if (!currentBox && current) {
33218
- currentBox = jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.wrapInline(current, enter !== jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.BR ? enter : jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.PARAGRAPH, editor);
33273
+ currentBox = (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_3__.call)(!isBrMode ? jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.wrapInline : jodit_core_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.wrapNextInline, current, !isBrMode ? enter.toLowerCase() : enterBlock, editor);
33219
33274
  }
33220
33275
  if (!currentBox) {
33221
33276
  editor.s.restore();
33222
33277
  return false;
33223
33278
  }
33224
- const alreadyIndented = processedElements.includes(currentBox);
33225
- if (currentBox && !alreadyIndented) {
33226
- const key = (0,_helpers__WEBPACK_IMPORTED_MODULE_5__/* .getKey */ .i)(editor.o.direction, currentBox);
33227
- processedElements.push(currentBox);
33228
- let value = currentBox.style[key]
33229
- ? parseInt(currentBox.style[key], 10)
33230
- : 0;
33231
- value +=
33232
- editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
33233
- currentBox.style[key] = value > 0 ? value + 'px' : '';
33234
- if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.attr)(currentBox, 'style')) {
33235
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_3__.attr)(currentBox, 'style', null);
33236
- }
33237
- }
33279
+ applyIndentToBox(processedElements, currentBox, editor, command);
33238
33280
  editor.s.restore();
33239
33281
  });
33240
33282
  editor.synchronizeValues();
33241
33283
  return false;
33242
33284
  };
33243
33285
  editor.registerCommand('indent', {
33244
- exec: callback,
33286
+ exec: indentCommand,
33245
33287
  hotkeys: ['ctrl+]', 'cmd+]']
33246
33288
  });
33247
33289
  editor.registerCommand('outdent', {
33248
- exec: callback,
33290
+ exec: indentCommand,
33249
33291
  hotkeys: ['ctrl+[', 'cmd+[']
33250
33292
  });
33251
33293
  }