jodit 4.19.14 → 4.20.1

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 (217) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/es2015/jodit.css +76 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +12 -12
  5. package/es2015/jodit.js +1464 -599
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +12 -12
  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 +12 -12
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +12 -12
  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 +76 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +17 -17
  23. package/es2021/jodit.js +1445 -596
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +17 -17
  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 +76 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +17 -17
  35. package/es2021.en/jodit.js +1419 -570
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +17 -17
  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 +96 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +1707 -706
  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 +10 -3
  60. package/esm/core/constants.js +1 -1
  61. package/esm/core/helpers/utils/anchor.d.ts +22 -0
  62. package/esm/core/helpers/utils/anchor.js +29 -0
  63. package/esm/core/helpers/utils/index.d.ts +1 -0
  64. package/esm/core/helpers/utils/index.js +1 -0
  65. package/esm/core/ui/form/inputs/input/input.js +2 -0
  66. package/esm/core/ui/popup/popup.d.ts +5 -0
  67. package/esm/core/ui/popup/popup.js +5 -0
  68. package/esm/jodit.js +11 -14
  69. package/esm/langs/ar.d.ts +5 -0
  70. package/esm/langs/ar.js +5 -0
  71. package/esm/langs/az.d.ts +5 -0
  72. package/esm/langs/az.js +5 -0
  73. package/esm/langs/cs_cz.d.ts +5 -0
  74. package/esm/langs/cs_cz.js +6 -1
  75. package/esm/langs/de.d.ts +5 -0
  76. package/esm/langs/de.js +6 -0
  77. package/esm/langs/es.d.ts +5 -0
  78. package/esm/langs/es.js +6 -1
  79. package/esm/langs/fa.d.ts +5 -0
  80. package/esm/langs/fa.js +6 -1
  81. package/esm/langs/fi.d.ts +5 -0
  82. package/esm/langs/fi.js +5 -0
  83. package/esm/langs/fr.d.ts +5 -0
  84. package/esm/langs/fr.js +5 -0
  85. package/esm/langs/he.d.ts +5 -0
  86. package/esm/langs/he.js +6 -1
  87. package/esm/langs/hu.d.ts +5 -0
  88. package/esm/langs/hu.js +5 -0
  89. package/esm/langs/id.d.ts +5 -0
  90. package/esm/langs/id.js +6 -1
  91. package/esm/langs/it.d.ts +5 -0
  92. package/esm/langs/it.js +6 -1
  93. package/esm/langs/ja.d.ts +5 -0
  94. package/esm/langs/ja.js +6 -1
  95. package/esm/langs/ko.d.ts +5 -0
  96. package/esm/langs/ko.js +6 -1
  97. package/esm/langs/mn.d.ts +5 -0
  98. package/esm/langs/mn.js +6 -1
  99. package/esm/langs/nl.d.ts +5 -0
  100. package/esm/langs/nl.js +5 -0
  101. package/esm/langs/no.d.ts +5 -0
  102. package/esm/langs/no.js +5 -0
  103. package/esm/langs/pl.d.ts +5 -0
  104. package/esm/langs/pl.js +5 -0
  105. package/esm/langs/pt_br.d.ts +5 -0
  106. package/esm/langs/pt_br.js +6 -1
  107. package/esm/langs/ru.d.ts +5 -0
  108. package/esm/langs/ru.js +6 -1
  109. package/esm/langs/sk.d.ts +5 -0
  110. package/esm/langs/sk.js +5 -0
  111. package/esm/langs/sv.d.ts +5 -0
  112. package/esm/langs/sv.js +5 -0
  113. package/esm/langs/tr.d.ts +5 -0
  114. package/esm/langs/tr.js +6 -1
  115. package/esm/langs/ua.d.ts +5 -0
  116. package/esm/langs/ua.js +6 -1
  117. package/esm/langs/zh_cn.d.ts +5 -0
  118. package/esm/langs/zh_cn.js +6 -1
  119. package/esm/langs/zh_tw.d.ts +5 -0
  120. package/esm/langs/zh_tw.js +5 -0
  121. package/esm/modules/file-browser/file-browser.d.ts +3 -4
  122. package/esm/modules/file-browser/file-browser.js +12 -12
  123. package/esm/modules/toolbar/button/button.d.ts +7 -0
  124. package/esm/modules/toolbar/button/button.js +32 -4
  125. package/esm/modules/uploader/config.js +18 -18
  126. package/esm/modules/uploader/helpers/index.d.ts +1 -0
  127. package/esm/modules/uploader/helpers/index.js +1 -0
  128. package/esm/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
  129. package/esm/modules/uploader/helpers/normalize-uploader-data.js +54 -0
  130. package/esm/modules/uploader/helpers/send-files.js +11 -6
  131. package/esm/modules/uploader/uploader.d.ts +4 -5
  132. package/esm/modules/uploader/uploader.js +12 -8
  133. package/esm/plugins/all.d.ts +1 -0
  134. package/esm/plugins/all.js +1 -0
  135. package/esm/plugins/anchor/anchor.d.ts +67 -0
  136. package/esm/plugins/anchor/anchor.js +302 -0
  137. package/esm/plugins/anchor/config.d.ts +6 -0
  138. package/esm/plugins/anchor/config.js +13 -0
  139. package/esm/plugins/file/file.d.ts +1 -1
  140. package/esm/plugins/file/file.js +6 -6
  141. package/esm/plugins/image/image.js +2 -2
  142. package/esm/plugins/image-caption/image-caption.js +1 -2
  143. package/esm/plugins/image-properties/utils/open-image-popup.js +7 -6
  144. package/esm/plugins/index.d.ts +1 -0
  145. package/esm/plugins/inline-popup/config/config.d.ts +8 -2
  146. package/esm/plugins/inline-popup/config/config.js +1 -0
  147. package/esm/plugins/inline-popup/config/items/cells.js +0 -10
  148. package/esm/plugins/inline-popup/config/items/img.js +1 -1
  149. package/esm/plugins/inline-popup/inline-popup.d.ts +9 -12
  150. package/esm/plugins/inline-popup/inline-popup.js +53 -77
  151. package/esm/plugins/link/link.js +150 -3
  152. package/esm/plugins/link/template.js +3 -1
  153. package/esm/plugins/resizer/resizer.d.ts +6 -0
  154. package/esm/plugins/resizer/resizer.js +11 -0
  155. package/esm/plugins/select/select.d.ts +31 -0
  156. package/esm/plugins/select/select.js +235 -2
  157. package/esm/plugins/select-cells/select-cells.d.ts +11 -0
  158. package/esm/plugins/select-cells/select-cells.js +48 -17
  159. package/esm/plugins/video/config.d.ts +1 -1
  160. package/esm/plugins/video/config.js +4 -3
  161. package/esm/plugins/video-properties/video-properties.js +7 -6
  162. package/esm/styles/icons/anchor.svg.js +1 -0
  163. package/esm/styles/icons/index.d.ts +1 -1
  164. package/esm/styles/icons/index.js +2 -1
  165. package/esm/types/file-browser.d.ts +8 -1
  166. package/esm/types/popup.d.ts +1 -0
  167. package/esm/types/uploader.d.ts +39 -1
  168. package/package.json +1 -1
  169. package/types/config.d.ts +10 -3
  170. package/types/core/helpers/utils/anchor.d.ts +22 -0
  171. package/types/core/helpers/utils/index.d.ts +1 -0
  172. package/types/core/ui/popup/popup.d.ts +5 -0
  173. package/types/langs/ar.d.ts +5 -0
  174. package/types/langs/az.d.ts +5 -0
  175. package/types/langs/cs_cz.d.ts +5 -0
  176. package/types/langs/de.d.ts +5 -0
  177. package/types/langs/es.d.ts +5 -0
  178. package/types/langs/fa.d.ts +5 -0
  179. package/types/langs/fi.d.ts +5 -0
  180. package/types/langs/fr.d.ts +5 -0
  181. package/types/langs/he.d.ts +5 -0
  182. package/types/langs/hu.d.ts +5 -0
  183. package/types/langs/id.d.ts +5 -0
  184. package/types/langs/it.d.ts +5 -0
  185. package/types/langs/ja.d.ts +5 -0
  186. package/types/langs/ko.d.ts +5 -0
  187. package/types/langs/mn.d.ts +5 -0
  188. package/types/langs/nl.d.ts +5 -0
  189. package/types/langs/no.d.ts +5 -0
  190. package/types/langs/pl.d.ts +5 -0
  191. package/types/langs/pt_br.d.ts +5 -0
  192. package/types/langs/ru.d.ts +5 -0
  193. package/types/langs/sk.d.ts +5 -0
  194. package/types/langs/sv.d.ts +5 -0
  195. package/types/langs/tr.d.ts +5 -0
  196. package/types/langs/ua.d.ts +5 -0
  197. package/types/langs/zh_cn.d.ts +5 -0
  198. package/types/langs/zh_tw.d.ts +5 -0
  199. package/types/modules/file-browser/file-browser.d.ts +3 -4
  200. package/types/modules/toolbar/button/button.d.ts +7 -0
  201. package/types/modules/uploader/helpers/index.d.ts +1 -0
  202. package/types/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
  203. package/types/modules/uploader/uploader.d.ts +4 -5
  204. package/types/plugins/anchor/anchor.d.ts +67 -0
  205. package/types/plugins/anchor/config.d.ts +6 -0
  206. package/types/plugins/file/file.d.ts +1 -1
  207. package/types/plugins/index.d.ts +1 -0
  208. package/types/plugins/inline-popup/config/config.d.ts +8 -2
  209. package/types/plugins/inline-popup/inline-popup.d.ts +9 -12
  210. package/types/plugins/resizer/resizer.d.ts +6 -0
  211. package/types/plugins/select/select.d.ts +31 -0
  212. package/types/plugins/select-cells/select-cells.d.ts +11 -0
  213. package/types/plugins/video/config.d.ts +1 -1
  214. package/types/styles/icons/index.d.ts +1 -1
  215. package/types/types/file-browser.d.ts +8 -1
  216. package/types/types/popup.d.ts +1 -0
  217. package/types/types/uploader.d.ts +39 -1
@@ -163,6 +163,14 @@ export class resizer extends Plugin {
163
163
  this.addEventListeners();
164
164
  this.__onChangeEditor();
165
165
  }
166
+ /**
167
+ * A tap that selects an image sends no `click` (iPadOS), so `touchend`
168
+ * stands in for it. A tick later, after `onClickOutside` has had the same
169
+ * `touchend`, as `click` comes after `mouseup`
170
+ */
171
+ onEditorTouchEnd(e) {
172
+ this.j.async.setTimeout(() => this.onEditorClick(e), 1);
173
+ }
166
174
  /**
167
175
  * Click in the editor area
168
176
  */
@@ -595,6 +603,9 @@ export class resizer extends Plugin {
595
603
  .off('keydown', this.onEditorKeyDown);
596
604
  }
597
605
  }
606
+ __decorate([
607
+ watch(':touchend')
608
+ ], resizer.prototype, "onEditorTouchEnd", null);
598
609
  __decorate([
599
610
  watch(':click')
600
611
  ], resizer.prototype, "onEditorClick", null);
@@ -26,6 +26,21 @@ export declare class select extends Plugin {
26
26
  private proxyEventsList;
27
27
  protected afterInit(jodit: IJodit): void;
28
28
  protected beforeDestruct(jodit: IJodit): void;
29
+ private __selectedMediaStyle;
30
+ /**
31
+ * The browsers shade an image in the selection, but Chrome doesn't shade
32
+ * a video with controls, or one in a `jodit-media` wrapper, so a selection
33
+ * that took one in didn't show it, and typing deleted it unseen (#1768).
34
+ * The media gets the same shade from a filter, in place of the tint Safari
35
+ * gives a block wrapper's whole line. It's a style in the editing
36
+ * document, as selected cells get their border, so the content, and with
37
+ * it the value, the history and a copy, doesn't change. Media a click
38
+ * selected whole is left alone, as its resize frame shows it (#1528). A
39
+ * change, read-only and the source mode redo or drop the style, as the
40
+ * selection may not change with them, and the style's paths could then
41
+ * fit other elements
42
+ */
43
+ private __markSelectedMedia;
29
44
  private onStartSelection;
30
45
  /**
31
46
  * Where the last press started. Chrome reports a drag that begins in one
@@ -93,5 +108,21 @@ export declare class select extends Plugin {
93
108
  * Normalize selection after triple click
94
109
  */
95
110
  protected onTripleClickNormalizeSelection(e: MouseEvent): void;
111
+ /**
112
+ * A double click past the end of a line selects only its line break, up
113
+ * to the start of the next line a caret can go on. The browsers show no
114
+ * caret for it, and typing replaces the break, joining the lines and
115
+ * taking any video in between with it (#1768). Put the caret at the end
116
+ * of the line instead
117
+ */
118
+ protected onDblClickPastLineEnd(): void;
119
+ /**
120
+ * The browsers have no caret position beside an uneditable block alone
121
+ * on its line, such as a video, so a drag that ends on its line runs on
122
+ * past it, and typing deletes it (#1768). Until the pointer has passed
123
+ * the block, the selection stops at the last caret place in the block
124
+ * before its line, or for a drag upwards at the first in the block after
125
+ */
126
+ protected onMouseUpOnUneditableLine(e: MouseEvent): void;
96
127
  protected onCopyNormalizeSelectionBound(e?: ClipboardEvent): void;
97
128
  }
@@ -13,15 +13,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
13
13
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
14
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15
15
  };
16
- import { IS_INLINE, LIST_TAGS } from "../../core/constants.js";
16
+ import { IS_INLINE, LIST_TAGS, MODE_SOURCE } from "../../core/constants.js";
17
17
  import { autobind, watch } from "../../core/decorators/index.js";
18
18
  import { Dom } from "../../core/dom/dom.js";
19
- import { pluginSystem } from "../../core/global.js";
19
+ import { getContainer, pluginSystem } from "../../core/global.js";
20
20
  import { toArray } from "../../core/helpers/array/to-array.js";
21
21
  import { camelCase } from "../../core/helpers/string/camel-case.js";
22
+ import { trim } from "../../core/helpers/string/trim.js";
23
+ import { cssPath } from "../../core/helpers/utils/selector.js";
22
24
  import { Plugin } from "../../core/plugin/index.js";
23
25
  import { Popup, UIElement } from "../../core/ui/index.js";
24
26
  import "./config.js";
27
+ const MEDIA = 'video, iframe, audio, object, embed';
28
+ // The shade the browsers lay over a selected image: #b5d6fd on white
29
+ const SHADE = `url("data:image/svg+xml,${encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg'>" +
30
+ "<filter id='s' x='0' y='0' width='1' height='1' color-interpolation-filters='sRGB'>" +
31
+ "<feFlood flood-color='#84bbfc' flood-opacity='.6'/><feComposite in2='SourceGraphic'/>" +
32
+ '</filter></svg>')}#s")`;
25
33
  /**
26
34
  * A utility plugin that allows you to subscribe to a click/mousedown/touchstart/mouseup on an element in DOM order
27
35
  *
@@ -43,6 +51,7 @@ export class select extends Plugin {
43
51
  'mouseup',
44
52
  'touchend'
45
53
  ];
54
+ this.__selectedMediaStyle = '';
46
55
  /**
47
56
  * Where the last press started. Chrome reports a drag that begins in one
48
57
  * element and ends in another as a `click` on their common ancestor, so a
@@ -60,6 +69,7 @@ export class select extends Plugin {
60
69
  jodit.e.on(eventName + '.select', this.onStartSelection);
61
70
  });
62
71
  jodit.e.on('dblclick', this.__onDblClickBesideRow, { top: true });
72
+ jodit.e.on(jodit.ed, 'selectionchange', this.__markSelectedMedia);
63
73
  }
64
74
  beforeDestruct(jodit) {
65
75
  this.proxyEventsList.forEach(eventName => {
@@ -67,6 +77,45 @@ export class select extends Plugin {
67
77
  });
68
78
  this.__endPressBesideRow();
69
79
  jodit.e.off('dblclick', this.__onDblClickBesideRow);
80
+ jodit.e.off(jodit.ed, 'selectionchange', this.__markSelectedMedia);
81
+ }
82
+ /**
83
+ * The browsers shade an image in the selection, but Chrome doesn't shade
84
+ * a video with controls, or one in a `jodit-media` wrapper, so a selection
85
+ * that took one in didn't show it, and typing deleted it unseen (#1768).
86
+ * The media gets the same shade from a filter, in place of the tint Safari
87
+ * gives a block wrapper's whole line. It's a style in the editing
88
+ * document, as selected cells get their border, so the content, and with
89
+ * it the value, the history and a copy, doesn't change. Media a click
90
+ * selected whole is left alone, as its resize frame shows it (#1528). A
91
+ * change, read-only and the source mode redo or drop the style, as the
92
+ * selection may not change with them, and the style's paths could then
93
+ * fit other elements
94
+ */
95
+ __markSelectedMedia() {
96
+ var _a;
97
+ const { s, editor, o } = this.j;
98
+ const range = ((_a = s.sel) === null || _a === void 0 ? void 0 : _a.rangeCount) ? s.sel.getRangeAt(0) : null;
99
+ const rules = [];
100
+ if (range &&
101
+ !range.collapsed &&
102
+ !o.readonly &&
103
+ this.j.getMode() !== MODE_SOURCE &&
104
+ !isElementSelection(range) &&
105
+ Dom.isOrContains(editor, range.commonAncestorContainer)) {
106
+ uneditableIn(range, editor).forEach(elm => {
107
+ const media = elm.querySelector(MEDIA);
108
+ const wrapper = cssPath(elm);
109
+ if (media && wrapper) {
110
+ rules.push(`${wrapper}::selection,${wrapper} ::selection{background:transparent}`, `${cssPath(media)}{filter:${SHADE}}`);
111
+ }
112
+ });
113
+ }
114
+ const style = rules.join('');
115
+ if (style !== this.__selectedMediaStyle) {
116
+ this.__selectedMediaStyle = style;
117
+ getContainer(this.j, select, 'style', true).textContent = style;
118
+ }
70
119
  }
71
120
  onStartSelection(e) {
72
121
  const { j } = this;
@@ -96,6 +145,10 @@ export class select extends Plugin {
96
145
  if (pressed && UIElement.closestElement(pressed, Popup)) {
97
146
  return;
98
147
  }
148
+ // An item of a list that closed once it was chosen was in a popup
149
+ if (Dom.isNode(node) && !node.isConnected) {
150
+ return;
151
+ }
99
152
  const box = UIElement.closestElement(node, Popup);
100
153
  if (!box) {
101
154
  this.j.e.fire('outsideClick', e);
@@ -324,6 +377,94 @@ export class select extends Plugin {
324
377
  startContainer, true);
325
378
  }
326
379
  }
380
+ /**
381
+ * A double click past the end of a line selects only its line break, up
382
+ * to the start of the next line a caret can go on. The browsers show no
383
+ * caret for it, and typing replaces the break, joining the lines and
384
+ * taking any video in between with it (#1768). Put the caret at the end
385
+ * of the line instead
386
+ */
387
+ onDblClickPastLineEnd() {
388
+ const { s, editor, o } = this.j;
389
+ const range = s.range;
390
+ if (o.readonly ||
391
+ !Dom.isOrContains(editor, range.commonAncestorContainer) ||
392
+ !isLineBreak(range, editor)) {
393
+ return;
394
+ }
395
+ range.collapse(true);
396
+ s.selectRange(range);
397
+ }
398
+ /**
399
+ * The browsers have no caret position beside an uneditable block alone
400
+ * on its line, such as a video, so a drag that ends on its line runs on
401
+ * past it, and typing deletes it (#1768). Until the pointer has passed
402
+ * the block, the selection stops at the last caret place in the block
403
+ * before its line, or for a drag upwards at the first in the block after
404
+ */
405
+ onMouseUpOnUneditableLine(e) {
406
+ var _a, _b;
407
+ const { s, editor, o } = this.j;
408
+ const { sel } = s;
409
+ if (o.readonly || !(sel === null || sel === void 0 ? void 0 : sel.rangeCount) || sel.isCollapsed) {
410
+ return;
411
+ }
412
+ const range = sel.getRangeAt(0).cloneRange();
413
+ // A video or image Jodit selected itself on the press
414
+ if (isElementSelection(range)) {
415
+ return;
416
+ }
417
+ const forward = sel.anchorNode === range.startContainer &&
418
+ sel.anchorOffset === range.startOffset;
419
+ const lines = uneditableIn(range, editor)
420
+ .map(elm => { var _a; return (_a = Dom.closest(elm, Dom.isBlock, editor)) !== null && _a !== void 0 ? _a : elm; })
421
+ .filter(line => !trim(ownText(line)));
422
+ const isAhead = (line) => {
423
+ const box = line.getBoundingClientRect();
424
+ return forward ? e.clientY < box.bottom : e.clientY > box.top;
425
+ };
426
+ const line = forward
427
+ ? lines.find(isAhead)
428
+ : lines.reverse().find(isAhead);
429
+ if (!line) {
430
+ return;
431
+ }
432
+ // Where a caret can go: in text, or before a <br>
433
+ const isCaretPlace = (node) => (Dom.isText(node) && !Dom.isEmptyTextNode(node)) ||
434
+ Dom.isTag(node, 'br');
435
+ // Only the block beside the line, not one further on
436
+ const beside = Dom.findNotEmptySibling(line, forward);
437
+ const place = Dom.isBlock(beside)
438
+ ? forward
439
+ ? Dom.last(beside, isCaretPlace)
440
+ : Dom.first(beside, isCaretPlace)
441
+ : null;
442
+ if (!place) {
443
+ return;
444
+ }
445
+ if (Dom.isText(place)) {
446
+ if (forward) {
447
+ range.setEnd(place, (_b = (_a = place.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
448
+ }
449
+ else {
450
+ range.setStart(place, 0);
451
+ }
452
+ }
453
+ else if (forward) {
454
+ range.setEndBefore(place);
455
+ }
456
+ else {
457
+ range.setStartBefore(place);
458
+ }
459
+ // The drag's start stays the anchor
460
+ const { startContainer, startOffset, endContainer, endOffset } = range;
461
+ if (forward) {
462
+ sel.setBaseAndExtent(startContainer, startOffset, endContainer, endOffset);
463
+ }
464
+ else {
465
+ sel.setBaseAndExtent(endContainer, endOffset, startContainer, startOffset);
466
+ }
467
+ }
327
468
  onCopyNormalizeSelectionBound(e) {
328
469
  const { s, editor, o } = this.j;
329
470
  if (!o.select.normalizeSelectionBeforeCutAndCopy || s.isCollapsed()) {
@@ -338,6 +479,10 @@ export class select extends Plugin {
338
479
  this.jodit.s.expandSelection();
339
480
  }
340
481
  }
482
+ __decorate([
483
+ watch([':change', ':readonly', ':afterSetMode']),
484
+ autobind
485
+ ], select.prototype, "__markSelectedMedia", null);
341
486
  __decorate([
342
487
  autobind
343
488
  ], select.prototype, "onStartSelection", null);
@@ -374,7 +519,95 @@ __decorate([
374
519
  __decorate([
375
520
  watch([':click'])
376
521
  ], select.prototype, "onTripleClickNormalizeSelection", null);
522
+ __decorate([
523
+ watch([':dblclick'])
524
+ ], select.prototype, "onDblClickPastLineEnd", null);
525
+ __decorate([
526
+ watch([':mouseup'])
527
+ ], select.prototype, "onMouseUpOnUneditableLine", null);
377
528
  __decorate([
378
529
  watch([':copy', ':cut'])
379
530
  ], select.prototype, "onCopyNormalizeSelectionBound", null);
531
+ const isUneditable = (node) => Dom.isElement(node) && node.getAttribute('contenteditable') === 'false';
532
+ /**
533
+ * The text a node shows outside its uneditable elements, whose own text, as
534
+ * a video's fallback text, isn't on the line
535
+ */
536
+ const ownText = (node) => {
537
+ var _a;
538
+ return isUneditable(node)
539
+ ? ''
540
+ : Dom.isText(node)
541
+ ? ((_a = node.nodeValue) !== null && _a !== void 0 ? _a : '')
542
+ : toArray(node.childNodes).map(ownText).join('');
543
+ };
544
+ /**
545
+ * The uneditable elements the range holds whole, without those inside
546
+ * another. Only those under the range's common ancestor can be, and none
547
+ * when that's a text node, as along one line of a drag
548
+ */
549
+ function uneditableIn(range, root) {
550
+ const box = range.commonAncestorContainer;
551
+ if (!Dom.isElement(box)) {
552
+ return [];
553
+ }
554
+ return toArray(box.querySelectorAll('[contenteditable="false"]')).filter(elm => {
555
+ if (!range.intersectsNode(elm)) {
556
+ return false;
557
+ }
558
+ const own = elm.ownerDocument.createRange();
559
+ own.selectNode(elm);
560
+ return (range.compareBoundaryPoints(Range.START_TO_START, own) <= 0 &&
561
+ range.compareBoundaryPoints(Range.END_TO_END, own) >= 0 &&
562
+ !Dom.closest(elm.parentNode, isUneditable, root));
563
+ });
564
+ }
565
+ /**
566
+ * The range holds one element and nothing else, as a selected image does
567
+ */
568
+ function isElementSelection(range) {
569
+ const { startContainer, startOffset, endContainer, endOffset } = range;
570
+ return (startContainer === endContainer &&
571
+ endOffset - startOffset === 1 &&
572
+ Dom.isElement(startContainer.childNodes[startOffset]));
573
+ }
574
+ /**
575
+ * The range holds a line end and nothing else: no characters but
576
+ * whitespace, and no element whole but a `<br>` or a line a caret can't go
577
+ * on, as a video's. It ends in another block, or holds the `<br>`
578
+ */
579
+ function isLineBreak(range, root) {
580
+ const { startContainer, endContainer } = range;
581
+ if (range.collapsed ||
582
+ (trim(range.toString()) && trim(ownText(range.cloneContents())))) {
583
+ return false;
584
+ }
585
+ let crossesLineEnd = Dom.closest(startContainer, Dom.isBlock, root) !==
586
+ Dom.closest(endContainer, Dom.isBlock, root);
587
+ const holdsBreaksOnly = (node) => {
588
+ if (!range.intersectsNode(node)) {
589
+ return true;
590
+ }
591
+ if (Dom.isOrContains(node, startContainer) ||
592
+ Dom.isOrContains(node, endContainer)) {
593
+ return toArray(node.childNodes).every(holdsBreaksOnly);
594
+ }
595
+ if (Dom.isTag(node, 'br')) {
596
+ crossesLineEnd = true;
597
+ return true;
598
+ }
599
+ return Dom.isText(node) || isCaretless(node);
600
+ };
601
+ return holdsBreaksOnly(range.commonAncestorContainer) && crossesLineEnd;
602
+ }
603
+ /**
604
+ * An uneditable element, or a block holding one and nothing else
605
+ */
606
+ function isCaretless(node) {
607
+ const children = toArray(node.childNodes);
608
+ return (isUneditable(node) ||
609
+ (Dom.isBlock(node) &&
610
+ children.some(isCaretless) &&
611
+ children.every(child => Dom.isEmptyTextNode(child) || isCaretless(child))));
612
+ }
380
613
  pluginSystem.add('select', select);
@@ -41,6 +41,11 @@ export declare class selectCells extends Plugin {
41
41
  */
42
42
  protected onKeyUp(): void;
43
43
  private __followCaret;
44
+ /**
45
+ * The box round the marked cells, which their popup opens beside and
46
+ * follows when its commands add, merge or replace cells
47
+ */
48
+ private __markedBound;
44
49
  /**
45
50
  * First selected cell
46
51
  */
@@ -71,6 +76,12 @@ export declare class selectCells extends Plugin {
71
76
  * cells, the browser's own selection from the drag goes
72
77
  */
73
78
  private __onClickAfterDrag;
79
+ /**
80
+ * The last press or key went to a popup, as to the cell popup's own
81
+ * controls, whose changes keep the cells marked
82
+ */
83
+ private __inPopup;
84
+ protected onPress(e?: Event): void;
74
85
  protected onChange(): void;
75
86
  /**
76
87
  * Mouse move inside the table
@@ -20,6 +20,7 @@ import { pluginSystem } from "../../core/global.js";
20
20
  import { $$, alignElement, position, toArray } from "../../core/helpers/index.js";
21
21
  import { Plugin } from "../../core/plugin/index.js";
22
22
  import { isMoved } from "../../core/selection/helpers/index.js";
23
+ import { Popup, UIElement } from "../../core/ui/index.js";
23
24
  import { Table } from "../../modules/table/table.js";
24
25
  import "./config.js";
25
26
  const key = 'table_processor_observer';
@@ -52,6 +53,11 @@ export class selectCells extends Plugin {
52
53
  * would unmark its cells
53
54
  */
54
55
  this.__keepMarks = false;
56
+ /**
57
+ * The last press or key went to a popup, as to the cell popup's own
58
+ * controls, whose changes keep the cells marked
59
+ */
60
+ this.__inPopup = false;
55
61
  }
56
62
  /**
57
63
  * Shortcut for Jodit.modules.Table
@@ -152,7 +158,22 @@ export class selectCells extends Plugin {
152
158
  // As after a click, the first change to the cell keeps the mark
153
159
  this.__selectedCell = cell;
154
160
  this.__tableModule.addSelection(cell);
155
- this.j.e.fire('showPopup', table, () => position(cell, this.j), 'cells');
161
+ this.j.e.fire('showPopup', table, this.__markedBound, 'cells');
162
+ }
163
+ /**
164
+ * The box round the marked cells, which their popup opens beside and
165
+ * follows when its commands add, merge or replace cells
166
+ */
167
+ __markedBound() {
168
+ const bounds = this.__tableModule
169
+ .getAllSelectedCells()
170
+ .filter(cell => cell.isConnected)
171
+ .map(cell => position(cell, this.j));
172
+ if (!bounds.length) {
173
+ return { left: 0, top: 0, width: 0, height: 0 };
174
+ }
175
+ const left = Math.min(...bounds.map(b => b.left)), top = Math.min(...bounds.map(b => b.top)), right = Math.max(...bounds.map(b => b.left + b.width)), bottom = Math.max(...bounds.map(b => b.top + b.height));
176
+ return { left, top, width: right - left, height: bottom - top };
156
177
  }
157
178
  /**
158
179
  * Mouse click inside the table
@@ -182,7 +203,7 @@ export class selectCells extends Plugin {
182
203
  this.__selectedCell = cell;
183
204
  (_a = this.j.s.sel) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
184
205
  if (this.__tableModule.getAllSelectedCells().length) {
185
- this.j.e.fire('showPopup', table, () => position(cell, this.j), 'cells');
206
+ this.j.e.fire('showPopup', table, this.__markedBound, 'cells');
186
207
  }
187
208
  else {
188
209
  this.j.e.fire('hidePopup', 'cells');
@@ -231,8 +252,13 @@ export class selectCells extends Plugin {
231
252
  return false;
232
253
  }
233
254
  }
255
+ onPress(e) {
256
+ this.__inPopup = Boolean(e &&
257
+ Dom.isNode(e.target) &&
258
+ UIElement.closestElement(e.target, Popup));
259
+ }
234
260
  onChange() {
235
- if (!this.j.isLocked && !this.__isSelectionMode) {
261
+ if (!this.j.isLocked && !this.__isSelectionMode && !this.__inPopup) {
236
262
  this.__onRemoveSelection();
237
263
  }
238
264
  }
@@ -351,15 +377,7 @@ export class selectCells extends Plugin {
351
377
  if (!min || !max) {
352
378
  return;
353
379
  }
354
- this.j.e.fire('showPopup', table, () => {
355
- const minOffset = position(min, this.j), maxOffset = position(max, this.j);
356
- return {
357
- left: minOffset.left,
358
- top: minOffset.top,
359
- width: maxOffset.left - minOffset.left + maxOffset.width,
360
- height: maxOffset.top - minOffset.top + maxOffset.height
361
- };
362
- }, 'cells');
380
+ this.j.e.fire('showPopup', table, this.__markedBound, 'cells');
363
381
  }
364
382
  __stopListening() {
365
383
  $$('table', this.j.editor).forEach(table => {
@@ -474,6 +492,11 @@ export class selectCells extends Plugin {
474
492
  this.__toggleHeaderRow(table, cells);
475
493
  break;
476
494
  }
495
+ // A split unmarks the cells. They stay marked, as after the
496
+ // other commands, so their popup stays beside them
497
+ if (/^split/.test(command)) {
498
+ cells.forEach(cell => this.__tableModule.addSelection(cell));
499
+ }
477
500
  if (/^bin(row|column)$/.test(command) &&
478
501
  !this.__tableModule.getColumnsCount(table)) {
479
502
  this.__removeTable(table);
@@ -487,7 +510,6 @@ export class selectCells extends Plugin {
487
510
  * move to the cells that replace them
488
511
  */
489
512
  __toggleHeaderRow(table, cells) {
490
- var _a, _b;
491
513
  const module = this.__tableModule;
492
514
  this.j.s.save();
493
515
  const replaced = module.toggleHeaderRow(table);
@@ -499,10 +521,6 @@ export class selectCells extends Plugin {
499
521
  module.addSelection(next);
500
522
  }
501
523
  });
502
- // As after the click that marked it, the command's own change keeps
503
- // the marks, so the popup can stay open for another toggle
504
- const anchor = (_a = this.__selectedCell) !== null && _a !== void 0 ? _a : cells[0];
505
- this.__selectedCell = (_b = replaced.get(anchor)) !== null && _b !== void 0 ? _b : anchor;
506
524
  }
507
525
  /**
508
526
  * The cell that takes the caret when rows or columns are deleted: the next
@@ -565,6 +583,9 @@ __decorate([
565
583
  __decorate([
566
584
  watch(':keyup')
567
585
  ], selectCells.prototype, "onKeyUp", null);
586
+ __decorate([
587
+ autobind
588
+ ], selectCells.prototype, "__markedBound", null);
568
589
  __decorate([
569
590
  autobind
570
591
  ], selectCells.prototype, "onStartSelection", null);
@@ -577,6 +598,16 @@ __decorate([
577
598
  __decorate([
578
599
  autobind
579
600
  ], selectCells.prototype, "__onClickAfterDrag", null);
601
+ __decorate([
602
+ watch([
603
+ 'ow:mousedown',
604
+ 'ow:touchstart',
605
+ 'ow:keydown',
606
+ ':mousedown',
607
+ ':touchstart',
608
+ ':keydown'
609
+ ])
610
+ ], selectCells.prototype, "onPress", null);
580
611
  __decorate([
581
612
  watch(':change')
582
613
  ], selectCells.prototype, "onChange", null);
@@ -41,7 +41,7 @@ declare module 'jodit/config' {
41
41
  * Jodit.make('#editor', {
42
42
  * video: {
43
43
  * defaultHandlerSuccess(data) {
44
- * data.files.forEach(file => {
44
+ * data.items.forEach(({ file }) => {
45
45
  * this.s.insertHTML(`<video controls preload="metadata" src="${data.baseurl + file}"></video>`);
46
46
  * });
47
47
  * }
@@ -8,14 +8,15 @@ import { Button } from "../../core/ui/button/index.js";
8
8
  import { UIBlock, UIForm, UIInput, UITextArea } from "../../core/ui/form/index.js";
9
9
  import { Icon } from "../../core/ui/icon.js";
10
10
  import { Config } from "../../config.js";
11
+ import { getItems } from "../../modules/uploader/helpers/normalize-uploader-data.js";
11
12
  import { TabsWidget, UploadTab } from "../../modules/widget/index.js";
12
13
  import videoIcon from "./video.svg.js";
13
14
  function insertVideos(data) {
14
- var _a;
15
- (_a = data.files) === null || _a === void 0 ? void 0 : _a.forEach(file => {
15
+ const { baseurl } = data;
16
+ getItems(data).forEach(({ file }) => {
16
17
  this.s.insertNode(prepareMedia(this, this.createInside.element('video', {
17
18
  controls: '',
18
- src: data.baseurl + file
19
+ src: baseurl + file
19
20
  })));
20
21
  });
21
22
  }
@@ -16,12 +16,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
16
16
  import { cache, cached, watch } from "../../core/decorators/index.js";
17
17
  import { Dom } from "../../core/dom/dom.js";
18
18
  import { pluginSystem } from "../../core/global.js";
19
- import { isArray } from "../../core/helpers/checker/is-array.js";
20
19
  import { position } from "../../core/helpers/size/position.js";
21
20
  import { markOwner } from "../../core/helpers/utils/utils.js";
22
21
  import { Plugin } from "../../core/plugin/plugin.js";
23
22
  import { Button } from "../../core/ui/button/index.js";
24
23
  import { Popup } from "../../core/ui/popup/popup.js";
24
+ import { getItems } from "../../modules/uploader/helpers/normalize-uploader-data.js";
25
25
  import { FileSelectorWidget } from "../../modules/widget/file-selector/file-selector.js";
26
26
  import { UIVideoPropertiesForm } from "./ui/ui-video-form.js";
27
27
  import { editedMedia, readValues } from "./readers.js";
@@ -132,15 +132,16 @@ export class videoProperties extends Plugin {
132
132
  popup
133
133
  .setContent(FileSelectorWidget(j, {
134
134
  upload: (data) => {
135
- if (data.files && data.files.length) {
136
- state.values.poster =
137
- data.baseurl + data.files[0];
135
+ const [item] = getItems(data);
136
+ if (item) {
137
+ state.values.poster = data.baseurl + item.file;
138
138
  }
139
139
  close();
140
140
  },
141
141
  filebrowser: (data) => {
142
- if (isArray(data.files) && data.files.length) {
143
- state.values.poster = data.files[0];
142
+ const [item] = getItems(data);
143
+ if (item) {
144
+ state.values.poster = item.file;
144
145
  close();
145
146
  }
146
147
  }
@@ -0,0 +1 @@
1
+ export default "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"> <g fill=\"none\"> <path d=\"M6 3h12v18l-6-4-6 4z\"/> </g> </svg> ";
@@ -8,4 +8,4 @@
8
8
  * @packageDocumentation
9
9
  * @module icons
10
10
  */
11
- export { angle_down, angle_left, angle_right, angle_up, bin, cancel, center, check, chevron, dots, download, eraser, eye, file, folder, info_circle, left, lock, ok, pencil, plus, resize_handler, right, save, settings, unlock, update, upload, valign };
11
+ export { anchor, angle_down, angle_left, angle_right, angle_up, bin, cancel, center, check, chevron, dots, download, eraser, eye, file, folder, info_circle, left, lock, ok, pencil, plus, resize_handler, right, save, settings, unlock, update, upload, valign };
@@ -8,6 +8,7 @@
8
8
  * @packageDocumentation
9
9
  * @module icons
10
10
  */
11
+ import anchor from "./anchor.svg.js";
11
12
  import angle_down from "./angle-down.svg.js";
12
13
  import angle_left from "./angle-left.svg.js";
13
14
  import angle_right from "./angle-right.svg.js";
@@ -37,4 +38,4 @@ import unlock from "./unlock.svg.js";
37
38
  import update from "./update.svg.js";
38
39
  import upload from "./upload.svg.js";
39
40
  import valign from "./valign.svg.js";
40
- export { angle_down, angle_left, angle_right, angle_up, bin, cancel, center, check, chevron, dots, download, eraser, eye, file, folder, info_circle, left, lock, ok, pencil, plus, resize_handler, right, save, settings, unlock, update, upload, valign };
41
+ export { anchor, angle_down, angle_left, angle_right, angle_up, bin, cancel, center, check, chevron, dots, download, eraser, eye, file, folder, info_circle, left, lock, ok, pencil, plus, resize_handler, right, save, settings, unlock, update, upload, valign };
@@ -7,7 +7,7 @@
7
7
  * @module types
8
8
  */
9
9
  import type { CanPromise, IDestructible, IDictionary, ImageBox, IPermissions, Nullable } from "./types";
10
- import type { IUploader, IUploaderOptions } from "./uploader";
10
+ import type { IUploadedFile, IUploader, IUploaderOptions } from "./uploader";
11
11
  import type { IViewOptions, IViewWithToolbar } from "./view";
12
12
  import type { IUIGroup } from "./ui";
13
13
  import type { IObservable } from "./events";
@@ -140,7 +140,14 @@ export interface IFileBrowserOptions extends IViewOptions {
140
140
  }
141
141
  export interface IFileBrowserCallBackData {
142
142
  baseurl: string;
143
+ /**
144
+ * One object per file. In 4.x the arrays win while `files` is set, as in
145
+ * the uploader's data
146
+ */
147
+ items?: IUploadedFile[];
148
+ /** @deprecated Use `items` instead. Removed in 5.0 */
143
149
  files: string[];
150
+ /** @deprecated Use `items` instead. Removed in 5.0 */
144
151
  isImages?: boolean[];
145
152
  }
146
153
  interface IFileBrowserDataProviderItemsMods {
@@ -13,6 +13,7 @@ export interface IPopup extends IUIElement, IDestructible {
13
13
  readonly container: HTMLElement;
14
14
  readonly isOpened: boolean;
15
15
  readonly strategy: PopupStrategy;
16
+ keepOpen?: boolean;
16
17
  viewBound: () => IBound;
17
18
  open(getBound: () => IBound, keepPosition?: boolean, parentContainer?: HTMLElement): this;
18
19
  setContent(content: IUIElement | HTMLElement | string): this;