jodit 4.15.15 → 4.15.17

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 (62) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +4 -4
  4. package/es2015/jodit.js +80 -23
  5. package/es2015/jodit.min.js +4 -4
  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 +4 -4
  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 +79 -23
  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 +79 -23
  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 +81 -23
  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 +4 -2
  51. package/esm/core/constants.js +1 -1
  52. package/esm/plugins/clean-html/clean-html.js +4 -1
  53. package/esm/plugins/clean-html/config.d.ts +4 -2
  54. package/esm/plugins/color/config.js +16 -6
  55. package/esm/plugins/focus/focus.js +17 -1
  56. package/esm/plugins/image-processor/image-processor.js +20 -1
  57. package/esm/plugins/image-properties/writers/margin.js +5 -3
  58. package/esm/plugins/inline-popup/config/items/img.js +7 -0
  59. package/esm/plugins/placeholder/placeholder.js +2 -1
  60. package/package.json +1 -1
  61. package/types/config.d.ts +4 -2
  62. package/types/plugins/clean-html/config.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.15.15
4
+ * Version: v4.15.17
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1786,7 +1786,7 @@ __webpack_require__.r(__webpack_exports__);
1786
1786
  * ```
1787
1787
  * @packageDocumentation
1788
1788
  * @module constants
1789
- */ const APP_VERSION = "4.15.15";
1789
+ */ const APP_VERSION = "4.15.17";
1790
1790
  // prettier-ignore
1791
1791
  const ES = "es2015";
1792
1792
  const IS_ES_MODERN = true;
@@ -28737,7 +28737,10 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
28737
28737
  if (!this.j.o.cleanHTML.collapseEmptyValueToEmptyString) {
28738
28738
  return;
28739
28739
  }
28740
- if (/^<([a-z][a-z0-9]*)\b[^>]*>(?:<br\/?>)?<\/\1>$/i.test(data.value.trim())) {
28740
+ // Only a text block can be an empty caret container; a lone video,
28741
+ // iframe or icon has no children but is content in itself
28742
+ const lone = /^<([a-z][a-z0-9]*)\b[^>]*>(?:<br\/?>)?<\/\1>$/i.exec(data.value.trim());
28743
+ if (lone && /^(p|div|h[1-6]|blockquote|pre)$/i.test(lone[1])) {
28741
28744
  data.value = '';
28742
28745
  }
28743
28746
  }
@@ -30027,6 +30030,15 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_0__.pluginSystem.add('color', color);
30027
30030
 
30028
30031
 
30029
30032
  jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_2__.Icon.set('brush', (_brush_svg__WEBPACK_IMPORTED_MODULE_5___default()));
30033
+ /**
30034
+ * Set a color style; an empty value removes it, and with it the `style`
30035
+ * attribute once nothing else is left in it
30036
+ */ function setColorStyle(elm, key, value) {
30037
+ (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(elm, key, value);
30038
+ if (!(0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style')) {
30039
+ (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'style', null);
30040
+ }
30041
+ }
30030
30042
  jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.brushCell = {
30031
30043
  isVisible: (editor)=>{
30032
30044
  return !editor.o.disablePlugins.includes('color');
@@ -30042,7 +30054,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.brushCell =
30042
30054
  }
30043
30055
  const makeColorPicker = (key)=>(0,jodit_modules_widget__WEBPACK_IMPORTED_MODULE_4__.ColorPickerWidget)(editor, (value)=>{
30044
30056
  selected.forEach((cell)=>{
30045
- ;(0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(cell, key, value);
30057
+ setColorStyle(cell, key, value);
30046
30058
  });
30047
30059
  editor.lock();
30048
30060
  editor.synchronizeValues();
@@ -30128,7 +30140,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.brush = {
30128
30140
  if (!currentElement) {
30129
30141
  editor.execCommand('background', false, value);
30130
30142
  } else {
30131
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(currentElement, 'backgroundColor', value);
30143
+ setColorStyle(currentElement, 'backgroundColor', value);
30132
30144
  }
30133
30145
  ;(0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.dataBind)(button, 'color', value);
30134
30146
  (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.dataBind)(button, 'color-mode', 'background');
@@ -30138,7 +30150,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.brush = {
30138
30150
  if (!currentElement) {
30139
30151
  editor.execCommand('forecolor', false, value);
30140
30152
  } else {
30141
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(currentElement, 'color', value);
30153
+ setColorStyle(currentElement, 'color', value);
30142
30154
  }
30143
30155
  ;(0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.dataBind)(button, 'color', value);
30144
30156
  (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.dataBind)(button, 'color-mode', 'color');
@@ -30167,10 +30179,10 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.brush = {
30167
30179
  if (current && current !== jodit.editor && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isNode(current) && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isElement(current)) {
30168
30180
  switch(mode){
30169
30181
  case 'color':
30170
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(current, 'color', color);
30182
+ setColorStyle(current, 'color', color);
30171
30183
  break;
30172
30184
  case 'background':
30173
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_1__.css)(current, 'backgroundColor', color);
30185
+ setColorStyle(current, 'backgroundColor', color);
30174
30186
  break;
30175
30187
  }
30176
30188
  } else {
@@ -32192,14 +32204,28 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_1__.pluginSystem.add('file', file);
32192
32204
  */ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.saveSelectionOnBlur = true;
32193
32205
  function focus(editor) {
32194
32206
  if (editor.o.saveSelectionOnBlur) {
32207
+ // A click that brings focus back places the caret itself, and Chrome
32208
+ // has already placed it when focus fires, so restoring would move it
32209
+ // back to the old selection. The saved markers are dropped instead.
32210
+ let focusByPointer = false;
32195
32211
  editor.e.on('blur', ()=>{
32212
+ // A press that never brought the focus back must not decide
32213
+ // what the next focus does
32214
+ focusByPointer = false;
32196
32215
  if (editor.isEditorMode()) {
32197
32216
  editor.s.save(true);
32198
32217
  }
32218
+ }).on('mousedown touchstart', ()=>{
32219
+ focusByPointer = !editor.editorIsActive;
32199
32220
  }).on('focus', ()=>{
32200
32221
  if (editor.isEditorMode()) {
32201
- editor.s.restore();
32222
+ if (focusByPointer) {
32223
+ editor.s.removeMarkers();
32224
+ } else {
32225
+ editor.s.restore();
32226
+ }
32202
32227
  }
32228
+ focusByPointer = false;
32203
32229
  });
32204
32230
  }
32205
32231
  const focus = ()=>{
@@ -33239,11 +33265,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33239
33265
  /* harmony import */ var _swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31635);
33240
33266
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81937);
33241
33267
  /* harmony import */ var jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(84839);
33242
- /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28077);
33243
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(65946);
33244
- /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(91206);
33245
- /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(23112);
33246
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(51034);
33268
+ /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23211);
33269
+ /* harmony import */ var jodit_core_global__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(28077);
33270
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(65946);
33271
+ /* harmony import */ var jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(91206);
33272
+ /* harmony import */ var jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(23112);
33273
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(51034);
33247
33274
  /*!
33248
33275
  * Jodit Editor (https://xdsoft.net/jodit/)
33249
33276
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -33261,11 +33288,12 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33261
33288
 
33262
33289
 
33263
33290
 
33291
+
33264
33292
  const JODIT_IMAGE_PROCESSOR_BINDED = '__jodit_imageprocessor_binded';
33265
33293
  const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33266
33294
  /**
33267
33295
  * Change editor's size after load all images
33268
- */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
33296
+ */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
33269
33297
  afterInit(jodit) {}
33270
33298
  beforeDestruct(jodit) {
33271
33299
  const buffer = (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.cached)(jodit, 'buffer');
@@ -33304,9 +33332,9 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33304
33332
  if (!editor.editor) {
33305
33333
  return;
33306
33334
  }
33307
- ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('img', editor.editor).forEach((elm)=>{
33308
- if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33309
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33335
+ ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.$$)('img', editor.editor).forEach((elm)=>{
33336
+ if (!(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED)) {
33337
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.dataBind)(elm, JODIT_IMAGE_PROCESSOR_BINDED, true);
33310
33338
  if (!elm.complete) {
33311
33339
  editor.e.on(elm, 'load', function ElementOnLoad() {
33312
33340
  var _editor_e;
@@ -33318,6 +33346,7 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33318
33346
  replaceDataURIToBlobUUID(editor, elm);
33319
33347
  }
33320
33348
  editor.e.on(elm, 'mousedown touchstart', ()=>{
33349
+ removeCaretText(elm);
33321
33350
  editor.s.select(elm);
33322
33351
  });
33323
33352
  }
@@ -33339,6 +33368,24 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33339
33368
  ]),
33340
33369
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.debounce)()
33341
33370
  ], imageProcessor.prototype, "afterChange", null);
33371
+ /**
33372
+ * Remove the invisible-space text beside an image, which only held a caret.
33373
+ * Selecting the image replaces the caret, and with the text still after a
33374
+ * block image, Safari highlights the rest of the image's line. See #1512
33375
+ */ function removeCaretText(elm) {
33376
+ for (const side of [
33377
+ 'previousSibling',
33378
+ 'nextSibling'
33379
+ ]){
33380
+ var _node_nodeValue;
33381
+ let node = elm[side];
33382
+ 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)(), ''))){
33383
+ const next = node[side];
33384
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.safeRemove(node);
33385
+ node = next;
33386
+ }
33387
+ }
33388
+ }
33342
33389
  function replaceDataURIToBlobUUID(editor, elm) {
33343
33390
  if (!editor.o.imageProcessor.replaceDataURIToBlobIdInView) {
33344
33391
  return;
@@ -33349,7 +33396,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33349
33396
  const dataUri = elm.src;
33350
33397
  let blob;
33351
33398
  try {
33352
- blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_7__.dataURItoBlob)(dataUri);
33399
+ blob = (0,jodit_modules_uploader_helpers_data_uri_to_blob__WEBPACK_IMPORTED_MODULE_8__.dataURItoBlob)(dataUri);
33353
33400
  } catch (unused) {
33354
33401
  // A data URI the browser accepts but we cannot decode is not worth
33355
33402
  // breaking the editor over — keep the image as it is
@@ -33362,7 +33409,7 @@ function replaceDataURIToBlobUUID(editor, elm) {
33362
33409
  list[elm.src] = dataUri;
33363
33410
  editor.buffer.set(JODIT_IMAGE_BLOB_ID, list);
33364
33411
  }
33365
- jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('imageProcessor', imageProcessor);
33412
+ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('imageProcessor', imageProcessor);
33366
33413
 
33367
33414
 
33368
33415
  /***/ }),
@@ -34856,10 +34903,12 @@ UIImagePositionTab = (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__
34856
34903
  marginBottom,
34857
34904
  marginLeft
34858
34905
  ];
34906
+ // Compared with the inline value, which is what `readMargins` showed, so a
34907
+ // margin from a stylesheet is not overwritten when the field is unchanged
34859
34908
  const applyMargin = (key, value)=>{
34860
- const oldValue = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key);
34909
+ const oldValue = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.cssInline)(image, key) || 0);
34861
34910
  const v = (0,_utils_utils__WEBPACK_IMPORTED_MODULE_1__.normalSizeToString)(value);
34862
- if (oldValue.toString() !== v.toString()) {
34911
+ if (oldValue !== v) {
34863
34912
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_0__.css)(image, key, v);
34864
34913
  }
34865
34914
  };
@@ -35687,6 +35736,14 @@ const align = {
35687
35736
  'Normal'
35688
35737
  ],
35689
35738
  tooltip: 'Vertical align',
35739
+ // `vertical-align` only moves an image in the line, not a floated or block one
35740
+ isDisabled: (editor, button)=>{
35741
+ const image = button.target;
35742
+ return Boolean(image && ([
35743
+ 'left',
35744
+ 'right'
35745
+ ].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'));
35746
+ },
35690
35747
  exec: (editor, image, { control })=>{
35691
35748
  if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(image, 'img')) {
35692
35749
  return;
@@ -38945,7 +39002,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.useInputsPlaceholder
38945
39002
  this.placeholderElm.innerHTML = (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_7__.attr)(editor.element, 'placeholder') || '';
38946
39003
  }
38947
39004
  editor.e.fire('placeholder', this.placeholderElm.innerHTML);
38948
- 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', this.toggle).on(window, 'load', this.toggle);
39005
+ 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', this.toggle).on(window, 'load', this.toggle);
38949
39006
  this.addNativeListeners();
38950
39007
  this.toggle();
38951
39008
  });