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/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.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
  *
@@ -1786,7 +1805,7 @@ __webpack_require__.r(__webpack_exports__);
1786
1805
  * ```
1787
1806
  * @packageDocumentation
1788
1807
  * @module constants
1789
- */ const APP_VERSION = "4.15.16";
1808
+ */ const APP_VERSION = "4.15.18";
1790
1809
  // prettier-ignore
1791
1810
  const ES = "es2015";
1792
1811
  const IS_ES_MODERN = true;
@@ -7562,6 +7581,7 @@ function trimChars(value, chars) {
7562
7581
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7563
7582
  /* harmony export */ alignElement: function() { return /* binding */ alignElement; },
7564
7583
  /* harmony export */ clearAlign: function() { return /* binding */ clearAlign; },
7584
+ /* harmony export */ getHAlign: function() { return /* binding */ getHAlign; },
7565
7585
  /* harmony export */ hAlignElement: function() { return /* binding */ hAlignElement; }
7566
7586
  /* harmony export */ });
7567
7587
  /* harmony import */ var jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27795);
@@ -7576,9 +7596,26 @@ function trimChars(value, chars) {
7576
7596
  */
7577
7597
 
7578
7598
 
7599
+ const classNames = (value)=>(value !== null && value !== void 0 ? value : '').split(/\s+/).filter(Boolean);
7579
7600
  /**
7580
- * Align image
7581
- */ function hAlignElement(image, align) {
7601
+ * Align image, with `classes` (see `imageAlignClasses`) instead of inline
7602
+ * styles when they are given
7603
+ */ function hAlignElement(image, align, classes) {
7604
+ if (classes) {
7605
+ hAlignElement(image, 'normal');
7606
+ Object.values(classes).forEach((value)=>image.classList.remove(...classNames(value)));
7607
+ image.classList.add(...classNames(classes[align || 'normal']));
7608
+ [
7609
+ 'class',
7610
+ 'style'
7611
+ ].forEach((name)=>{
7612
+ var _attr;
7613
+ if (!((_attr = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, name)) === null || _attr === void 0 ? void 0 : _attr.trim())) {
7614
+ (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(image, name, null);
7615
+ }
7616
+ });
7617
+ return;
7618
+ }
7582
7619
  if (align && align !== 'normal') {
7583
7620
  if (align !== 'center') {
7584
7621
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.css)(image, 'float', align);
@@ -7601,6 +7638,31 @@ function trimChars(value, chars) {
7601
7638
  ;(0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.clearCenterAlign)(image);
7602
7639
  }
7603
7640
  }
7641
+ /**
7642
+ * The alignment `hAlignElement` has set on an element
7643
+ */ function getHAlign(elm, classes) {
7644
+ if (classes) {
7645
+ for (const align of [
7646
+ 'left',
7647
+ 'right',
7648
+ 'center',
7649
+ 'normal'
7650
+ ]){
7651
+ const names = classNames(classes[align]);
7652
+ if (names.length && names.every((name)=>elm.classList.contains(name))) {
7653
+ return align;
7654
+ }
7655
+ }
7656
+ }
7657
+ const float = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.cssInline)(elm, 'float').toLowerCase();
7658
+ if (float === 'left' || float === 'right') {
7659
+ return float;
7660
+ }
7661
+ 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') {
7662
+ return 'center';
7663
+ }
7664
+ return 'normal';
7665
+ }
7604
7666
  /**
7605
7667
  * Remove text-align style for all selected children
7606
7668
  */ function clearAlign(node) {
@@ -8764,6 +8826,7 @@ __webpack_require__.r(__webpack_exports__);
8764
8826
  /* harmony export */ get: function() { return /* reexport safe */ _get__WEBPACK_IMPORTED_MODULE_15__.get; },
8765
8827
  /* harmony export */ getClassName: function() { return /* reexport safe */ _get_class_name__WEBPACK_IMPORTED_MODULE_16__.getClassName; },
8766
8828
  /* harmony export */ getDataTransfer: function() { return /* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_27__.getDataTransfer; },
8829
+ /* harmony export */ getHAlign: function() { return /* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_0__.getHAlign; },
8767
8830
  /* harmony export */ getPropertyDescriptor: function() { return /* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_27__.getPropertyDescriptor; },
8768
8831
  /* harmony export */ getXPathByElement: function() { return /* reexport safe */ _selector__WEBPACK_IMPORTED_MODULE_24__.getXPathByElement; },
8769
8832
  /* harmony export */ hAlignElement: function() { return /* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_0__.hAlignElement; },
@@ -8794,7 +8857,7 @@ __webpack_require__.r(__webpack_exports__);
8794
8857
  /* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(28712);
8795
8858
  /* harmony import */ var _assert__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_assert__WEBPACK_IMPORTED_MODULE_2__);
8796
8859
  /* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
8797
- /* 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__)
8860
+ /* 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__)
8798
8861
  /* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
8799
8862
  /* harmony import */ var _attr__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7909);
8800
8863
  /* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26136);
@@ -10721,11 +10784,12 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10721
10784
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
10722
10785
  /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
10723
10786
  /* harmony import */ var jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(28686);
10724
- /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(28712);
10725
- /* 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__);
10726
- /* harmony import */ var jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(7470);
10727
- /* harmony import */ var _style_commit_style__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(84578);
10728
- /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(42259);
10787
+ /* harmony import */ var jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16849);
10788
+ /* harmony import */ var jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(28712);
10789
+ /* 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__);
10790
+ /* harmony import */ var jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7470);
10791
+ /* harmony import */ var _style_commit_style__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(84578);
10792
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(42259);
10729
10793
  /*!
10730
10794
  * Jodit Editor (https://xdsoft.net/jodit/)
10731
10795
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -10747,6 +10811,7 @@ function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild,
10747
10811
 
10748
10812
 
10749
10813
 
10814
+
10750
10815
  class Selection {
10751
10816
  /**
10752
10817
  * Short alias for this.jodit
@@ -11187,7 +11252,7 @@ class Selection {
11187
11252
  return node;
11188
11253
  }
11189
11254
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node)) {
11190
- const ret = (0,_helpers__WEBPACK_IMPORTED_MODULE_10__.findCorrectCurrentNode)(node, range, rightMode, sel.isCollapsed, checkChild, child);
11255
+ const ret = (0,_helpers__WEBPACK_IMPORTED_MODULE_11__.findCorrectCurrentNode)(node, range, rightMode, sel.isCollapsed, checkChild, child);
11191
11256
  node = ret.node;
11192
11257
  rightMode = ret.rightMode;
11193
11258
  }
@@ -11331,6 +11396,10 @@ class Selection {
11331
11396
  if (styles && typeof styles === 'object') {
11332
11397
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(image, styles);
11333
11398
  }
11399
+ const { imageDefaultAlign, imageAlignClasses } = this.j.o;
11400
+ if (imageDefaultAlign && imageDefaultAlign !== 'normal') {
11401
+ (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_7__.hAlignElement)(image, imageDefaultAlign, imageAlignClasses);
11402
+ }
11334
11403
  const onload = ()=>{
11335
11404
  if (image.naturalHeight < image.offsetHeight || image.naturalWidth < image.offsetWidth) {
11336
11405
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(image, {
@@ -11455,7 +11524,7 @@ class Selection {
11455
11524
  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));
11456
11525
  // check right offset
11457
11526
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
11458
- if ((0,_helpers__WEBPACK_IMPORTED_MODULE_10__.cursorInTheEdgeOfString)(container, offset, start, end)) {
11527
+ if ((0,_helpers__WEBPACK_IMPORTED_MODULE_11__.cursorInTheEdgeOfString)(container, offset, start, end)) {
11459
11528
  return false;
11460
11529
  }
11461
11530
  } else {
@@ -11850,8 +11919,8 @@ class Selection {
11850
11919
  * }) // will remove `color:red` from `span`
11851
11920
  * ```
11852
11921
  */ commitStyle(options) {
11853
- ;(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');
11854
- const styleElm = new _style_commit_style__WEBPACK_IMPORTED_MODULE_9__.CommitStyle(options);
11922
+ ;(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');
11923
+ const styleElm = new _style_commit_style__WEBPACK_IMPORTED_MODULE_10__.CommitStyle(options);
11855
11924
  styleElm.apply(this.j);
11856
11925
  }
11857
11926
  /**
@@ -11901,7 +11970,7 @@ class Selection {
11901
11970
  }
11902
11971
  const fragment = leftRange.extractContents();
11903
11972
  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));
11904
- (0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_7__.assert)(currentBox.parentNode, 'Splitting fails');
11973
+ (0,jodit_core_helpers_utils_assert__WEBPACK_IMPORTED_MODULE_8__.assert)(currentBox.parentNode, 'Splitting fails');
11905
11974
  try {
11906
11975
  clearEmpties(fragment);
11907
11976
  clearEmpties(currentBox);
@@ -11954,7 +12023,7 @@ class Selection {
11954
12023
  const r = range.cloneRange();
11955
12024
  r.collapse(start);
11956
12025
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeInsertNode(r, fake);
11957
- (0,jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_8__.moveTheNodeAlongTheEdgeOutward)(fake, start, this.j.editor);
12026
+ (0,jodit_core_selection_helpers_move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_9__.moveTheNodeAlongTheEdgeOutward)(fake, start, this.j.editor);
11958
12027
  return fake;
11959
12028
  };
11960
12029
  const leftFake = moveMaxEdgeFake(true);
@@ -32204,14 +32273,28 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_1__.pluginSystem.add('file', file);
32204
32273
  */ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.saveSelectionOnBlur = true;
32205
32274
  function focus(editor) {
32206
32275
  if (editor.o.saveSelectionOnBlur) {
32276
+ // A click that brings focus back places the caret itself, and Chrome
32277
+ // has already placed it when focus fires, so restoring would move it
32278
+ // back to the old selection. The saved markers are dropped instead.
32279
+ let focusByPointer = false;
32207
32280
  editor.e.on('blur', ()=>{
32281
+ // A press that never brought the focus back must not decide
32282
+ // what the next focus does
32283
+ focusByPointer = false;
32208
32284
  if (editor.isEditorMode()) {
32209
32285
  editor.s.save(true);
32210
32286
  }
32287
+ }).on('mousedown touchstart', ()=>{
32288
+ focusByPointer = !editor.editorIsActive;
32211
32289
  }).on('focus', ()=>{
32212
32290
  if (editor.isEditorMode()) {
32213
- editor.s.restore();
32291
+ if (focusByPointer) {
32292
+ editor.s.removeMarkers();
32293
+ } else {
32294
+ editor.s.restore();
32295
+ }
32214
32296
  }
32297
+ focusByPointer = false;
32215
32298
  });
32216
32299
  }
32217
32300
  const focus = ()=>{
@@ -33251,11 +33334,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33251
33334
  /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635);
33252
33335
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81937);
33253
33336
  /* harmony import */ var jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(84839);
33254
- /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28077);
33255
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
33256
- /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(91206);
33257
- /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(23112);
33258
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(51034);
33337
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
33338
+ /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28077);
33339
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(65946);
33340
+ /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(91206);
33341
+ /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(23112);
33342
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(51034);
33259
33343
  /*!
33260
33344
  * Jodit Editor (https://xdsoft.net/jodit/)
33261
33345
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -33273,11 +33357,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33273
33357
 
33274
33358
 
33275
33359
 
33360
+
33276
33361
  const JODIT_IMAGE_PROCESSOR_BINDED = '__jodit_imageprocessor_binded';
33277
33362
  const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33278
33363
  /**
33279
33364
  * Change editor's size after load all images
33280
- */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
33365
+ */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
33281
33366
  afterInit(jodit) {}
33282
33367
  beforeDestruct(jodit) {
33283
33368
  const buffer = (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.cached)(jodit, 'buffer');
@@ -33316,9 +33401,9 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33316
33401
  if (!editor.editor) {
33317
33402
  return;
33318
33403
  }
33319
- ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('img', editor.editor).forEach((elm)=>{
33320
- if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33321
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33404
+ ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.$$)('img', editor.editor).forEach((elm)=>{
33405
+ if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33406
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33322
33407
  if (!elm.complete) {
33323
33408
  editor.e.on(elm, 'load', function ElementOnLoad() {
33324
33409
  var _editor_e;
@@ -33330,6 +33415,7 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33330
33415
  replaceDataURIToBlobUUID(editor, elm);
33331
33416
  }
33332
33417
  editor.e.on(elm, 'mousedown touchstart', ()=>{
33418
+ removeCaretText(elm);
33333
33419
  editor.s.select(elm);
33334
33420
  });
33335
33421
  }
@@ -33351,6 +33437,24 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33351
33437
  ]),
33352
33438
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.debounce)()
33353
33439
  ], imageProcessor.prototype, "afterChange", null);
33440
+ /**
33441
+ * Remove the invisible-space text beside an image, which only held a caret.
33442
+ * Selecting the image replaces the caret, and with the text still after a
33443
+ * block image, Safari highlights the rest of the image's line. See #1512
33444
+ */ function removeCaretText(elm) {
33445
+ for (const side of [
33446
+ 'previousSibling',
33447
+ 'nextSibling'
33448
+ ]){
33449
+ var _node_nodeValue;
33450
+ let node = elm[side];
33451
+ while(jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(node) && !((_node_nodeValue = node.nodeValue) === null || _node_nodeValue === void 0 ? void 0 : _node_nodeValue.replace((0,jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.INVISIBLE_SPACE_REG_EXP)(), ''))){
33452
+ const next = node[side];
33453
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(node);
33454
+ node = next;
33455
+ }
33456
+ }
33457
+ }
33354
33458
  function replaceDataURIToBlobUUID(editor, elm) {
33355
33459
  if (!editor.o.imageProcessor.replaceDataURIToBlobIdInView) {
33356
33460
  return;
@@ -33361,7 +33465,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33361
33465
  const dataUri = elm.src;
33362
33466
  let blob;
33363
33467
  try {
33364
- blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__.dataURItoBlob)(dataUri);
33468
+ blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_8__.dataURItoBlob)(dataUri);
33365
33469
  } catch (unused) {
33366
33470
  // A data URI the browser accepts but we cannot decode is not worth
33367
33471
  // breaking the editor over — keep the image as it is
@@ -33374,7 +33478,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33374
33478
  list[elm.src] = dataUri;
33375
33479
  editor.buffer.set(JODIT_IMAGE_BLOB_ID, list);
33376
33480
  }
33377
- jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProcessor', imageProcessor);
33481
+ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('imageProcessor', imageProcessor);
33378
33482
 
33379
33483
 
33380
33484
  /***/ }),
@@ -33683,7 +33787,7 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('imageProperties
33683
33787
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
33684
33788
  /* harmony export */ readAlign: function() { return /* binding */ readAlign; }
33685
33789
  /* harmony export */ });
33686
- /* harmony import */ var jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80991);
33790
+ /* harmony import */ var jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16849);
33687
33791
  /*!
33688
33792
  * Jodit Editor (https://xdsoft.net/jodit/)
33689
33793
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -33693,20 +33797,9 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('imageProperties
33693
33797
  */
33694
33798
  /**
33695
33799
  * @private
33696
- */ function readAlign(image, values) {
33697
- // Align
33698
- if ((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'float') && [
33699
- 'left',
33700
- 'right'
33701
- ].indexOf((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, 'float').toLowerCase()) !== -1) {
33702
- values.align = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, 'float');
33703
- } else {
33704
- 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') {
33705
- values.align = 'center';
33706
- } else {
33707
- values.align = '';
33708
- }
33709
- }
33800
+ */ function readAlign(image, values, classes) {
33801
+ const align = (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_0__.getHAlign)(image, classes);
33802
+ values.align = align === 'normal' ? '' : align;
33710
33803
  }
33711
33804
 
33712
33805
 
@@ -33745,7 +33838,7 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('imageProperties
33745
33838
  */ function readValuesFromImage(j, state) {
33746
33839
  return (0,_swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__._)(function*() {
33747
33840
  const { sourceImage: image, values } = state;
33748
- (0,_align__WEBPACK_IMPORTED_MODULE_3__.readAlign)(image, values);
33841
+ (0,_align__WEBPACK_IMPORTED_MODULE_3__.readAlign)(image, values, j.o.imageAlignClasses);
33749
33842
  // Border radius
33750
33843
  values.borderRadius = parseInt((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_2__.cssInline)(image, 'border-radius') || '0', 10) || 0;
33751
33844
  // Id
@@ -34797,7 +34890,7 @@ UIImagePositionTab = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__
34797
34890
  (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(image, 'id', id || null);
34798
34891
  }
34799
34892
  if (opt.image.editAlign) {
34800
- (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.hAlignElement)(image, align);
34893
+ (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.hAlignElement)(image, align, j.o.imageAlignClasses);
34801
34894
  }
34802
34895
  }
34803
34896
 
@@ -34868,10 +34961,12 @@ UIImagePositionTab = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__
34868
34961
  marginBottom,
34869
34962
  marginLeft
34870
34963
  ];
34964
+ // Compared with the inline value, which is what `readMargins` showed, so a
34965
+ // margin from a stylesheet is not overwritten when the field is unchanged
34871
34966
  const applyMargin = (key, value)=>{
34872
- const oldValue = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key);
34967
+ const oldValue = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, key) || 0);
34873
34968
  const v = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)(value);
34874
- if (oldValue.toString() !== v.toString()) {
34969
+ if (oldValue !== v) {
34875
34970
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key, v);
34876
34971
  }
34877
34972
  };
@@ -35638,6 +35733,10 @@ const cmd = (control)=>control.args && (0,jodit_core_helpers_checker__WEBPACK_IM
35638
35733
 
35639
35734
 
35640
35735
 
35736
+ // Images align with `imageAlignClasses`; the wrappers of iframes and media
35737
+ // keep inline styles
35738
+ const alignClasses = (editor, elm)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, 'img') ? editor.o.imageAlignClasses : null;
35739
+ const currentAlign = (editor, elm)=>elm ? (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.getHAlign)(elm, alignClasses(editor, elm)) : 'normal';
35641
35740
  const align = {
35642
35741
  name: 'left',
35643
35742
  childTemplate: (_, __, value)=>value,
@@ -35647,6 +35746,16 @@ const align = {
35647
35746
  'Center',
35648
35747
  'Normal'
35649
35748
  ],
35749
+ update: (editor, button)=>{
35750
+ const current = currentAlign(editor, button.target);
35751
+ button.state.icon.name = current === 'normal' ? 'left' : current;
35752
+ },
35753
+ isActive: (editor, button)=>currentAlign(editor, button.target) !== 'normal',
35754
+ isChildActive: (editor, button)=>{
35755
+ var _button_control_args;
35756
+ const [value] = (_button_control_args = button.control.args) !== null && _button_control_args !== void 0 ? _button_control_args : [];
35757
+ return (0,jodit_core_helpers_checker_is_string__WEBPACK_IMPORTED_MODULE_1__.isString)(value) && currentAlign(editor, button.target) === value.toLowerCase();
35758
+ },
35650
35759
  exec: (editor, elm, { control })=>{
35651
35760
  if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, new Set([
35652
35761
  'img',
@@ -35659,7 +35768,7 @@ const align = {
35659
35768
  if (!command) {
35660
35769
  return false;
35661
35770
  }
35662
- ;(0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.hAlignElement)(elm, command);
35771
+ ;(0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.hAlignElement)(elm, command, alignClasses(editor, elm));
35663
35772
  if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, new Set([
35664
35773
  'jodit',
35665
35774
  'jodit-media'
@@ -35699,6 +35808,14 @@ const align = {
35699
35808
  'Normal'
35700
35809
  ],
35701
35810
  tooltip: 'Vertical align',
35811
+ // `vertical-align` only moves an image in the line, not a floated or block one
35812
+ isDisabled: (editor, button)=>{
35813
+ const image = button.target;
35814
+ return Boolean(image && ([
35815
+ 'left',
35816
+ 'right'
35817
+ ].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'));
35818
+ },
35702
35819
  exec: (editor, image, { control })=>{
35703
35820
  if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(image, 'img')) {
35704
35821
  return;