jodit 4.16.0 → 4.17.0

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 (80) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/es2015/jodit.css +11 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +7 -7
  5. package/es2015/jodit.js +176 -33
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +7 -7
  8. package/es2015/plugins/debug/debug.css +1 -1
  9. package/es2015/plugins/debug/debug.js +1 -1
  10. package/es2015/plugins/debug/debug.min.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +7 -7
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +7 -7
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  20. package/es2021/jodit.css +11 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +7 -7
  23. package/es2021/jodit.js +168 -32
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +7 -7
  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 +11 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +7 -7
  35. package/es2021.en/jodit.js +168 -32
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +7 -7
  38. package/es2021.en/plugins/debug/debug.css +1 -1
  39. package/es2021.en/plugins/debug/debug.js +1 -1
  40. package/es2021.en/plugins/debug/debug.min.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  42. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  44. package/es5/jodit.css +15 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +188 -33
  48. package/es5/jodit.min.css +3 -3
  49. package/es5/jodit.min.js +2 -2
  50. package/es5/plugins/debug/debug.css +1 -1
  51. package/es5/plugins/debug/debug.js +1 -1
  52. package/es5/plugins/debug/debug.min.js +1 -1
  53. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  56. package/es5/polyfills.fat.min.js +1 -1
  57. package/es5/polyfills.js +1 -1
  58. package/es5/polyfills.min.js +1 -1
  59. package/esm/config.d.ts +40 -1
  60. package/esm/core/constants.js +1 -1
  61. package/esm/modules/widget/file-selector/file-selector.d.ts +10 -1
  62. package/esm/modules/widget/file-selector/file-selector.js +30 -18
  63. package/esm/plugins/file/file.d.ts +24 -1
  64. package/esm/plugins/file/file.js +17 -1
  65. package/esm/plugins/iframe/config.js +4 -0
  66. package/esm/plugins/image-processor/image-processor.d.ts +5 -0
  67. package/esm/plugins/image-processor/image-processor.js +29 -2
  68. package/esm/plugins/inline-popup/config/items/img.js +22 -1
  69. package/esm/plugins/source/editor/engines/ace.js +2 -1
  70. package/esm/plugins/source/source.d.ts +17 -0
  71. package/esm/plugins/source/source.js +58 -10
  72. package/esm/plugins/video/config.d.ts +21 -1
  73. package/esm/plugins/video/config.js +22 -2
  74. package/package.json +1 -1
  75. package/types/config.d.ts +40 -1
  76. package/types/modules/widget/file-selector/file-selector.d.ts +10 -1
  77. package/types/plugins/file/file.d.ts +24 -1
  78. package/types/plugins/image-processor/image-processor.d.ts +5 -0
  79. package/types/plugins/source/source.d.ts +17 -0
  80. package/types/plugins/video/config.d.ts +21 -1
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.16.0
4
+ * Version: v4.17.0
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1799,7 +1799,7 @@ __webpack_require__.r(__webpack_exports__);
1799
1799
  * ```
1800
1800
  * @packageDocumentation
1801
1801
  * @module constants
1802
- */ const APP_VERSION = "4.16.0";
1802
+ */ const APP_VERSION = "4.17.0";
1803
1803
  // prettier-ignore
1804
1804
  const ES = "es2021";
1805
1805
  const IS_ES_MODERN = true;
@@ -26195,22 +26195,19 @@ jodit_core_ui__WEBPACK_IMPORTED_MODULE_2__.Icon.set('palette', (_palette_svg__WE
26195
26195
  const tabs = [];
26196
26196
  const options = editor.o.uploader;
26197
26197
  if (callbacks.upload && options.showTabInFileSelector !== false && (options.url || options.insertImageAsBase64URI || options.customUploadFunction)) {
26198
- const dragBox = editor.c.fromHTML('<div class="jodit-drag-and-drop__file-box">' + `<strong>${editor.i18n(isImage ? 'Drop image' : 'Drop file')}</strong>` + `<span><br>${editor.i18n('or click')}</span>` + `<input type="file" accept="${isImage ? 'image/*' : '*'}" tabindex="-1" dir="auto" multiple=""/>` + '</div>');
26199
- editor.uploader.bind(dragBox, (resp)=>{
26200
- const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(callbacks.upload) ? callbacks.upload : options.defaultHandlerSuccess;
26198
+ const { upload } = callbacks;
26199
+ tabs.push(UploadTab(editor, (resp)=>{
26200
+ const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(upload) ? upload : options.defaultHandlerSuccess;
26201
26201
  if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handler)) {
26202
26202
  handler.call(editor, resp);
26203
26203
  }
26204
- editor.e.fire('closeAllPopups');
26205
- }, (error)=>{
26206
- editor.message.error(error.message);
26207
- editor.e.fire('closeAllPopups');
26208
- });
26209
- tabs.push({
26210
- icon: 'upload',
26211
- name: 'Upload',
26212
- content: dragBox
26213
- });
26204
+ }, isImage ? {
26205
+ label: 'Drop image',
26206
+ accept: 'image/*'
26207
+ } : {
26208
+ label: 'Drop file',
26209
+ accept: '*'
26210
+ }));
26214
26211
  }
26215
26212
  if (callbacks.filebrowser) {
26216
26213
  if (editor.o.filebrowser.ajax.url || editor.o.filebrowser.items.url) {
@@ -26278,6 +26275,24 @@ jodit_core_ui__WEBPACK_IMPORTED_MODULE_2__.Icon.set('palette', (_palette_svg__WE
26278
26275
  box.classList.add('jodit-file-selector');
26279
26276
  return box;
26280
26277
  };
26278
+ /**
26279
+ * The Upload tab: a box that uploads the files dropped on it or chosen in its
26280
+ * file input, then passes the uploader's answer to `onSuccess` and closes the popup
26281
+ */ const UploadTab = (editor, onSuccess, { label, accept })=>{
26282
+ const dragBox = editor.c.fromHTML('<div class="jodit-drag-and-drop__file-box">' + `<strong>${editor.i18n(label)}</strong>` + `<span><br>${editor.i18n('or click')}</span>` + `<input type="file" accept="${accept}" tabindex="-1" dir="auto" multiple=""/>` + '</div>');
26283
+ editor.uploader.bind(dragBox, (resp)=>{
26284
+ onSuccess.call(editor, resp);
26285
+ editor.e.fire('closeAllPopups');
26286
+ }, (error)=>{
26287
+ editor.message.error(error.message);
26288
+ editor.e.fire('closeAllPopups');
26289
+ });
26290
+ return {
26291
+ icon: 'upload',
26292
+ name: 'Upload',
26293
+ content: dragBox
26294
+ };
26295
+ };
26281
26296
  function val(elm, name, value) {
26282
26297
  const child = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.first(elm, (node)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(node, 'input') && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.attr)(node, 'name') === name);
26283
26298
  if (!child) {
@@ -26290,7 +26305,8 @@ function val(elm, name, value) {
26290
26305
  }
26291
26306
 
26292
26307
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
26293
- /* harmony export */ "FileSelectorWidget", 0, /* binding */ FileSelectorWidget
26308
+ /* harmony export */ "FileSelectorWidget", 0, /* binding */ FileSelectorWidget,
26309
+ /* harmony export */ "UploadTab", 0, /* binding */ UploadTab
26294
26310
  /* harmony export */ ]);
26295
26311
 
26296
26312
 
@@ -26303,7 +26319,8 @@ function val(elm, name, value) {
26303
26319
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
26304
26320
  /* harmony export */ ColorPickerWidget: function() { return /* reexport safe */ _color_picker_color_picker__WEBPACK_IMPORTED_MODULE_0__.ColorPickerWidget; },
26305
26321
  /* harmony export */ FileSelectorWidget: function() { return /* reexport safe */ _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__.FileSelectorWidget; },
26306
- /* harmony export */ TabsWidget: function() { return /* reexport safe */ _tabs_tabs__WEBPACK_IMPORTED_MODULE_2__.TabsWidget; }
26322
+ /* harmony export */ TabsWidget: function() { return /* reexport safe */ _tabs_tabs__WEBPACK_IMPORTED_MODULE_2__.TabsWidget; },
26323
+ /* harmony export */ UploadTab: function() { return /* reexport safe */ _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__.UploadTab; }
26307
26324
  /* harmony export */ });
26308
26325
  /* harmony import */ var _color_picker_color_picker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72348);
26309
26326
  /* harmony import */ var _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18762);
@@ -32001,6 +32018,18 @@ function brBefore(start) {
32001
32018
 
32002
32019
 
32003
32020
 
32021
+ function insertLinks(data) {
32022
+ data.files?.forEach((file)=>{
32023
+ const link = this.createInside.element('a', {
32024
+ href: data.baseurl + file
32025
+ });
32026
+ link.textContent = this.o.uploader.getDisplayName.call(this.uploader, data.baseurl, file);
32027
+ this.s.insertNode(link);
32028
+ });
32029
+ }
32030
+ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.file = {
32031
+ defaultHandlerSuccess: insertLinks
32032
+ };
32004
32033
  jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.file = {
32005
32034
  popup: (editor, current, close)=>{
32006
32035
  const insert = (url, title = '')=>{
@@ -32015,7 +32044,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.file = {
32015
32044
  data.files && data.files.forEach((file)=>insert(data.baseurl + file));
32016
32045
  close();
32017
32046
  },
32018
- upload: true,
32047
+ upload: (data)=>{
32048
+ (editor.o.file?.defaultHandlerSuccess ?? insertLinks).call(editor, data);
32049
+ },
32019
32050
  url: (url, text)=>{
32020
32051
  if (sourceAnchor) {
32021
32052
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_2__.attr)(sourceAnchor, 'href', url);
@@ -32901,7 +32932,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeBaseUrl = '';
32901
32932
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeTitle = 'Jodit Editor';
32902
32933
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeDoctype = '<!DOCTYPE html>';
32903
32934
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeDefaultSrc = 'about:blank';
32904
- jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeStyle = 'html{' + 'margin:0;' + 'padding:0;' + 'min-height: 100%;' + '}' + 'body{' + 'box-sizing:border-box;' + 'font-size:13px;' + 'line-height:1.6;' + 'padding:10px;' + 'margin:0;' + 'background:transparent;' + 'color:#000;' + 'position:' + 'relative;' + 'z-index:2;' + 'user-select:auto;' + 'margin:0px;' + 'overflow:auto;' + 'outline:none;' + '}' + 'table{' + 'width:100%;' + 'border:none;' + 'border-collapse:collapse;' + 'empty-cells: show;' + 'max-width: 100%;' + '}' + 'th,td{' + 'padding: 2px 5px;' + 'border:1px solid #ccc;' + '-webkit-user-select:text;' + '-moz-user-select:text;' + '-ms-user-select:text;' + 'user-select:text' + '}' + 'p{' + 'margin-top:0;' + '}' + '.jodit_editor .jodit_iframe_wrapper{' + 'display: block;' + 'clear: both;' + 'user-select: none;' + 'position: relative;' + '}' + '.jodit_editor .jodit_iframe_wrapper:after {' + 'position:absolute;' + 'content:"";' + 'z-index:1;' + 'top:0;' + 'left:0;' + 'right: 0;' + 'bottom: 0;' + 'cursor: pointer;' + 'display: block;' + 'background: rgba(0, 0, 0, 0);' + '} ' + '.jodit_disabled{' + 'user-select: none;' + '-o-user-select: none;' + '-moz-user-select: none;' + '-khtml-user-select: none;' + '-webkit-user-select: none;' + '-ms-user-select: none' + '}';
32935
+ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeStyle = 'html{' + 'margin:0;' + 'padding:0;' + 'min-height: 100%;' + '}' + 'body{' + 'box-sizing:border-box;' + 'font-size:13px;' + 'line-height:1.6;' + 'padding:10px;' + 'margin:0;' + 'background:transparent;' + 'color:#000;' + 'position:' + 'relative;' + 'z-index:2;' + 'user-select:auto;' + 'margin:0px;' + 'overflow:auto;' + 'outline:none;' + '}' + 'table{' + 'width:100%;' + 'border:none;' + 'border-collapse:collapse;' + 'empty-cells: show;' + 'max-width: 100%;' + '}' + 'th,td{' + 'padding: 2px 5px;' + 'border:1px solid #ccc;' + '-webkit-user-select:text;' + '-moz-user-select:text;' + '-ms-user-select:text;' + 'user-select:text' + '}' + 'p{' + 'margin-top:0;' + '}' + '.jodit_editor .jodit_iframe_wrapper{' + 'display: block;' + 'clear: both;' + 'user-select: none;' + 'position: relative;' + '}' + '.jodit_editor .jodit_iframe_wrapper:after {' + 'position:absolute;' + 'content:"";' + 'z-index:1;' + 'top:0;' + 'left:0;' + 'right: 0;' + 'bottom: 0;' + 'cursor: pointer;' + 'display: block;' + 'background: rgba(0, 0, 0, 0);' + '} ' + '.jodit-wysiwyg_image-selected::selection,' + '.jodit-wysiwyg_image-selected *:not(img)::selection{' + 'background:transparent' + '}' + '.jodit_disabled{' + 'user-select: none;' + '-o-user-select: none;' + '-moz-user-select: none;' + '-khtml-user-select: none;' + '-webkit-user-select: none;' + '-ms-user-select: none' + '}';
32905
32936
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeCSSLinks = [];
32906
32937
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeSandbox = null;
32907
32938
 
@@ -33143,13 +33174,19 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
33143
33174
 
33144
33175
 
33145
33176
 
33177
+
33146
33178
  const JODIT_IMAGE_PROCESSOR_BINDED = '__jodit_imageprocessor_binded';
33147
33179
  const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33180
+ const IMAGE_SELECTED = 'jodit-wysiwyg_image-selected';
33148
33181
  /**
33149
33182
  * Change editor's size after load all images
33150
33183
  */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
33151
- afterInit(jodit) {}
33184
+ afterInit(jodit) {
33185
+ jodit.e.on(jodit.ed, 'selectionchange', this.onSelectionChange);
33186
+ }
33152
33187
  beforeDestruct(jodit) {
33188
+ jodit.e.off(jodit.ed, 'selectionchange', this.onSelectionChange);
33189
+ jodit.editor.classList.remove(IMAGE_SELECTED);
33153
33190
  const buffer = (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.cached)(jodit, 'buffer');
33154
33191
  const list = buffer?.get(JODIT_IMAGE_BLOB_ID);
33155
33192
  if (buffer && list) {
@@ -33180,6 +33217,13 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33180
33217
  }
33181
33218
  }
33182
33219
  }
33220
+ /**
33221
+ * While the selection is an image, only the image is highlighted: Safari
33222
+ * paints the rest of a block image's line with its parent's highlight. See #1528
33223
+ */ onSelectionChange() {
33224
+ const { jodit } = this;
33225
+ jodit.editor.classList.toggle(IMAGE_SELECTED, isImageSelected(jodit));
33226
+ }
33183
33227
  async afterChange(data) {
33184
33228
  const { jodit: editor } = this;
33185
33229
  if (!editor.editor) {
@@ -33211,6 +33255,9 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33211
33255
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
33212
33256
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeSetElementValue')
33213
33257
  ], imageProcessor.prototype, "onBeforeSetElementValue", null);
33258
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
33259
+ jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
33260
+ ], imageProcessor.prototype, "onSelectionChange", null);
33214
33261
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
33215
33262
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)([
33216
33263
  ':change',
@@ -33219,6 +33266,14 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
33219
33266
  ]),
33220
33267
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.debounce)()
33221
33268
  ], imageProcessor.prototype, "afterChange", null);
33269
+ function isImageSelected(jodit) {
33270
+ const { sel } = jodit.s;
33271
+ if (!sel || !sel.rangeCount) {
33272
+ return false;
33273
+ }
33274
+ const { startContainer, startOffset, endContainer, endOffset } = sel.getRangeAt(0);
33275
+ return startContainer === endContainer && endOffset === startOffset + 1 && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isTag(startContainer.childNodes[startOffset], 'img') && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isOrContains(jodit.editor, startContainer);
33276
+ }
33222
33277
  /**
33223
33278
  * Remove the invisible-space text beside an image, which only held a caret.
33224
33279
  * Selecting the image replaces the caret, and with the text still after a
@@ -35494,6 +35549,26 @@ const cmd = (control)=>control.args && (0,jodit_core_helpers_checker__WEBPACK_IM
35494
35549
  // Images align with `imageAlignClasses`; the wrappers of iframes and media
35495
35550
  // keep inline styles
35496
35551
  const alignClasses = (editor, elm)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, 'img') ? editor.o.imageAlignClasses : null;
35552
+ // A Normal image sits where the text of its line is aligned (#1531)
35553
+ const lineAlign = (editor, elm)=>{
35554
+ const block = elm && jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.closest(elm, jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isBlock, editor.editor) || editor.editor;
35555
+ const rtl = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(block, 'direction') === 'rtl';
35556
+ switch((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(block, 'text-align')){
35557
+ case 'center':
35558
+ case '-webkit-center':
35559
+ return 'center';
35560
+ case 'justify':
35561
+ return 'justify';
35562
+ case 'right':
35563
+ return 'right';
35564
+ case 'end':
35565
+ return rtl ? 'left' : 'right';
35566
+ case 'start':
35567
+ return rtl ? 'right' : 'left';
35568
+ default:
35569
+ return 'left';
35570
+ }
35571
+ };
35497
35572
  const currentAlign = (editor, elm)=>elm ? (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.getHAlign)(elm, alignClasses(editor, elm)) : 'normal';
35498
35573
  const align = {
35499
35574
  name: 'left',
@@ -35506,7 +35581,7 @@ const align = {
35506
35581
  ],
35507
35582
  update: (editor, button)=>{
35508
35583
  const current = currentAlign(editor, button.target);
35509
- button.state.icon.name = current === 'normal' ? 'left' : current;
35584
+ button.state.icon.name = current === 'normal' ? lineAlign(editor, button.target) : current;
35510
35585
  },
35511
35586
  isActive: (editor, button)=>currentAlign(editor, button.target) !== 'normal',
35512
35587
  isChildActive: (editor, button)=>{
@@ -42074,7 +42149,8 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
42074
42149
  }
42075
42150
  return;
42076
42151
  }
42077
- this.fromWYSIWYG();
42152
+ // The source plugin carries the fallback editor's text over when this
42153
+ // one is ready; refilling from WYSIWYG here would drop unsynced typing
42078
42154
  tryInitAceEditor();
42079
42155
  };
42080
42156
  editor.e.on('afterSetMode', initAceEditor);
@@ -42456,6 +42532,7 @@ class SourceEditor {
42456
42532
  if (new_value !== this.getMirrorValue()) {
42457
42533
  this.setMirrorValue(new_value);
42458
42534
  }
42535
+ this.__filledValue = this.getMirrorValue();
42459
42536
  this.__lock = false;
42460
42537
  }
42461
42538
  }
@@ -42625,11 +42702,7 @@ class SourceEditor {
42625
42702
  }
42626
42703
  loading = true;
42627
42704
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.loadNext)(editor, editor.o.beautifyHTMLCDNUrlsJS).then(()=>{
42628
- // The source view was filled before the
42629
- // beautifier arrived — format it now.
42630
- if (addEventListener()) {
42631
- this.syncValueFromWYSIWYG(true);
42632
- }
42705
+ addEventListener() && this.beautifyUntouched();
42633
42706
  }, ()=>null);
42634
42707
  };
42635
42708
  editor.e.on('afterSetMode.source', loadBeautify);
@@ -42649,9 +42722,7 @@ class SourceEditor {
42649
42722
  if (editor.o.sourceEditor !== 'area') {
42650
42723
  const sourceEditor = (0,_editor_factory__WEBPACK_IMPORTED_MODULE_9__.createSourceEditor)(editor.o.sourceEditor, editor, this.mirrorContainer, this.toWYSIWYG, this.fromWYSIWYG);
42651
42724
  sourceEditor.onReadyAlways(()=>{
42652
- this.sourceEditor?.destruct();
42653
- this.sourceEditor = sourceEditor;
42654
- this.syncValueFromWYSIWYG(true);
42725
+ this.takeOver(sourceEditor);
42655
42726
  editor.events?.fire('sourceEditorReady', editor);
42656
42727
  });
42657
42728
  } else {
@@ -42661,6 +42732,48 @@ class SourceEditor {
42661
42732
  });
42662
42733
  }
42663
42734
  }
42735
+ /**
42736
+ * Replaces the source editor (the textarea shown while ACE loads) with
42737
+ * the one that just became ready, carrying its text, selection and focus
42738
+ * over. Filling the new editor from WYSIWYG instead would drop what was
42739
+ * typed since the last, debounced, sync and normalise half-typed markup.
42740
+ */ takeOver(sourceEditor) {
42741
+ const previous = this.sourceEditor;
42742
+ if (!previous || previous === sourceEditor) {
42743
+ this.sourceEditor = sourceEditor;
42744
+ this.syncValueFromWYSIWYG(true);
42745
+ return;
42746
+ }
42747
+ const value = previous.getValue(), start = previous.getSelectionStart(), end = previous.getSelectionEnd(), focused = previous.isFocused, untouched = value === this.__filledValue;
42748
+ previous.destruct();
42749
+ this.sourceEditor = sourceEditor;
42750
+ if (untouched) {
42751
+ this.syncValueFromWYSIWYG(true);
42752
+ } else {
42753
+ sourceEditor.setValue(value);
42754
+ this.toWYSIWYG();
42755
+ }
42756
+ if (start >= 0) {
42757
+ sourceEditor.setSelectionRange(start, end);
42758
+ }
42759
+ focused && sourceEditor.focus();
42760
+ }
42761
+ /**
42762
+ * The beautifier arrived after the source view was opened: format the
42763
+ * view if nothing has been typed into it, otherwise leave the typing alone
42764
+ */ beautifyUntouched() {
42765
+ const value = this.getMirrorValue();
42766
+ if (this.j.o.editHTMLDocumentMode || !value || value !== this.__filledValue) {
42767
+ return;
42768
+ }
42769
+ const html = this.j.e.fire('beautifyHTML', value);
42770
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.isString)(html) && html !== value) {
42771
+ const focused = this.sourceEditor?.isFocused;
42772
+ this.setMirrorValue(html);
42773
+ this.__filledValue = this.getMirrorValue();
42774
+ focused && this.sourceEditor?.focus();
42775
+ }
42776
+ }
42664
42777
  /** @override */ beforeDestruct() {
42665
42778
  if (this.sourceEditor) {
42666
42779
  this.sourceEditor.destruct();
@@ -42674,7 +42787,10 @@ class SourceEditor {
42674
42787
  name: 'source',
42675
42788
  group: 'source'
42676
42789
  }
42677
- ]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "sourceEditor", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "mirrorContainer", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__lock", false), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__oldMirrorValue", ''), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerStart", '{start-jodit-selection}'), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerStartReg", /{start-jodit-selection}/g), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerEnd", '{end-jodit-selection}'), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerEndReg", /{end-jodit-selection}/g), // override it for ace editors
42790
+ ]), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "sourceEditor", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "mirrorContainer", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__lock", false), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__oldMirrorValue", ''), /**
42791
+ * What the source view was last filled with from WYSIWYG, read back from
42792
+ * the editor; while the view still holds it, nothing has been typed there
42793
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__filledValue", ''), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerStart", '{start-jodit-selection}'), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerStartReg", /{start-jodit-selection}/g), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerEnd", '{end-jodit-selection}'), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "tempMarkerEndReg", /{end-jodit-selection}/g), // override it for ace editors
42678
42794
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "getSelectionStart", ()=>{
42679
42795
  return this.sourceEditor?.getSelectionStart() ?? 0;
42680
42796
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "getSelectionEnd", ()=>{
@@ -45038,10 +45154,19 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('toolbarNavigati
45038
45154
 
45039
45155
 
45040
45156
 
45157
+ function insertVideos(data) {
45158
+ data.files?.forEach((file)=>{
45159
+ this.s.insertNode(this.createInside.element('video', {
45160
+ controls: '',
45161
+ src: data.baseurl + file
45162
+ }));
45163
+ });
45164
+ }
45041
45165
  jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.video = {
45042
45166
  parseUrlToVideoEmbed: jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.convertMediaUrlToVideoEmbed,
45043
45167
  defaultWidth: 400,
45044
- defaultHeight: 345
45168
+ defaultHeight: 345,
45169
+ defaultHandlerSuccess: insertVideos
45045
45170
  };
45046
45171
  jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_3__.Icon.set('video', (_video_svg__WEBPACK_IMPORTED_MODULE_6___default()));
45047
45172
  jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.controls.video = {
@@ -45078,6 +45203,17 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.controls.video = {
45078
45203
  close();
45079
45204
  };
45080
45205
  jodit.s.save();
45206
+ const { uploader } = jodit.o;
45207
+ // Base64 alone would put whole video files into the content
45208
+ if (uploader.showTabInFileSelector !== false && (uploader.url || uploader.customUploadFunction)) {
45209
+ tabs.push((0,jodit_modules_widget__WEBPACK_IMPORTED_MODULE_5__.UploadTab)(jodit, (data)=>{
45210
+ jodit.s.restore();
45211
+ (jodit.o.video?.defaultHandlerSuccess ?? insertVideos).call(jodit, data);
45212
+ }, {
45213
+ label: 'Drop file',
45214
+ accept: 'video/*'
45215
+ }));
45216
+ }
45081
45217
  tabs.push({
45082
45218
  icon: 'link',
45083
45219
  name: 'Link',