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
@@ -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;
@@ -26171,22 +26171,19 @@ jodit_core_ui__WEBPACK_IMPORTED_MODULE_2__.Icon.set('palette', (_palette_svg__WE
26171
26171
  const tabs = [];
26172
26172
  const options = editor.o.uploader;
26173
26173
  if (callbacks.upload && options.showTabInFileSelector !== false && (options.url || options.insertImageAsBase64URI || options.customUploadFunction)) {
26174
- 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>');
26175
- editor.uploader.bind(dragBox, (resp)=>{
26176
- const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(callbacks.upload) ? callbacks.upload : options.defaultHandlerSuccess;
26174
+ const { upload } = callbacks;
26175
+ tabs.push(UploadTab(editor, (resp)=>{
26176
+ const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(upload) ? upload : options.defaultHandlerSuccess;
26177
26177
  if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handler)) {
26178
26178
  handler.call(editor, resp);
26179
26179
  }
26180
- editor.e.fire('closeAllPopups');
26181
- }, (error)=>{
26182
- editor.message.error(error.message);
26183
- editor.e.fire('closeAllPopups');
26184
- });
26185
- tabs.push({
26186
- icon: 'upload',
26187
- name: 'Upload',
26188
- content: dragBox
26189
- });
26180
+ }, isImage ? {
26181
+ label: 'Drop image',
26182
+ accept: 'image/*'
26183
+ } : {
26184
+ label: 'Drop file',
26185
+ accept: '*'
26186
+ }));
26190
26187
  }
26191
26188
  if (callbacks.filebrowser) {
26192
26189
  if (editor.o.filebrowser.ajax.url || editor.o.filebrowser.items.url) {
@@ -26254,6 +26251,24 @@ jodit_core_ui__WEBPACK_IMPORTED_MODULE_2__.Icon.set('palette', (_palette_svg__WE
26254
26251
  box.classList.add('jodit-file-selector');
26255
26252
  return box;
26256
26253
  };
26254
+ /**
26255
+ * The Upload tab: a box that uploads the files dropped on it or chosen in its
26256
+ * file input, then passes the uploader's answer to `onSuccess` and closes the popup
26257
+ */ const UploadTab = (editor, onSuccess, { label, accept })=>{
26258
+ 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>');
26259
+ editor.uploader.bind(dragBox, (resp)=>{
26260
+ onSuccess.call(editor, resp);
26261
+ editor.e.fire('closeAllPopups');
26262
+ }, (error)=>{
26263
+ editor.message.error(error.message);
26264
+ editor.e.fire('closeAllPopups');
26265
+ });
26266
+ return {
26267
+ icon: 'upload',
26268
+ name: 'Upload',
26269
+ content: dragBox
26270
+ };
26271
+ };
26257
26272
  function val(elm, name, value) {
26258
26273
  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);
26259
26274
  if (!child) {
@@ -26266,7 +26281,8 @@ function val(elm, name, value) {
26266
26281
  }
26267
26282
 
26268
26283
  /* harmony export */ __webpack_require__.d(__webpack_exports__, [
26269
- /* harmony export */ "FileSelectorWidget", 0, /* binding */ FileSelectorWidget
26284
+ /* harmony export */ "FileSelectorWidget", 0, /* binding */ FileSelectorWidget,
26285
+ /* harmony export */ "UploadTab", 0, /* binding */ UploadTab
26270
26286
  /* harmony export */ ]);
26271
26287
 
26272
26288
 
@@ -26279,7 +26295,8 @@ function val(elm, name, value) {
26279
26295
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
26280
26296
  /* harmony export */ ColorPickerWidget: function() { return /* reexport safe */ _color_picker_color_picker__WEBPACK_IMPORTED_MODULE_0__.ColorPickerWidget; },
26281
26297
  /* harmony export */ FileSelectorWidget: function() { return /* reexport safe */ _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__.FileSelectorWidget; },
26282
- /* harmony export */ TabsWidget: function() { return /* reexport safe */ _tabs_tabs__WEBPACK_IMPORTED_MODULE_2__.TabsWidget; }
26298
+ /* harmony export */ TabsWidget: function() { return /* reexport safe */ _tabs_tabs__WEBPACK_IMPORTED_MODULE_2__.TabsWidget; },
26299
+ /* harmony export */ UploadTab: function() { return /* reexport safe */ _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__.UploadTab; }
26283
26300
  /* harmony export */ });
26284
26301
  /* harmony import */ var _color_picker_color_picker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(72348);
26285
26302
  /* harmony import */ var _file_selector_file_selector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18762);
@@ -31614,6 +31631,18 @@ function brBefore(start) {
31614
31631
 
31615
31632
 
31616
31633
 
31634
+ function insertLinks(data) {
31635
+ data.files?.forEach((file)=>{
31636
+ const link = this.createInside.element('a', {
31637
+ href: data.baseurl + file
31638
+ });
31639
+ link.textContent = this.o.uploader.getDisplayName.call(this.uploader, data.baseurl, file);
31640
+ this.s.insertNode(link);
31641
+ });
31642
+ }
31643
+ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.file = {
31644
+ defaultHandlerSuccess: insertLinks
31645
+ };
31617
31646
  jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.file = {
31618
31647
  popup: (editor, current, close)=>{
31619
31648
  const insert = (url, title = '')=>{
@@ -31628,7 +31657,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.controls.file = {
31628
31657
  data.files && data.files.forEach((file)=>insert(data.baseurl + file));
31629
31658
  close();
31630
31659
  },
31631
- upload: true,
31660
+ upload: (data)=>{
31661
+ (editor.o.file?.defaultHandlerSuccess ?? insertLinks).call(editor, data);
31662
+ },
31632
31663
  url: (url, text)=>{
31633
31664
  if (sourceAnchor) {
31634
31665
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_2__.attr)(sourceAnchor, 'href', url);
@@ -32514,7 +32545,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeBaseUrl = '';
32514
32545
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeTitle = 'Jodit Editor';
32515
32546
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeDoctype = '<!DOCTYPE html>';
32516
32547
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeDefaultSrc = 'about:blank';
32517
- 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' + '}';
32548
+ 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' + '}';
32518
32549
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeCSSLinks = [];
32519
32550
  jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.iframeSandbox = null;
32520
32551
 
@@ -32756,13 +32787,19 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.imageProcessor = {
32756
32787
 
32757
32788
 
32758
32789
 
32790
+
32759
32791
  const JODIT_IMAGE_PROCESSOR_BINDED = '__jodit_imageprocessor_binded';
32760
32792
  const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
32793
+ const IMAGE_SELECTED = 'jodit-wysiwyg_image-selected';
32761
32794
  /**
32762
32795
  * Change editor's size after load all images
32763
32796
  */ class imageProcessor extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugin {
32764
- afterInit(jodit) {}
32797
+ afterInit(jodit) {
32798
+ jodit.e.on(jodit.ed, 'selectionchange', this.onSelectionChange);
32799
+ }
32765
32800
  beforeDestruct(jodit) {
32801
+ jodit.e.off(jodit.ed, 'selectionchange', this.onSelectionChange);
32802
+ jodit.editor.classList.remove(IMAGE_SELECTED);
32766
32803
  const buffer = (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.cached)(jodit, 'buffer');
32767
32804
  const list = buffer?.get(JODIT_IMAGE_BLOB_ID);
32768
32805
  if (buffer && list) {
@@ -32793,6 +32830,13 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
32793
32830
  }
32794
32831
  }
32795
32832
  }
32833
+ /**
32834
+ * While the selection is an image, only the image is highlighted: Safari
32835
+ * paints the rest of a block image's line with its parent's highlight. See #1528
32836
+ */ onSelectionChange() {
32837
+ const { jodit } = this;
32838
+ jodit.editor.classList.toggle(IMAGE_SELECTED, isImageSelected(jodit));
32839
+ }
32796
32840
  async afterChange(data) {
32797
32841
  const { jodit: editor } = this;
32798
32842
  if (!editor.editor) {
@@ -32824,6 +32868,9 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
32824
32868
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
32825
32869
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeSetElementValue')
32826
32870
  ], imageProcessor.prototype, "onBeforeSetElementValue", null);
32871
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
32872
+ jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
32873
+ ], imageProcessor.prototype, "onSelectionChange", null);
32827
32874
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_0__.__decorate)([
32828
32875
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)([
32829
32876
  ':change',
@@ -32832,6 +32879,14 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
32832
32879
  ]),
32833
32880
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.debounce)()
32834
32881
  ], imageProcessor.prototype, "afterChange", null);
32882
+ function isImageSelected(jodit) {
32883
+ const { sel } = jodit.s;
32884
+ if (!sel || !sel.rangeCount) {
32885
+ return false;
32886
+ }
32887
+ const { startContainer, startOffset, endContainer, endOffset } = sel.getRangeAt(0);
32888
+ 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);
32889
+ }
32835
32890
  /**
32836
32891
  * Remove the invisible-space text beside an image, which only held a caret.
32837
32892
  * Selecting the image replaces the caret, and with the text still after a
@@ -35107,6 +35162,26 @@ const cmd = (control)=>control.args && (0,jodit_core_helpers_checker__WEBPACK_IM
35107
35162
  // Images align with `imageAlignClasses`; the wrappers of iframes and media
35108
35163
  // keep inline styles
35109
35164
  const alignClasses = (editor, elm)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(elm, 'img') ? editor.o.imageAlignClasses : null;
35165
+ // A Normal image sits where the text of its line is aligned (#1531)
35166
+ const lineAlign = (editor, elm)=>{
35167
+ 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;
35168
+ const rtl = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(block, 'direction') === 'rtl';
35169
+ switch((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_3__.css)(block, 'text-align')){
35170
+ case 'center':
35171
+ case '-webkit-center':
35172
+ return 'center';
35173
+ case 'justify':
35174
+ return 'justify';
35175
+ case 'right':
35176
+ return 'right';
35177
+ case 'end':
35178
+ return rtl ? 'left' : 'right';
35179
+ case 'start':
35180
+ return rtl ? 'right' : 'left';
35181
+ default:
35182
+ return 'left';
35183
+ }
35184
+ };
35110
35185
  const currentAlign = (editor, elm)=>elm ? (0,jodit_core_helpers_utils_align__WEBPACK_IMPORTED_MODULE_2__.getHAlign)(elm, alignClasses(editor, elm)) : 'normal';
35111
35186
  const align = {
35112
35187
  name: 'left',
@@ -35119,7 +35194,7 @@ const align = {
35119
35194
  ],
35120
35195
  update: (editor, button)=>{
35121
35196
  const current = currentAlign(editor, button.target);
35122
- button.state.icon.name = current === 'normal' ? 'left' : current;
35197
+ button.state.icon.name = current === 'normal' ? lineAlign(editor, button.target) : current;
35123
35198
  },
35124
35199
  isActive: (editor, button)=>currentAlign(editor, button.target) !== 'normal',
35125
35200
  isChildActive: (editor, button)=>{
@@ -41321,7 +41396,8 @@ class AceEditor extends jodit_plugins_source_editor_sourceEditor__WEBPACK_IMPORT
41321
41396
  }
41322
41397
  return;
41323
41398
  }
41324
- this.fromWYSIWYG();
41399
+ // The source plugin carries the fallback editor's text over when this
41400
+ // one is ready; refilling from WYSIWYG here would drop unsynced typing
41325
41401
  tryInitAceEditor();
41326
41402
  };
41327
41403
  editor.e.on('afterSetMode', initAceEditor);
@@ -41703,6 +41779,7 @@ class SourceEditor {
41703
41779
  if (new_value !== this.getMirrorValue()) {
41704
41780
  this.setMirrorValue(new_value);
41705
41781
  }
41782
+ this.__filledValue = this.getMirrorValue();
41706
41783
  this.__lock = false;
41707
41784
  }
41708
41785
  }
@@ -41872,11 +41949,7 @@ class SourceEditor {
41872
41949
  }
41873
41950
  loading = true;
41874
41951
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.loadNext)(editor, editor.o.beautifyHTMLCDNUrlsJS).then(()=>{
41875
- // The source view was filled before the
41876
- // beautifier arrived — format it now.
41877
- if (addEventListener()) {
41878
- this.syncValueFromWYSIWYG(true);
41879
- }
41952
+ addEventListener() && this.beautifyUntouched();
41880
41953
  }, ()=>null);
41881
41954
  };
41882
41955
  editor.e.on('afterSetMode.source', loadBeautify);
@@ -41896,9 +41969,7 @@ class SourceEditor {
41896
41969
  if (editor.o.sourceEditor !== 'area') {
41897
41970
  const sourceEditor = (0,_editor_factory__WEBPACK_IMPORTED_MODULE_9__.createSourceEditor)(editor.o.sourceEditor, editor, this.mirrorContainer, this.toWYSIWYG, this.fromWYSIWYG);
41898
41971
  sourceEditor.onReadyAlways(()=>{
41899
- this.sourceEditor?.destruct();
41900
- this.sourceEditor = sourceEditor;
41901
- this.syncValueFromWYSIWYG(true);
41972
+ this.takeOver(sourceEditor);
41902
41973
  editor.events?.fire('sourceEditorReady', editor);
41903
41974
  });
41904
41975
  } else {
@@ -41908,6 +41979,48 @@ class SourceEditor {
41908
41979
  });
41909
41980
  }
41910
41981
  }
41982
+ /**
41983
+ * Replaces the source editor (the textarea shown while ACE loads) with
41984
+ * the one that just became ready, carrying its text, selection and focus
41985
+ * over. Filling the new editor from WYSIWYG instead would drop what was
41986
+ * typed since the last, debounced, sync and normalise half-typed markup.
41987
+ */ takeOver(sourceEditor) {
41988
+ const previous = this.sourceEditor;
41989
+ if (!previous || previous === sourceEditor) {
41990
+ this.sourceEditor = sourceEditor;
41991
+ this.syncValueFromWYSIWYG(true);
41992
+ return;
41993
+ }
41994
+ const value = previous.getValue(), start = previous.getSelectionStart(), end = previous.getSelectionEnd(), focused = previous.isFocused, untouched = value === this.__filledValue;
41995
+ previous.destruct();
41996
+ this.sourceEditor = sourceEditor;
41997
+ if (untouched) {
41998
+ this.syncValueFromWYSIWYG(true);
41999
+ } else {
42000
+ sourceEditor.setValue(value);
42001
+ this.toWYSIWYG();
42002
+ }
42003
+ if (start >= 0) {
42004
+ sourceEditor.setSelectionRange(start, end);
42005
+ }
42006
+ focused && sourceEditor.focus();
42007
+ }
42008
+ /**
42009
+ * The beautifier arrived after the source view was opened: format the
42010
+ * view if nothing has been typed into it, otherwise leave the typing alone
42011
+ */ beautifyUntouched() {
42012
+ const value = this.getMirrorValue();
42013
+ if (this.j.o.editHTMLDocumentMode || !value || value !== this.__filledValue) {
42014
+ return;
42015
+ }
42016
+ const html = this.j.e.fire('beautifyHTML', value);
42017
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.isString)(html) && html !== value) {
42018
+ const focused = this.sourceEditor?.isFocused;
42019
+ this.setMirrorValue(html);
42020
+ this.__filledValue = this.getMirrorValue();
42021
+ focused && this.sourceEditor?.focus();
42022
+ }
42023
+ }
41911
42024
  /** @override */ beforeDestruct() {
41912
42025
  if (this.sourceEditor) {
41913
42026
  this.sourceEditor.destruct();
@@ -41921,7 +42034,10 @@ class SourceEditor {
41921
42034
  name: 'source',
41922
42035
  group: 'source'
41923
42036
  }
41924
- ]), (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
42037
+ ]), (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", ''), /**
42038
+ * What the source view was last filled with from WYSIWYG, read back from
42039
+ * the editor; while the view still holds it, nothing has been typed there
42040
+ */ (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
41925
42041
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "getSelectionStart", ()=>{
41926
42042
  return this.sourceEditor?.getSelectionStart() ?? 0;
41927
42043
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "getSelectionEnd", ()=>{
@@ -43553,10 +43669,19 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.pluginSystem.add('toolbarNavigati
43553
43669
 
43554
43670
 
43555
43671
 
43672
+ function insertVideos(data) {
43673
+ data.files?.forEach((file)=>{
43674
+ this.s.insertNode(this.createInside.element('video', {
43675
+ controls: '',
43676
+ src: data.baseurl + file
43677
+ }));
43678
+ });
43679
+ }
43556
43680
  jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.video = {
43557
43681
  parseUrlToVideoEmbed: jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.convertMediaUrlToVideoEmbed,
43558
43682
  defaultWidth: 400,
43559
- defaultHeight: 345
43683
+ defaultHeight: 345,
43684
+ defaultHandlerSuccess: insertVideos
43560
43685
  };
43561
43686
  jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_3__.Icon.set('video', (_video_svg__WEBPACK_IMPORTED_MODULE_6___default()));
43562
43687
  jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.controls.video = {
@@ -43593,6 +43718,17 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__.Config.prototype.controls.video = {
43593
43718
  close();
43594
43719
  };
43595
43720
  jodit.s.save();
43721
+ const { uploader } = jodit.o;
43722
+ // Base64 alone would put whole video files into the content
43723
+ if (uploader.showTabInFileSelector !== false && (uploader.url || uploader.customUploadFunction)) {
43724
+ tabs.push((0,jodit_modules_widget__WEBPACK_IMPORTED_MODULE_5__.UploadTab)(jodit, (data)=>{
43725
+ jodit.s.restore();
43726
+ (jodit.o.video?.defaultHandlerSuccess ?? insertVideos).call(jodit, data);
43727
+ }, {
43728
+ label: 'Drop file',
43729
+ accept: 'video/*'
43730
+ }));
43731
+ }
43596
43732
  tabs.push({
43597
43733
  icon: 'link',
43598
43734
  name: 'Link',