jodit 4.15.16 → 4.15.18

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 (69) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +7 -7
  4. package/es2015/jodit.js +165 -48
  5. package/es2015/jodit.min.js +7 -7
  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 +4 -4
  13. package/es2018/jodit.min.js +7 -7
  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 +8 -8
  18. package/es2021/jodit.js +162 -48
  19. package/es2021/jodit.min.js +12 -12
  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 +8 -8
  28. package/es2021.en/jodit.js +162 -48
  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 +213 -77
  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/config.d.ts +23 -0
  51. package/esm/config.js +21 -0
  52. package/esm/core/constants.js +1 -1
  53. package/esm/core/helpers/utils/align.d.ts +8 -3
  54. package/esm/core/helpers/utils/align.js +40 -2
  55. package/esm/core/selection/selection.js +5 -0
  56. package/esm/plugins/focus/focus.js +17 -1
  57. package/esm/plugins/image-processor/image-processor.js +20 -1
  58. package/esm/plugins/image-properties/readers/align.d.ts +5 -1
  59. package/esm/plugins/image-properties/readers/align.js +4 -18
  60. package/esm/plugins/image-properties/readers/index.js +1 -1
  61. package/esm/plugins/image-properties/writers/index.js +1 -1
  62. package/esm/plugins/image-properties/writers/margin.js +5 -3
  63. package/esm/plugins/inline-popup/config/items/img.js +24 -2
  64. package/esm/types/types.d.ts +4 -0
  65. package/package.json +1 -1
  66. package/types/config.d.ts +23 -0
  67. package/types/core/helpers/utils/align.d.ts +8 -3
  68. package/types/plugins/image-properties/readers/align.d.ts +5 -1
  69. package/types/types/types.d.ts +4 -0
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.15.16
4
+ * Version: v4.15.18
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -728,6 +728,25 @@ let ConfigPrototype = {};
728
728
  /**
729
729
  * Default width (in pixels) applied to images inserted into the editor
730
730
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "imageDefaultWidth", 300);
731
+ /**
732
+ * Alignment given to images inserted into the editor. `'normal'` leaves
733
+ * them unaligned
734
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "imageDefaultAlign", 'normal');
735
+ /**
736
+ * Class names to align images with, instead of an inline `float` or
737
+ * `margin`. Aligning an image removes every class listed here and adds the
738
+ * chosen alignment's, which can be several separated by spaces.
739
+ *
740
+ * ```javascript
741
+ * Jodit.make('#editor', {
742
+ * imageAlignClasses: {
743
+ * left: 'align-left',
744
+ * right: 'align-right',
745
+ * center: 'align-center'
746
+ * }
747
+ * });
748
+ * ```
749
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "imageAlignClasses", null);
731
750
  /**
732
751
  * Do not display these buttons that are on the list
733
752
  *
@@ -1780,7 +1799,7 @@ __webpack_require__.r(__webpack_exports__);
1780
1799
  * ```
1781
1800
  * @packageDocumentation
1782
1801
  * @module constants
1783
- */ const APP_VERSION = "4.15.16";
1802
+ */ const APP_VERSION = "4.15.18";
1784
1803
  // prettier-ignore
1785
1804
  const ES = "es2021";
1786
1805
  const IS_ES_MODERN = true;
@@ -7535,6 +7554,7 @@ function trimChars(value, chars) {
7535
7554
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7536
7555
  /* harmony export */ alignElement: function() { return /* binding */ alignElement; },
7537
7556
  /* harmony export */ clearAlign: function() { return /* binding */ clearAlign; },
7557
+ /* harmony export */ getHAlign: function() { return /* binding */ getHAlign; },
7538
7558
  /* harmony export */ hAlignElement: function() { return /* binding */ hAlignElement; }
7539
7559
  /* harmony export */ });
7540
7560
  /* harmony import */ var jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27795);
@@ -7549,9 +7569,25 @@ function trimChars(value, chars) {
7549
7569
  */
7550
7570
 
7551
7571
 
7572
+ const classNames = (value)=>(value ?? '').split(/\s+/).filter(Boolean);
7552
7573
  /**
7553
- * Align image
7554
- */ function hAlignElement(image, align) {
7574
+ * Align image, with `classes` (see `imageAlignClasses`) instead of inline
7575
+ * styles when they are given
7576
+ */ function hAlignElement(image, align, classes) {
7577
+ if (classes) {
7578
+ hAlignElement(image, 'normal');
7579
+ Object.values(classes).forEach((value)=>image.classList.remove(...classNames(value)));
7580
+ image.classList.add(...classNames(classes[align || 'normal']));
7581
+ [
7582
+ 'class',
7583
+ 'style'
7584
+ ].forEach((name)=>{
7585
+ if (!(0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, name)?.trim()) {
7586
+ (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, name, null);
7587
+ }
7588
+ });
7589
+ return;
7590
+ }
7555
7591
  if (align && align !== 'normal') {
7556
7592
  if (align !== 'center') {
7557
7593
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.css)(image, 'float', align);
@@ -7574,6 +7610,31 @@ function trimChars(value, chars) {
7574
7610
  ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.clearCenterAlign)(image);
7575
7611
  }
7576
7612
  }
7613
+ /**
7614
+ * The alignment `hAlignElement` has set on an element
7615
+ */ function getHAlign(elm, classes) {
7616
+ if (classes) {
7617
+ for (const align of [
7618
+ 'left',
7619
+ 'right',
7620
+ 'center',
7621
+ 'normal'
7622
+ ]){
7623
+ const names = classNames(classes[align]);
7624
+ if (names.length && names.every((name)=>elm.classList.contains(name))) {
7625
+ return align;
7626
+ }
7627
+ }
7628
+ }
7629
+ const float = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.cssInline)(elm, 'float').toLowerCase();
7630
+ if (float === 'left' || float === 'right') {
7631
+ return float;
7632
+ }
7633
+ if ((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.css)(elm, 'display') === 'block' && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.cssInline)(elm, 'margin-left') === 'auto' && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.cssInline)(elm, 'margin-right') === 'auto') {
7634
+ return 'center';
7635
+ }
7636
+ return 'normal';
7637
+ }
7577
7638
  /**
7578
7639
  * Remove text-align style for all selected children
7579
7640
  */ function clearAlign(node) {
@@ -8736,6 +8797,7 @@ __webpack_require__.r(__webpack_exports__);
8736
8797
  /* harmony export */ get: function() { return /* reexport safe */ _get__WEBPACK_IMPORTED_MODULE_15__.get; },
8737
8798
  /* harmony export */ getClassName: function() { return /* reexport safe */ _get_class_name__WEBPACK_IMPORTED_MODULE_16__.getClassName; },
8738
8799
  /* harmony export */ getDataTransfer: function() { return /* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_27__.getDataTransfer; },
8800
+ /* harmony export */ getHAlign: function() { return /* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_0__.getHAlign; },
8739
8801
  /* harmony export */ getPropertyDescriptor: function() { return /* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_27__.getPropertyDescriptor; },
8740
8802
  /* harmony export */ getXPathByElement: function() { return /* reexport safe */ _selector__WEBPACK_IMPORTED_MODULE_24__.getXPathByElement; },
8741
8803
  /* harmony export */ hAlignElement: function() { return /* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_0__.hAlignElement; },
@@ -8766,7 +8828,7 @@ __webpack_require__.r(__webpack_exports__);
8766
8828
  /* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(28712);
8767
8829
  /* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_assert__WEBPACK_IMPORTED_MODULE_2__);
8768
8830
  /* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
8769
- /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _assert__WEBPACK_IMPORTED_MODULE_2__) if(["default","alignElement","clearAlign","hAlignElement","alreadyLoadedList","appendScriptAsync","appendStyleAsync","loadNext","loadNextStyle"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = function(key) { return _assert__WEBPACK_IMPORTED_MODULE_2__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
8831
+ /* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _assert__WEBPACK_IMPORTED_MODULE_2__) if(["default","alignElement","clearAlign","getHAlign","hAlignElement","alreadyLoadedList","appendScriptAsync","appendStyleAsync","loadNext","loadNextStyle"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = function(key) { return _assert__WEBPACK_IMPORTED_MODULE_2__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
8770
8832
  /* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
8771
8833
  /* harmony import */ var _attr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7909);
8772
8834
  /* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26136);
@@ -10666,11 +10728,12 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10666
10728
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
10667
10729
  /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
10668
10730
  /* harmony import */ var jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28686);
10669
- /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(28712);
10670
- /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__);
10671
- /* harmony import */ var jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7470);
10672
- /* harmony import */ var _style_commit_style__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(84578);
10673
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(42259);
10731
+ /* harmony import */ var jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16849);
10732
+ /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(28712);
10733
+ /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__);
10734
+ /* harmony import */ var jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7470);
10735
+ /* harmony import */ var _style_commit_style__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(84578);
10736
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(42259);
10674
10737
  /*!
10675
10738
  * Jodit Editor (https://xdsoft.net/jodit/)
10676
10739
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -10692,6 +10755,7 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10692
10755
 
10693
10756
 
10694
10757
 
10758
+
10695
10759
  class Selection {
10696
10760
  /**
10697
10761
  * Short alias for this.jodit
@@ -11124,7 +11188,7 @@ class Selection {
11124
11188
  return node;
11125
11189
  }
11126
11190
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node)) {
11127
- const ret = (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.findCorrectCurrentNode)(node, range, rightMode, sel.isCollapsed, checkChild, child);
11191
+ const ret = (0,_helpers__WEBPACK_IMPORTED_MODULE_11__.findCorrectCurrentNode)(node, range, rightMode, sel.isCollapsed, checkChild, child);
11128
11192
  node = ret.node;
11129
11193
  rightMode = ret.rightMode;
11130
11194
  }
@@ -11265,6 +11329,10 @@ class Selection {
11265
11329
  if (styles && typeof styles === 'object') {
11266
11330
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(image, styles);
11267
11331
  }
11332
+ const { imageDefaultAlign, imageAlignClasses } = this.j.o;
11333
+ if (imageDefaultAlign && imageDefaultAlign !== 'normal') {
11334
+ (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_7__.hAlignElement)(image, imageDefaultAlign, imageAlignClasses);
11335
+ }
11268
11336
  const onload = ()=>{
11269
11337
  if (image.naturalHeight < image.offsetHeight || image.naturalWidth < image.offsetWidth) {
11270
11338
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(image, {
@@ -11388,7 +11456,7 @@ class Selection {
11388
11456
  const isSignificant = (elm)=>Boolean(elm && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTag(elm, 'br') && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(elm) && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isTemporary(elm) && !(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isElement(elm) && this.j.e.fire('isInvisibleForCursor', elm) === true));
11389
11457
  // check right offset
11390
11458
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
11391
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.cursorInTheEdgeOfString)(container, offset, start, end)) {
11459
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_11__.cursorInTheEdgeOfString)(container, offset, start, end)) {
11392
11460
  return false;
11393
11461
  }
11394
11462
  } else {
@@ -11776,8 +11844,8 @@ class Selection {
11776
11844
  * }) // will remove `color:red` from `span`
11777
11845
  * ```
11778
11846
  */ commitStyle(options) {
11779
- ;(0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__.assert)((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.size)(options) > 0, 'Need to pass at least one option');
11780
- const styleElm = new _style_commit_style__WEBPACK_IMPORTED_MODULE_9__.CommitStyle(options);
11847
+ ;(0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__.assert)((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.size)(options) > 0, 'Need to pass at least one option');
11848
+ const styleElm = new _style_commit_style__WEBPACK_IMPORTED_MODULE_10__.CommitStyle(options);
11781
11849
  styleElm.apply(this.j);
11782
11850
  }
11783
11851
  /**
@@ -11827,7 +11895,7 @@ class Selection {
11827
11895
  }
11828
11896
  const fragment = leftRange.extractContents();
11829
11897
  const clearEmpties = (node)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.each(node, (node)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isEmptyTextNode(node) && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(node));
11830
- (0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__.assert)(currentBox.parentNode, 'Splitting fails');
11898
+ (0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__.assert)(currentBox.parentNode, 'Splitting fails');
11831
11899
  try {
11832
11900
  clearEmpties(fragment);
11833
11901
  clearEmpties(currentBox);
@@ -11880,7 +11948,7 @@ class Selection {
11880
11948
  const r = range.cloneRange();
11881
11949
  r.collapse(start);
11882
11950
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeInsertNode(r, fake);
11883
- (0,jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_8__.moveTheNodeAlongTheEdgeOutward)(fake, start, this.j.editor);
11951
+ (0,jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_9__.moveTheNodeAlongTheEdgeOutward)(fake, start, this.j.editor);
11884
11952
  return fake;
11885
11953
  };
11886
11954
  const leftFake = moveMaxEdgeFake(true);
@@ -31983,14 +32051,28 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_1__.pluginSystem.add('file', file);
31983
32051
  */ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.saveSelectionOnBlur = true;
31984
32052
  function focus(editor) {
31985
32053
  if (editor.o.saveSelectionOnBlur) {
32054
+ // A click that brings focus back places the caret itself, and Chrome
32055
+ // has already placed it when focus fires, so restoring would move it
32056
+ // back to the old selection. The saved markers are dropped instead.
32057
+ let focusByPointer = false;
31986
32058
  editor.e.on('blur', ()=>{
32059
+ // A press that never brought the focus back must not decide
32060
+ // what the next focus does
32061
+ focusByPointer = false;
31987
32062
  if (editor.isEditorMode()) {
31988
32063
  editor.s.save(true);
31989
32064
  }
32065
+ }).on('mousedown touchstart', ()=>{
32066
+ focusByPointer = !editor.editorIsActive;
31990
32067
  }).on('focus', ()=>{
31991
32068
  if (editor.isEditorMode()) {
31992
- editor.s.restore();
32069
+ if (focusByPointer) {
32070
+ editor.s.removeMarkers();
32071
+ } else {
32072
+ editor.s.restore();
32073
+ }
31993
32074
  }
32075
+ focusByPointer = false;
31994
32076
  });
31995
32077
  }
31996
32078
  const focus = ()=>{
@@ -33016,11 +33098,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33016
33098
  /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31635);
33017
33099
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81937);
33018
33100
  /* harmony import */ var jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(84839);
33019
- /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(28077);
33020
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65946);
33021
- /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(91206);
33022
- /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23112);
33023
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(51034);
33101
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(23211);
33102
+ /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28077);
33103
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
33104
+ /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(91206);
33105
+ /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(23112);
33106
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(51034);
33024
33107
  /*!
33025
33108
  * Jodit Editor (https://xdsoft.net/jodit/)
33026
33109
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -33037,11 +33120,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33037
33120
 
33038
33121
 
33039
33122
 
33123
+
33040
33124
  const JODIT_IMAGE_PROCESSOR_BINDED = '__jodit_imageprocessor_binded';
33041
33125
  const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33042
33126
  /**
33043
33127
  * Change editor's size after load all images
33044
- */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__.Plugin {
33128
+ */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
33045
33129
  afterInit(jodit) {}
33046
33130
  beforeDestruct(jodit) {
33047
33131
  const buffer = (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.cached)(jodit, 'buffer');
@@ -33079,9 +33163,9 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33079
33163
  if (!editor.editor) {
33080
33164
  return;
33081
33165
  }
33082
- ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.$$)('img', editor.editor).forEach((elm)=>{
33083
- if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33084
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33166
+ ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('img', editor.editor).forEach((elm)=>{
33167
+ if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33168
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33085
33169
  if (!elm.complete) {
33086
33170
  editor.e.on(elm, 'load', function ElementOnLoad() {
33087
33171
  !editor.isInDestruct && editor.e?.fire('resize');
@@ -33092,6 +33176,7 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33092
33176
  replaceDataURIToBlobUUID(editor, elm);
33093
33177
  }
33094
33178
  editor.e.on(elm, 'mousedown touchstart', ()=>{
33179
+ removeCaretText(elm);
33095
33180
  editor.s.select(elm);
33096
33181
  });
33097
33182
  }
@@ -33112,6 +33197,23 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33112
33197
  ]),
33113
33198
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.debounce)()
33114
33199
  ], imageProcessor.prototype, "afterChange", null);
33200
+ /**
33201
+ * Remove the invisible-space text beside an image, which only held a caret.
33202
+ * Selecting the image replaces the caret, and with the text still after a
33203
+ * block image, Safari highlights the rest of the image's line. See #1512
33204
+ */ function removeCaretText(elm) {
33205
+ for (const side of [
33206
+ 'previousSibling',
33207
+ 'nextSibling'
33208
+ ]){
33209
+ let node = elm[side];
33210
+ while(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isText(node) && !node.nodeValue?.replace((0,jodit_core_constants__WEBPACK_IMPORTED_MODULE_1__.INVISIBLE_SPACE_REG_EXP)(), '')){
33211
+ const next = node[side];
33212
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(node);
33213
+ node = next;
33214
+ }
33215
+ }
33216
+ }
33115
33217
  function replaceDataURIToBlobUUID(editor, elm) {
33116
33218
  if (!editor.o.imageProcessor.replaceDataURIToBlobIdInView) {
33117
33219
  return;
@@ -33122,7 +33224,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33122
33224
  const dataUri = elm.src;
33123
33225
  let blob;
33124
33226
  try {
33125
- blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_6__.dataURItoBlob)(dataUri);
33227
+ blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__.dataURItoBlob)(dataUri);
33126
33228
  } catch {
33127
33229
  // A data URI the browser accepts but we cannot decode is not worth
33128
33230
  // breaking the editor over — keep the image as it is
@@ -33135,7 +33237,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33135
33237
  list[elm.src] = dataUri;
33136
33238
  editor.buffer.set(JODIT_IMAGE_BLOB_ID, list);
33137
33239
  }
33138
- jodit_core_global__WEBPACK_IMPORTED_MODULE_3__.pluginSystem.add('imageProcessor', imageProcessor);
33240
+ jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProcessor', imageProcessor);
33139
33241
 
33140
33242
 
33141
33243
  /***/ }),
@@ -33438,7 +33540,7 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProperties
33438
33540
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33439
33541
  /* harmony export */ readAlign: function() { return /* binding */ readAlign; }
33440
33542
  /* harmony export */ });
33441
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80991);
33543
+ /* harmony import */ var jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16849);
33442
33544
  /*!
33443
33545
  * Jodit Editor (https://xdsoft.net/jodit/)
33444
33546
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -33448,20 +33550,9 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProperties
33448
33550
  */
33449
33551
  /**
33450
33552
  * @private
33451
- */ function readAlign(image, values) {
33452
- // Align
33453
- if ((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'float') && [
33454
- 'left',
33455
- 'right'
33456
- ].indexOf((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'float').toLowerCase()) !== -1) {
33457
- values.align = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, 'float');
33458
- } else {
33459
- if ((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, 'display') === 'block' && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'margin-left') === 'auto' && (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'margin-right') === 'auto') {
33460
- values.align = 'center';
33461
- } else {
33462
- values.align = '';
33463
- }
33464
- }
33553
+ */ function readAlign(image, values, classes) {
33554
+ const align = (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_0__.getHAlign)(image, classes);
33555
+ values.align = align === 'normal' ? '' : align;
33465
33556
  }
33466
33557
 
33467
33558
 
@@ -33497,7 +33588,7 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProperties
33497
33588
  * @private
33498
33589
  */ async function readValuesFromImage(j, state) {
33499
33590
  const { sourceImage: image, values } = state;
33500
- (0,_align__WEBPACK_IMPORTED_MODULE_2__.readAlign)(image, values);
33591
+ (0,_align__WEBPACK_IMPORTED_MODULE_2__.readAlign)(image, values, j.o.imageAlignClasses);
33501
33592
  // Border radius
33502
33593
  values.borderRadius = parseInt((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_1__.cssInline)(image, 'border-radius') || '0', 10) || 0;
33503
33594
  // Id
@@ -34538,7 +34629,7 @@ UIImagePositionTab = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__
34538
34629
  (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'id', id || null);
34539
34630
  }
34540
34631
  if (opt.image.editAlign) {
34541
- (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.hAlignElement)(image, align);
34632
+ (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.hAlignElement)(image, align, j.o.imageAlignClasses);
34542
34633
  }
34543
34634
  }
34544
34635
 
@@ -34609,10 +34700,12 @@ UIImagePositionTab = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__
34609
34700
  marginBottom,
34610
34701
  marginLeft
34611
34702
  ];
34703
+ // Compared with the inline value, which is what `readMargins` showed, so a
34704
+ // margin from a stylesheet is not overwritten when the field is unchanged
34612
34705
  const applyMargin = (key, value)=>{
34613
- const oldValue = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key);
34706
+ const oldValue = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, key) || 0);
34614
34707
  const v = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)(value);
34615
- if (oldValue.toString() !== v.toString()) {
34708
+ if (oldValue !== v) {
34616
34709
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key, v);
34617
34710
  }
34618
34711
  };
@@ -35376,6 +35469,10 @@ const cmd = (control)=>control.args && (0,jodit_core_helpers_checker__WEBPACK_IM
35376
35469
 
35377
35470
 
35378
35471
 
35472
+ // Images align with `imageAlignClasses`; the wrappers of iframes and media
35473
+ // keep inline styles
35474
+ const alignClasses = (editor, elm)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, 'img') ? editor.o.imageAlignClasses : null;
35475
+ const currentAlign = (editor, elm)=>elm ? (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.getHAlign)(elm, alignClasses(editor, elm)) : 'normal';
35379
35476
  const align = {
35380
35477
  name: 'left',
35381
35478
  childTemplate: (_, __, value)=>value,
@@ -35385,6 +35482,15 @@ const align = {
35385
35482
  'Center',
35386
35483
  'Normal'
35387
35484
  ],
35485
+ update: (editor, button)=>{
35486
+ const current = currentAlign(editor, button.target);
35487
+ button.state.icon.name = current === 'normal' ? 'left' : current;
35488
+ },
35489
+ isActive: (editor, button)=>currentAlign(editor, button.target) !== 'normal',
35490
+ isChildActive: (editor, button)=>{
35491
+ const [value] = button.control.args ?? [];
35492
+ return (0,jodit_core_helpers_checker_is_string__WEBPACK_IMPORTED_MODULE_1__.isString)(value) && currentAlign(editor, button.target) === value.toLowerCase();
35493
+ },
35388
35494
  exec: (editor, elm, { control })=>{
35389
35495
  if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, new Set([
35390
35496
  'img',
@@ -35397,7 +35503,7 @@ const align = {
35397
35503
  if (!command) {
35398
35504
  return false;
35399
35505
  }
35400
- ;(0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.hAlignElement)(elm, command);
35506
+ ;(0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.hAlignElement)(elm, command, alignClasses(editor, elm));
35401
35507
  if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, new Set([
35402
35508
  'jodit',
35403
35509
  'jodit-media'
@@ -35437,6 +35543,14 @@ const align = {
35437
35543
  'Normal'
35438
35544
  ],
35439
35545
  tooltip: 'Vertical align',
35546
+ // `vertical-align` only moves an image in the line, not a floated or block one
35547
+ isDisabled: (editor, button)=>{
35548
+ const image = button.target;
35549
+ return Boolean(image && ([
35550
+ 'left',
35551
+ 'right'
35552
+ ].includes((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(image, 'float')) || (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(image, 'display') === 'block'));
35553
+ },
35440
35554
  exec: (editor, image, { control })=>{
35441
35555
  if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(image, 'img')) {
35442
35556
  return;