jodit 4.18.12 → 4.19.4

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 (255) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/es2015/jodit.css +10 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +18 -12
  5. package/es2015/jodit.js +2464 -300
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +18 -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 +18 -12
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +18 -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 +10 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +26 -19
  23. package/es2021/jodit.js +2426 -297
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +26 -19
  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 +10 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +29 -22
  35. package/es2021.en/jodit.js +2400 -271
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +29 -22
  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 +11 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +2823 -360
  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 +44 -1
  60. package/esm/config.js +2 -1
  61. package/esm/core/constants.js +1 -1
  62. package/esm/core/dom/dom.js +4 -2
  63. package/esm/core/event-emitter/event-emitter.js +1 -0
  64. package/esm/core/helpers/utils/align.d.ts +6 -1
  65. package/esm/core/helpers/utils/align.js +22 -12
  66. package/esm/core/helpers/utils/image-caption.d.ts +24 -0
  67. package/esm/core/helpers/utils/image-caption.js +43 -0
  68. package/esm/core/helpers/utils/index.d.ts +1 -0
  69. package/esm/core/helpers/utils/index.js +1 -0
  70. package/esm/core/selection/selection.d.ts +3 -0
  71. package/esm/core/selection/selection.js +20 -5
  72. package/esm/core/ui/helpers/focus-form-field.d.ts +12 -0
  73. package/esm/core/ui/helpers/focus-form-field.js +21 -0
  74. package/esm/jodit.js +18 -2
  75. package/esm/langs/ar.d.ts +2 -0
  76. package/esm/langs/ar.js +2 -0
  77. package/esm/langs/az.d.ts +2 -0
  78. package/esm/langs/az.js +2 -0
  79. package/esm/langs/cs_cz.d.ts +2 -0
  80. package/esm/langs/cs_cz.js +2 -0
  81. package/esm/langs/de.d.ts +2 -0
  82. package/esm/langs/de.js +2 -0
  83. package/esm/langs/es.d.ts +2 -0
  84. package/esm/langs/es.js +2 -0
  85. package/esm/langs/fa.d.ts +2 -0
  86. package/esm/langs/fa.js +2 -0
  87. package/esm/langs/fi.d.ts +2 -0
  88. package/esm/langs/fi.js +2 -0
  89. package/esm/langs/fr.d.ts +2 -0
  90. package/esm/langs/fr.js +2 -0
  91. package/esm/langs/he.d.ts +2 -0
  92. package/esm/langs/he.js +2 -0
  93. package/esm/langs/hu.d.ts +2 -0
  94. package/esm/langs/hu.js +2 -0
  95. package/esm/langs/id.d.ts +2 -0
  96. package/esm/langs/id.js +2 -0
  97. package/esm/langs/it.d.ts +2 -0
  98. package/esm/langs/it.js +2 -0
  99. package/esm/langs/ja.d.ts +2 -0
  100. package/esm/langs/ja.js +2 -0
  101. package/esm/langs/ko.d.ts +2 -0
  102. package/esm/langs/ko.js +2 -0
  103. package/esm/langs/mn.d.ts +2 -0
  104. package/esm/langs/mn.js +2 -0
  105. package/esm/langs/nl.d.ts +2 -0
  106. package/esm/langs/nl.js +2 -0
  107. package/esm/langs/no.d.ts +2 -0
  108. package/esm/langs/no.js +2 -0
  109. package/esm/langs/pl.d.ts +2 -0
  110. package/esm/langs/pl.js +2 -0
  111. package/esm/langs/pt_br.d.ts +2 -0
  112. package/esm/langs/pt_br.js +2 -0
  113. package/esm/langs/ru.d.ts +2 -0
  114. package/esm/langs/ru.js +2 -0
  115. package/esm/langs/sk.d.ts +2 -0
  116. package/esm/langs/sk.js +2 -0
  117. package/esm/langs/sv.d.ts +2 -0
  118. package/esm/langs/sv.js +2 -0
  119. package/esm/langs/tr.d.ts +2 -0
  120. package/esm/langs/tr.js +2 -0
  121. package/esm/langs/ua.d.ts +2 -0
  122. package/esm/langs/ua.js +2 -0
  123. package/esm/langs/zh_cn.d.ts +2 -0
  124. package/esm/langs/zh_cn.js +2 -0
  125. package/esm/langs/zh_tw.d.ts +2 -0
  126. package/esm/langs/zh_tw.js +2 -0
  127. package/esm/modules/table/table.d.ts +27 -0
  128. package/esm/modules/table/table.js +110 -2
  129. package/esm/modules/toolbar/button/button.js +11 -3
  130. package/esm/modules/uploader/helpers/send-files.js +3 -1
  131. package/esm/modules/widget/tabs/tabs.js +2 -0
  132. package/esm/plugins/all.d.ts +1 -0
  133. package/esm/plugins/all.js +1 -0
  134. package/esm/plugins/backspace/backspace.js +17 -1
  135. package/esm/plugins/backspace/cases/check-remove-char.js +1 -11
  136. package/esm/plugins/backspace/helpers.d.ts +5 -0
  137. package/esm/plugins/backspace/helpers.js +11 -0
  138. package/esm/plugins/clean-html/clean-html.js +2 -2
  139. package/esm/plugins/clean-html/helpers/index.d.ts +1 -0
  140. package/esm/plugins/clean-html/helpers/index.js +1 -0
  141. package/esm/plugins/clean-html/helpers/remove-format/remove-format-for-word.d.ts +16 -0
  142. package/esm/plugins/clean-html/helpers/remove-format/remove-format-for-word.js +109 -0
  143. package/esm/plugins/drag-and-drop-element/drag-and-drop-element.js +4 -2
  144. package/esm/plugins/format-block/config.d.ts +13 -0
  145. package/esm/plugins/format-block/config.js +38 -1
  146. package/esm/plugins/format-block/content-fonts.d.ts +17 -0
  147. package/esm/plugins/format-block/content-fonts.js +156 -0
  148. package/esm/plugins/image-caption/config.d.ts +31 -0
  149. package/esm/plugins/image-caption/config.js +11 -0
  150. package/esm/plugins/image-caption/image-caption.d.ts +140 -0
  151. package/esm/plugins/image-caption/image-caption.js +799 -0
  152. package/esm/plugins/image-processor/image-processor.d.ts +2 -1
  153. package/esm/plugins/image-processor/image-processor.js +9 -4
  154. package/esm/plugins/image-properties/config.js +1 -0
  155. package/esm/plugins/image-properties/image-properties.js +19 -5
  156. package/esm/plugins/image-properties/interface.d.ts +6 -0
  157. package/esm/plugins/image-properties/readers/align.d.ts +1 -1
  158. package/esm/plugins/image-properties/readers/index.js +9 -3
  159. package/esm/plugins/image-properties/readers/margin.d.ts +1 -1
  160. package/esm/plugins/image-properties/readers/size.d.ts +5 -1
  161. package/esm/plugins/image-properties/readers/size.js +4 -5
  162. package/esm/plugins/image-properties/ui/ui-image-main-tab.d.ts +2 -0
  163. package/esm/plugins/image-properties/ui/ui-image-main-tab.js +20 -0
  164. package/esm/plugins/image-properties/writers/caption.d.ts +15 -0
  165. package/esm/plugins/image-properties/writers/caption.js +18 -0
  166. package/esm/plugins/image-properties/writers/index.js +15 -10
  167. package/esm/plugins/image-properties/writers/link.js +7 -2
  168. package/esm/plugins/image-properties/writers/margin.d.ts +1 -1
  169. package/esm/plugins/image-properties/writers/size.d.ts +5 -2
  170. package/esm/plugins/image-properties/writers/size.js +16 -2
  171. package/esm/plugins/indent/helpers.d.ts +9 -0
  172. package/esm/plugins/indent/helpers.js +23 -3
  173. package/esm/plugins/indent/indent.js +2 -20
  174. package/esm/plugins/index.d.ts +1 -0
  175. package/esm/plugins/inline-popup/config/config.js +4 -0
  176. package/esm/plugins/inline-popup/config/items/cells.js +29 -0
  177. package/esm/plugins/inline-popup/config/items/img.js +35 -5
  178. package/esm/plugins/inline-popup/icons/caption.svg.js +1 -0
  179. package/esm/plugins/inline-popup/icons/headerrow.svg.js +1 -0
  180. package/esm/plugins/inline-popup/inline-popup.js +3 -2
  181. package/esm/plugins/placeholder/placeholder.js +7 -1
  182. package/esm/plugins/resize-cells/resize-cells.d.ts +49 -0
  183. package/esm/plugins/resize-cells/resize-cells.js +247 -13
  184. package/esm/plugins/resizer/resizer.js +13 -2
  185. package/esm/plugins/select-cells/select-cells.d.ts +5 -0
  186. package/esm/plugins/select-cells/select-cells.js +29 -11
  187. package/esm/plugins/tab/cases/index.d.ts +1 -0
  188. package/esm/plugins/tab/cases/index.js +1 -0
  189. package/esm/plugins/tab/cases/on-tab-inside-li.js +3 -1
  190. package/esm/plugins/tab/cases/tab-spaces.d.ts +32 -0
  191. package/esm/plugins/tab/cases/tab-spaces.js +263 -0
  192. package/esm/plugins/tab/config.d.ts +10 -0
  193. package/esm/plugins/tab/config.js +2 -1
  194. package/esm/plugins/tab/tab.js +61 -6
  195. package/esm/types/types.d.ts +16 -0
  196. package/esm/types/uploader.d.ts +6 -0
  197. package/package.json +1 -1
  198. package/types/config.d.ts +44 -1
  199. package/types/core/helpers/utils/align.d.ts +6 -1
  200. package/types/core/helpers/utils/image-caption.d.ts +24 -0
  201. package/types/core/helpers/utils/index.d.ts +1 -0
  202. package/types/core/selection/selection.d.ts +3 -0
  203. package/types/core/ui/helpers/focus-form-field.d.ts +12 -0
  204. package/types/langs/ar.d.ts +2 -0
  205. package/types/langs/az.d.ts +2 -0
  206. package/types/langs/cs_cz.d.ts +2 -0
  207. package/types/langs/de.d.ts +2 -0
  208. package/types/langs/es.d.ts +2 -0
  209. package/types/langs/fa.d.ts +2 -0
  210. package/types/langs/fi.d.ts +2 -0
  211. package/types/langs/fr.d.ts +2 -0
  212. package/types/langs/he.d.ts +2 -0
  213. package/types/langs/hu.d.ts +2 -0
  214. package/types/langs/id.d.ts +2 -0
  215. package/types/langs/it.d.ts +2 -0
  216. package/types/langs/ja.d.ts +2 -0
  217. package/types/langs/ko.d.ts +2 -0
  218. package/types/langs/mn.d.ts +2 -0
  219. package/types/langs/nl.d.ts +2 -0
  220. package/types/langs/no.d.ts +2 -0
  221. package/types/langs/pl.d.ts +2 -0
  222. package/types/langs/pt_br.d.ts +2 -0
  223. package/types/langs/ru.d.ts +2 -0
  224. package/types/langs/sk.d.ts +2 -0
  225. package/types/langs/sv.d.ts +2 -0
  226. package/types/langs/tr.d.ts +2 -0
  227. package/types/langs/ua.d.ts +2 -0
  228. package/types/langs/zh_cn.d.ts +2 -0
  229. package/types/langs/zh_tw.d.ts +2 -0
  230. package/types/modules/table/table.d.ts +27 -0
  231. package/types/plugins/backspace/helpers.d.ts +5 -0
  232. package/types/plugins/clean-html/helpers/index.d.ts +1 -0
  233. package/types/plugins/clean-html/helpers/remove-format/remove-format-for-word.d.ts +16 -0
  234. package/types/plugins/format-block/config.d.ts +13 -0
  235. package/types/plugins/format-block/content-fonts.d.ts +17 -0
  236. package/types/plugins/image-caption/config.d.ts +31 -0
  237. package/types/plugins/image-caption/image-caption.d.ts +140 -0
  238. package/types/plugins/image-processor/image-processor.d.ts +2 -1
  239. package/types/plugins/image-properties/interface.d.ts +6 -0
  240. package/types/plugins/image-properties/readers/align.d.ts +1 -1
  241. package/types/plugins/image-properties/readers/margin.d.ts +1 -1
  242. package/types/plugins/image-properties/readers/size.d.ts +5 -1
  243. package/types/plugins/image-properties/ui/ui-image-main-tab.d.ts +2 -0
  244. package/types/plugins/image-properties/writers/caption.d.ts +15 -0
  245. package/types/plugins/image-properties/writers/margin.d.ts +1 -1
  246. package/types/plugins/image-properties/writers/size.d.ts +5 -2
  247. package/types/plugins/indent/helpers.d.ts +9 -0
  248. package/types/plugins/index.d.ts +1 -0
  249. package/types/plugins/resize-cells/resize-cells.d.ts +49 -0
  250. package/types/plugins/select-cells/select-cells.d.ts +5 -0
  251. package/types/plugins/tab/cases/index.d.ts +1 -0
  252. package/types/plugins/tab/cases/tab-spaces.d.ts +32 -0
  253. package/types/plugins/tab/config.d.ts +10 -0
  254. package/types/types/types.d.ts +16 -0
  255. package/types/types/uploader.d.ts +6 -0
@@ -77,8 +77,9 @@ export class selectCells extends Plugin {
77
77
  .map(e => e + '.select-cells')
78
78
  .join(' '), this.onStartSelection)
79
79
  // For `clickEditor` correct working. Because `mousedown` on first cell
80
- // and mouseup on another cell call `click` only for `TR` element.
81
- .on('clickTr clickTbody', () => {
80
+ // and mouseup on another cell call `click` only for their common
81
+ // ancestor: the row, the section, or the table across sections
82
+ .on('clickTr clickTbody clickThead clickTfoot clickTable', () => {
82
83
  var _a;
83
84
  const cellsCount = this.__tableModule.getAllSelectedCells().length;
84
85
  if (cellsCount) {
@@ -251,14 +252,6 @@ export class selectCells extends Plugin {
251
252
  }
252
253
  this.j.e.fire('hidePopup');
253
254
  e.stopPropagation();
254
- // Hack for FireFox for force redraw selection
255
- (() => {
256
- const n = this.j.createInside.fromHTML('<div style="color:rgba(0,0,0,0.01);width:0;height:0">&nbsp;</div>');
257
- Dom.append(cell, n);
258
- this.j.async.setTimeout(() => {
259
- Dom.safeRemove(n);
260
- }, this.j.defaultTimeout / 5);
261
- })();
262
255
  }
263
256
  /**
264
257
  * On click in outside - remove selection
@@ -361,7 +354,7 @@ export class selectCells extends Plugin {
361
354
  this.j.synchronizeValues();
362
355
  return false;
363
356
  }
364
- if (/table(splitv|splitg|merge|empty|bin|binrow|bincolumn|addcolumn|addrow)/.test(command)) {
357
+ if (/table(splitv|splitg|merge|empty|bin|binrow|bincolumn|addcolumn|addrow|headerrow)/.test(command)) {
365
358
  command = command.replace('table', '');
366
359
  const cells = this.__tableModule.getAllSelectedCells();
367
360
  if (cells.length) {
@@ -430,6 +423,9 @@ export class selectCells extends Plugin {
430
423
  case 'addrowbefore':
431
424
  this.__tableModule.appendRow(table, cell.parentNode, command === 'addrowafter');
432
425
  break;
426
+ case 'headerrow':
427
+ this.__toggleHeaderRow(table, cells);
428
+ break;
433
429
  }
434
430
  if (/^bin(row|column)$/.test(command) &&
435
431
  !this.__tableModule.getColumnsCount(table)) {
@@ -439,6 +435,28 @@ export class selectCells extends Plugin {
439
435
  return false;
440
436
  }
441
437
  }
438
+ /**
439
+ * Turns the table's header row on or off. The caret and the marked cells
440
+ * move to the cells that replace them
441
+ */
442
+ __toggleHeaderRow(table, cells) {
443
+ var _a, _b;
444
+ const module = this.__tableModule;
445
+ this.j.s.save();
446
+ const replaced = module.toggleHeaderRow(table);
447
+ this.j.s.restore();
448
+ cells.forEach(cell => {
449
+ const next = replaced.get(cell);
450
+ if (next) {
451
+ module.removeSelection(cell);
452
+ module.addSelection(next);
453
+ }
454
+ });
455
+ // As after the click that marked it, the command's own change keeps
456
+ // the marks, so the popup can stay open for another toggle
457
+ const anchor = (_a = this.__selectedCell) !== null && _a !== void 0 ? _a : cells[0];
458
+ this.__selectedCell = (_b = replaced.get(anchor)) !== null && _b !== void 0 ? _b : anchor;
459
+ }
442
460
  /**
443
461
  * The cell that takes the caret when rows or columns are deleted: the next
444
462
  * one in the same column (or row) that is not deleted, else the previous one
@@ -7,3 +7,4 @@
7
7
  * @module plugins/tab
8
8
  */
9
9
  export * from "./on-tab-inside-li";
10
+ export * from "./tab-spaces";
@@ -7,3 +7,4 @@
7
7
  * @module plugins/tab
8
8
  */
9
9
  export * from "./on-tab-inside-li.js";
10
+ export * from "./tab-spaces.js";
@@ -11,7 +11,9 @@ import { assert } from "../../../core/helpers/utils/assert.js";
11
11
  * @private
12
12
  */
13
13
  export function onTabInsideLi(jodit, shift = false) {
14
- if (!jodit.o.tab.tabInsideLiInsertNewList) {
14
+ // Focused with no range, as WebKit can leave it, there's no caret to
15
+ // mark
16
+ if (!jodit.o.tab.tabInsideLiInsertNewList || !jodit.s.isInsideArea) {
15
17
  return false;
16
18
  }
17
19
  const [fake, fake2] = fakeCursors(jodit);
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module plugins/tab
8
+ */
9
+ import type { IJodit } from "../../../types/index";
10
+ /**
11
+ * With `tab.spaces`, outside table cells: Tab at a caret inserts the spaces,
12
+ * or a tab where white space is kept, as in `pre`, and in a list's first item
13
+ * it indents the list, as Word does. Shift+Tab takes them out again. Tab or
14
+ * Shift+Tab with a selection indents or outdents it. Neither moves the focus
15
+ * on: Escape and then Tab does that
16
+ * @private
17
+ */
18
+ export declare function onTabSpaces(jodit: IJodit, shift: boolean): boolean;
19
+ /**
20
+ * With `tab.spaces`, Backspace just after that many spaces removes them
21
+ * together, as it would a tab. With `upTo`, as for Shift+Tab, fewer will do,
22
+ * if one of them is non-breaking, so a space between words stays
23
+ * @private
24
+ */
25
+ export declare function removeTabSpaces(jodit: IJodit, caret: Node, upTo?: boolean): boolean;
26
+ /**
27
+ * With `tab.spaces`, a tab in pasted text becomes the spaces, as HTML would
28
+ * show it as one space. Tabs in white space that's kept, and those that only
29
+ * lay out the HTML, stay as they are
30
+ * @private
31
+ */
32
+ export declare function tabsToSpaces(jodit: IJodit, html: string): string | void;
@@ -0,0 +1,263 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ import { INVISIBLE_SPACE, NBSP_SPACE } from "../../../core/constants.js";
7
+ import { Dom } from "../../../core/dom/dom.js";
8
+ import { cssInline } from "../../../core/helpers/utils/css.js";
9
+ import { addBRInsideEmptyBlock } from "../../backspace/helpers.js";
10
+ import { applyIndentToBox, getKey } from "../../indent/helpers.js";
11
+ const KEEPS_TABS = new Set(['pre', 'pre-wrap', 'break-spaces']);
12
+ const KEEPS_TABS_TAGS = new Set([
13
+ 'pre',
14
+ 'textarea',
15
+ 'style',
16
+ 'script'
17
+ ]);
18
+ /**
19
+ * With `tab.spaces`, outside table cells: Tab at a caret inserts the spaces,
20
+ * or a tab where white space is kept, as in `pre`, and in a list's first item
21
+ * it indents the list, as Word does. Shift+Tab takes them out again. Tab or
22
+ * Shift+Tab with a selection indents or outdents it. Neither moves the focus
23
+ * on: Escape and then Tab does that
24
+ * @private
25
+ */
26
+ export function onTabSpaces(jodit, shift) {
27
+ const { spaces } = jodit.o.tab;
28
+ const current = jodit.s.current();
29
+ if (!spaces || jodit.o.readonly || jodit.isLocked) {
30
+ return false;
31
+ }
32
+ // The editor has the focus but no caret, so there's nowhere to put
33
+ // anything, but the focus stays
34
+ if (!current) {
35
+ return true;
36
+ }
37
+ if (Dom.closest(current, Dom.isCell, jodit.editor)) {
38
+ return false;
39
+ }
40
+ if (!jodit.s.isCollapsed()) {
41
+ jodit.execCommand(shift ? 'outdent' : 'indent');
42
+ return true;
43
+ }
44
+ const li = Dom.closest(current, 'li', jodit.editor);
45
+ const list = li && !li.previousElementSibling && Dom.isList(li.parentElement)
46
+ ? li.parentElement
47
+ : null;
48
+ if (list && (!shift || isIndented(jodit, list))) {
49
+ applyIndentToBox(new Set(), list, jodit, shift ? 'outdent' : 'indent');
50
+ jodit.synchronizeValues();
51
+ return true;
52
+ }
53
+ if (shift) {
54
+ unindent(jodit, current, spaces);
55
+ return true;
56
+ }
57
+ const element = Dom.isElement(current) ? current : current.parentElement;
58
+ const keepsTabs = element &&
59
+ KEEPS_TABS.has(jodit.ew.getComputedStyle(element).whiteSpace);
60
+ jodit.s.insertNode(jodit.createInside.text(keepsTabs ? '\t' : NBSP_SPACE.repeat(spaces)));
61
+ return true;
62
+ }
63
+ /**
64
+ * Shift+Tab at a caret takes out a tab or up to `spaces` spaces just before
65
+ * it, then a tab or up to `spaces` spaces at the start of its line, then the
66
+ * indent of its block
67
+ */
68
+ function unindent(jodit, current, spaces) {
69
+ const block = Dom.closest(current, Dom.isBlock, jodit.editor);
70
+ const caret = jodit.createInside.fake();
71
+ Dom.safeInsertNode(jodit.s.range, caret);
72
+ let removed;
73
+ try {
74
+ removed =
75
+ removeTabBefore(caret) ||
76
+ removeTabSpaces(jodit, caret, true) ||
77
+ removeLineIndent(jodit, block !== null && block !== void 0 ? block : jodit.editor, caret, spaces);
78
+ if (removed) {
79
+ addBRInsideEmptyBlock(jodit, caret);
80
+ }
81
+ }
82
+ finally {
83
+ jodit.s.setCursorBefore(caret);
84
+ Dom.safeRemove(caret);
85
+ }
86
+ if (removed) {
87
+ jodit.synchronizeValues();
88
+ }
89
+ else if (block && isIndented(jodit, block)) {
90
+ jodit.execCommand('outdent');
91
+ }
92
+ }
93
+ function removeTabBefore(caret) {
94
+ const before = caret.previousSibling;
95
+ if (Dom.isText(before) && before.data.endsWith('\t')) {
96
+ before.deleteData(before.length - 1, 1);
97
+ return true;
98
+ }
99
+ return false;
100
+ }
101
+ function removeLineIndent(jodit, block, caret, spaces) {
102
+ const { whiteSpace } = jodit.ew.getComputedStyle(block);
103
+ const walker = jodit.ed.createTreeWalker(block, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, {
104
+ acceptNode: node => Dom.isBlock(node)
105
+ ? NodeFilter.FILTER_REJECT
106
+ : NodeFilter.FILTER_ACCEPT
107
+ });
108
+ const [start, offset] = lineStart(walker, caret, KEEPS_TABS.has(whiteSpace) || whiteSpace === 'pre-line');
109
+ return removeIndentAt(walker, start, offset, caret, spaces);
110
+ }
111
+ /**
112
+ * Where the caret's line starts: after a `<br>`, after a newline where white
113
+ * space keeps it, or at the caret
114
+ */
115
+ function lineStart(walker, caret, keepsBreaks) {
116
+ let start = null;
117
+ let offset = 0;
118
+ for (let node = walker.nextNode(); node && node !== caret; node = walker.nextNode()) {
119
+ const lineBreak = keepsBreaks && Dom.isText(node) ? node.data.lastIndexOf('\n') : -1;
120
+ if (Dom.isTag(node, 'br')) {
121
+ start = null;
122
+ }
123
+ else if (lineBreak >= 0) {
124
+ start = node;
125
+ offset = lineBreak + 1;
126
+ }
127
+ else if (Dom.isText(node) && !start) {
128
+ start = node;
129
+ offset = 0;
130
+ }
131
+ }
132
+ return start ? [start, offset] : [caret, 0];
133
+ }
134
+ function removeIndentAt(walker, start, startOffset, caret, spaces) {
135
+ let removed = 0;
136
+ let offset = startOffset;
137
+ walker.currentNode = start;
138
+ for (let node = start; node && removed < spaces && !Dom.isTag(node, 'br'); node = walker.nextNode()) {
139
+ if (Dom.isText(node) && node !== caret) {
140
+ const [end, count] = scanIndent(node.data, offset, spaces - removed, !removed);
141
+ node.deleteData(offset, end - offset);
142
+ removed += count;
143
+ if (offset < node.length) {
144
+ break;
145
+ }
146
+ }
147
+ offset = 0;
148
+ }
149
+ return removed > 0;
150
+ }
151
+ /**
152
+ * Where up to `count` spaces from `offset` end, and how many there were. A
153
+ * tab at the start of a line is a whole indent
154
+ */
155
+ function scanIndent(text, offset, count, atLineStart) {
156
+ if (atLineStart && text[offset] === '\t') {
157
+ return [offset + 1, count];
158
+ }
159
+ let end = offset;
160
+ let found = 0;
161
+ for (; end < text.length && found < count; end += 1) {
162
+ const char = text[end];
163
+ if (char !== ' ' && char !== NBSP_SPACE && char !== INVISIBLE_SPACE) {
164
+ break;
165
+ }
166
+ if (char !== INVISIBLE_SPACE) {
167
+ found += 1;
168
+ }
169
+ }
170
+ return [end, found];
171
+ }
172
+ function isIndented(jodit, box) {
173
+ return (parseInt(cssInline(box, getKey(jodit.o.direction, box)) || '0', 10) > 0);
174
+ }
175
+ /**
176
+ * With `tab.spaces`, Backspace just after that many spaces removes them
177
+ * together, as it would a tab. With `upTo`, as for Shift+Tab, fewer will do,
178
+ * if one of them is non-breaking, so a space between words stays
179
+ * @private
180
+ */
181
+ export function removeTabSpaces(jodit, caret, upTo = false) {
182
+ const { spaces } = jodit.o.tab;
183
+ if (!spaces) {
184
+ return false;
185
+ }
186
+ const range = jodit.s.createRange();
187
+ range.setEndBefore(caret);
188
+ let count = 0;
189
+ let nonBreaking = false;
190
+ for (let node = caret.previousSibling; Dom.isText(node) && count < spaces; node = node.previousSibling) {
191
+ let offset = node.length;
192
+ for (; offset > 0 && count < spaces; offset -= 1) {
193
+ const char = node.data[offset - 1];
194
+ if (char === NBSP_SPACE) {
195
+ nonBreaking = true;
196
+ }
197
+ else if (char !== ' ' && char !== INVISIBLE_SPACE) {
198
+ break;
199
+ }
200
+ if (char !== INVISIBLE_SPACE) {
201
+ count += 1;
202
+ }
203
+ }
204
+ range.setStart(node, offset);
205
+ if (offset && count < spaces) {
206
+ break;
207
+ }
208
+ }
209
+ if (upTo ? !nonBreaking : count < spaces) {
210
+ return false;
211
+ }
212
+ range.deleteContents();
213
+ // An emptied line keeps a <br>, as after any Backspace, or it has no
214
+ // height to hold the caret
215
+ addBRInsideEmptyBlock(jodit, caret);
216
+ return true;
217
+ }
218
+ /**
219
+ * With `tab.spaces`, a tab in pasted text becomes the spaces, as HTML would
220
+ * show it as one space. Tabs in white space that's kept, and those that only
221
+ * lay out the HTML, stay as they are
222
+ * @private
223
+ */
224
+ export function tabsToSpaces(jodit, html) {
225
+ var _a;
226
+ const { spaces } = jodit.o.tab;
227
+ const current = jodit.s.current();
228
+ const target = Dom.isElement(current) ? current : current === null || current === void 0 ? void 0 : current.parentElement;
229
+ if (!spaces ||
230
+ !html.includes('\t') ||
231
+ (target && KEEPS_TABS.has(jodit.ew.getComputedStyle(target).whiteSpace))) {
232
+ return;
233
+ }
234
+ // A template parses without loading images or running scripts
235
+ const template = jodit.ed.createElement('template');
236
+ template.innerHTML = html;
237
+ const walker = jodit.ed.createTreeWalker(template.content, NodeFilter.SHOW_TEXT);
238
+ let changed = false;
239
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
240
+ const text = (_a = node.nodeValue) !== null && _a !== void 0 ? _a : '';
241
+ if (text.includes('\t') && text.trim() && !keepsTabs(node)) {
242
+ node.nodeValue = text.replace(/\t/g, NBSP_SPACE.repeat(spaces));
243
+ changed = true;
244
+ }
245
+ }
246
+ return changed ? template.innerHTML : undefined;
247
+ }
248
+ /**
249
+ * The fragment isn't rendered, so this reads the white space its own styles
250
+ * and tags set. The text of `<style>` and `<script>` isn't shown at all
251
+ */
252
+ function keepsTabs(node) {
253
+ for (let el = node.parentElement; el; el = el.parentElement) {
254
+ const { whiteSpace } = el.style;
255
+ if (whiteSpace) {
256
+ return KEEPS_TABS.has(whiteSpace);
257
+ }
258
+ if (Dom.isTag(el, KEEPS_TABS_TAGS)) {
259
+ return true;
260
+ }
261
+ }
262
+ return false;
263
+ }
@@ -10,6 +10,16 @@ declare module 'jodit/config' {
10
10
  * Pressing Tab inside LI will add an internal list
11
11
  */
12
12
  tabInsideLiInsertNewList: boolean;
13
+ /**
14
+ * Outside table cells and the list items Tab already nests, Tab at a
15
+ * caret inserts this many non-breaking spaces, and Shift+Tab or
16
+ * Backspace takes them out again. In a list's first item Tab
17
+ * indents the list. Tab and Shift+Tab with a selection indent and
18
+ * outdent it, and a tab in pasted text becomes the same spaces.
19
+ * Neither key moves the focus on: Escape and then Tab does. 0
20
+ * leaves Tab to the browser, which moves the focus on
21
+ */
22
+ spaces: number;
13
23
  };
14
24
  }
15
25
  }
@@ -8,5 +8,6 @@
8
8
  */
9
9
  import { Config } from "../../config.js";
10
10
  Config.prototype.tab = {
11
- tabInsideLiInsertNewList: true
11
+ tabInsideLiInsertNewList: true,
12
+ spaces: 0
12
13
  };
@@ -13,19 +13,60 @@ 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 { KEY_TAB } from "../../core/constants.js";
17
- import { watch } from "../../core/decorators/index.js";
16
+ import { KEY_ESC, KEY_TAB } from "../../core/constants.js";
17
+ import { autobind, watch } from "../../core/decorators/index.js";
18
18
  import { pluginSystem } from "../../core/global.js";
19
+ import { isString } from "../../core/helpers/checker/is-string.js";
19
20
  import { Plugin } from "../../core/plugin/index.js";
20
21
  import "./config.js";
21
- import { onTabInsideLi } from "./cases/index.js";
22
+ import { onTabInsideLi, onTabSpaces, removeTabSpaces, tabsToSpaces } from "./cases/index.js";
23
+ const MODIFIER_KEYS = new Set(['Shift', 'Control', 'Alt', 'Meta', 'CapsLock']);
22
24
  class tab extends Plugin {
23
- afterInit(jodit) { }
25
+ constructor() {
26
+ super(...arguments);
27
+ /**
28
+ * With `tab.spaces`, Tab stays in the editor, so an Escape lets the next
29
+ * Tab move the focus on, as in code editors. A modifier key keeps it, and
30
+ * any other key or a click ends it
31
+ */
32
+ this.__released = false;
33
+ }
34
+ afterInit(jodit) {
35
+ // Without a namespace it runs ahead of table navigation, which would
36
+ // take a released Tab
37
+ jodit.e.on('keydown', this.__onKeyDownFirst, { top: true });
38
+ }
39
+ // An Escape that closes a popup has done its job
40
+ __endRelease() {
41
+ this.__released = false;
42
+ }
43
+ __onKeyDownFirst(event) {
44
+ const released = this.__released;
45
+ if (!MODIFIER_KEYS.has(event.key)) {
46
+ this.__released = event.key === KEY_ESC && this.j.o.tab.spaces > 0;
47
+ }
48
+ // The browser moves the focus
49
+ if (released && event.key === KEY_TAB) {
50
+ this.j.e.stopPropagation('keydown');
51
+ }
52
+ }
24
53
  __onTab(event) {
25
- if (event.key === KEY_TAB && this.__onShift(event.shiftKey)) {
54
+ if (event.key === KEY_TAB &&
55
+ (this.__onShift(event.shiftKey) ||
56
+ onTabSpaces(this.j, event.shiftKey))) {
26
57
  return false;
27
58
  }
28
59
  }
60
+ __onBackspace(backspace, fakeNode) {
61
+ if (backspace && removeTabSpaces(this.j, fakeNode)) {
62
+ return true;
63
+ }
64
+ }
65
+ __onPasteInsert(html) {
66
+ if (isString(html)) {
67
+ return tabsToSpaces(this.j, html);
68
+ }
69
+ }
29
70
  __onCommand(command) {
30
71
  if ((command === 'indent' || command === 'outdent') &&
31
72
  this.__onShift(command === 'outdent')) {
@@ -39,11 +80,25 @@ class tab extends Plugin {
39
80
  }
40
81
  return res;
41
82
  }
42
- beforeDestruct(jodit) { }
83
+ beforeDestruct(jodit) {
84
+ jodit.e.off('keydown', this.__onKeyDownFirst);
85
+ }
43
86
  }
87
+ __decorate([
88
+ watch([':mousedown.tab', ':beforePopupClose.tab'])
89
+ ], tab.prototype, "__endRelease", null);
90
+ __decorate([
91
+ autobind
92
+ ], tab.prototype, "__onKeyDownFirst", null);
44
93
  __decorate([
45
94
  watch(':keydown.tab')
46
95
  ], tab.prototype, "__onTab", null);
96
+ __decorate([
97
+ watch(':backSpaceBeforeCases.tab')
98
+ ], tab.prototype, "__onBackspace", null);
99
+ __decorate([
100
+ watch(':beforePasteInsert.tab')
101
+ ], tab.prototype, "__onPasteInsert", null);
47
102
  __decorate([
48
103
  watch(':beforeCommand.tab')
49
104
  ], tab.prototype, "__onCommand", null);
@@ -203,6 +203,22 @@ export interface MediaWrapper {
203
203
  tag: string;
204
204
  className: string;
205
205
  }
206
+ /**
207
+ * The elements a captioned image is kept in, see `imageCaption`. An empty
208
+ * `className` matches the tag alone
209
+ */
210
+ export interface ImageCaptionMarkup {
211
+ /**
212
+ * Holds the image, or its link, and the caption
213
+ */
214
+ wrapper: MediaWrapper;
215
+ /**
216
+ * Inside the wrapper, round the image and the caption, as Froala's
217
+ * `span.fr-img-wrap`
218
+ */
219
+ inner: Nullable<MediaWrapper>;
220
+ caption: MediaWrapper;
221
+ }
206
222
  export interface ImageBox {
207
223
  w: number;
208
224
  h: number;
@@ -16,6 +16,12 @@ interface IUploaderData {
16
16
  path?: string;
17
17
  baseurl: string;
18
18
  newfilename?: string;
19
+ /**
20
+ * The names the files had on the user's device. Only set when the
21
+ * images were read as base64 (`insertImageAsBase64URI`), where `files`
22
+ * holds data URIs.
23
+ */
24
+ fileNames?: string[];
19
25
  }
20
26
  interface IUploaderAnswer {
21
27
  success: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.18.12",
3
+ "version": "4.19.4",
4
4
  "description": "Jodit is an awesome and useful wysiwyg editor with filebrowser",
5
5
  "main": "esm/index.js",
6
6
  "types": "types/index.d.ts",
package/types/config.d.ts CHANGED
@@ -10,6 +10,7 @@ import type { IDictionary } from "./types/index";
10
10
  import type { Nullable } from "./types/index";
11
11
  import type { IJodit } from "./types/index";
12
12
  import type { IUploaderData } from "./types/index";
13
+ import type { ImageCaptionMarkup } from "./types/index";
13
14
  import type { ImagePropertiesOptions } from "./plugins/image-properties/interface";
14
15
  import type { IControlType } from "./types/index";
15
16
  import type { formTemplate } from "./plugins/link/template";
@@ -653,7 +654,8 @@ declare class Config implements IViewOptions {
653
654
  * spaces. An alignment can also list several such sets, to recognise each
654
655
  * of them; aligning writes the first. A media wrapper (see
655
656
  * `mediaWrappers`), and Jodit's own `jodit` and `jodit-media` wrappers,
656
- * are aligned with the classes for the media in them.
657
+ * are aligned with the classes for the media in them, and a captioned
658
+ * image's wrapper (see `imageCaption`) with those for `img`.
657
659
  *
658
660
  * ```javascript
659
661
  * const media = {
@@ -1335,6 +1337,17 @@ interface Config {
1335
1337
  };
1336
1338
  };
1337
1339
  }
1340
+ interface Config {
1341
+ formatBlock: {
1342
+ /**
1343
+ * The CSS properties each preview in the Paragraph list copies from
1344
+ * how the content shows its tag, so the list looks like the content.
1345
+ * Lengths become `em`, and size and line height stay with the list.
1346
+ * An empty list, the default, keeps the toolbar's styles.
1347
+ */
1348
+ previewProperties: string[];
1349
+ };
1350
+ }
1338
1351
  interface Config {
1339
1352
  /**
1340
1353
  * Open WYSIWYG in full screen
@@ -1442,6 +1455,26 @@ interface Config {
1442
1455
  */
1443
1456
  iframeSandbox: string | null;
1444
1457
  }
1458
+ interface Config {
1459
+ /**
1460
+ * The elements a captioned image is kept in, read from the content and
1461
+ * written by the Caption button in the image popup and the Caption
1462
+ * checkbox in the image properties dialog. The default is a `<figure>`
1463
+ * holding the image, or its link, and a `<figcaption>`. Content from
1464
+ * another editor can be captioned in its own way, as Froala's is:
1465
+ *
1466
+ * ```javascript
1467
+ * Jodit.make('#editor', {
1468
+ * imageCaption: {
1469
+ * wrapper: { tag: 'span', className: 'fr-img-caption' },
1470
+ * inner: { tag: 'span', className: 'fr-img-wrap' },
1471
+ * caption: { tag: 'span', className: 'fr-inner' }
1472
+ * }
1473
+ * });
1474
+ * ```
1475
+ */
1476
+ imageCaption: ImageCaptionMarkup;
1477
+ }
1445
1478
  interface Config {
1446
1479
  /**
1447
1480
  * Options for processing images inserted into the editor (e.g. converting base64 data URIs to Blob URLs).
@@ -2025,6 +2058,16 @@ interface Config {
2025
2058
  * Pressing Tab inside LI will add an internal list
2026
2059
  */
2027
2060
  tabInsideLiInsertNewList: boolean;
2061
+ /**
2062
+ * Outside table cells and the list items Tab already nests, Tab at a
2063
+ * caret inserts this many non-breaking spaces, and Shift+Tab or
2064
+ * Backspace takes them out again. In a list's first item Tab
2065
+ * indents the list. Tab and Shift+Tab with a selection indent and
2066
+ * outdent it, and a tab in pasted text becomes the same spaces.
2067
+ * Neither key moves the focus on: Escape and then Tab does. 0
2068
+ * leaves Tab to the browser, which moves the focus on
2069
+ */
2070
+ spaces: number;
2028
2071
  };
2029
2072
  }
2030
2073
  interface Config {
@@ -10,7 +10,7 @@ import type { HAlignClasses, IJodit, ImageHAlign, Nullable } from "../../../type
10
10
  /**
11
11
  * The class names to align `elm` with: `alignClasses` for its tag, or for the
12
12
  * media in it when it wraps media (a `mediaWrappers` wrapper, `jodit` or
13
- * `jodit-media`)
13
+ * `jodit-media`) or a captioned image (see `imageCaption`)
14
14
  */
15
15
  export declare function getAlignClasses(jodit: IJodit, elm: Nullable<HTMLElement>): Nullable<HAlignClasses>;
16
16
  /**
@@ -18,6 +18,11 @@ export declare function getAlignClasses(jodit: IJodit, elm: Nullable<HTMLElement
18
18
  * when they are given
19
19
  */
20
20
  export declare function hAlignElement(image: HTMLElement, align: ImageHAlign, classes?: Nullable<HAlignClasses>): void;
21
+ /**
22
+ * Remove the alignment `hAlignElement` set on an element, with the classes of
23
+ * every alignment in `classes`
24
+ */
25
+ export declare function clearHAlign(elm: HTMLElement, classes?: Nullable<HAlignClasses>): void;
21
26
  /**
22
27
  * The alignment `hAlignElement` has set on an element
23
28
  */