jodit 4.18.12 → 4.19.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 (255) hide show
  1. package/CHANGELOG.md +22 -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
@@ -3,4 +3,17 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
+ declare module 'jodit/config' {
7
+ interface Config {
8
+ formatBlock: {
9
+ /**
10
+ * The CSS properties each preview in the Paragraph list copies from
11
+ * how the content shows its tag, so the list looks like the content.
12
+ * Lengths become `em`, and size and line height stay with the list.
13
+ * An empty list, the default, keeps the toolbar's styles.
14
+ */
15
+ previewProperties: string[];
16
+ };
17
+ }
18
+ }
6
19
  export {};
@@ -7,8 +7,45 @@ import { Dom } from "../../core/dom/dom.js";
7
7
  import { isPlainObject } from "../../core/helpers/checker/is-plain-object.js";
8
8
  import { Icon } from "../../core/ui/icon.js";
9
9
  import { Config } from "../../config.js";
10
+ import { withContentFonts } from "./content-fonts.js";
10
11
  import paragraphIcon from "./paragraph.svg.js";
11
12
  Icon.set('paragraph', paragraphIcon);
13
+ Config.prototype.formatBlock = {
14
+ // Opt in: previews keep the toolbar's styles unless the integrator lists
15
+ // the properties to copy, e.g. ['font-family', 'font-weight', 'color']
16
+ previewProperties: []
17
+ };
18
+ /**
19
+ * The list is outside the editing area, and in iframe mode outside its
20
+ * document, so a preview would take the toolbar's styles. This reads how the
21
+ * content shows a tag from a probe in the editing area
22
+ */
23
+ function previewStyle(editor, tag) {
24
+ const { previewProperties } = editor.o.formatBlock;
25
+ if (!previewProperties.length) {
26
+ return '';
27
+ }
28
+ const probe = editor.createInside.element(tag, { style: 'display: none' });
29
+ Dom.append(editor.editor, probe);
30
+ const style = editor.ew.getComputedStyle(probe);
31
+ const size = parseFloat(style.fontSize) || 16;
32
+ const css = previewProperties
33
+ .map(prop => {
34
+ let value = style.getPropertyValue(prop);
35
+ if (value && prop === 'font-family') {
36
+ value = withContentFonts(editor, value);
37
+ }
38
+ // Each browser knows only one of the smoothing properties
39
+ return value
40
+ ? `;${prop}:${value
41
+ .replace(/(-?[\d.]+)px/g, (_, px) => `${parseFloat(px) / size}em`)
42
+ .replace(/"/g, "'")}`
43
+ : '';
44
+ })
45
+ .join('');
46
+ Dom.safeRemove(probe);
47
+ return css;
48
+ }
12
49
  Config.prototype.controls.paragraph = {
13
50
  command: 'formatBlock',
14
51
  value(editor, button) {
@@ -51,6 +88,6 @@ Config.prototype.controls.paragraph = {
51
88
  isPlainObject(button.control.list) &&
52
89
  Boolean(button.control.list[button.state.value]));
53
90
  },
54
- childTemplate: (e, key, value) => `<${key} style="margin:0;padding:0"><span>${e.i18n(value)}</span></${key}>`,
91
+ childTemplate: (e, key, value) => `<${key} style="margin:0;padding:0${previewStyle(e, key)}"><span>${e.i18n(value)}</span></${key}>`,
55
92
  tooltip: 'Insert format block'
56
93
  };
@@ -0,0 +1,17 @@
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/format-block
8
+ */
9
+ import type { IJodit } from "../../types/index";
10
+ /**
11
+ * In iframe mode the content's web fonts load only in the iframe, but the
12
+ * Paragraph list is in the page, so its previews would fall back to the
13
+ * page's fonts. This adds the content's web fonts to the page under names
14
+ * only this editor uses, so nothing else on the page can pick them up, and
15
+ * puts those names first in a preview's `font-family`
16
+ */
17
+ export declare function withContentFonts(editor: IJodit, fontFamily: string): string;
@@ -0,0 +1,156 @@
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
+ const carried = new WeakMap();
7
+ const fetched = new Map();
8
+ let editors = 0;
9
+ /**
10
+ * In iframe mode the content's web fonts load only in the iframe, but the
11
+ * Paragraph list is in the page, so its previews would fall back to the
12
+ * page's fonts. This adds the content's web fonts to the page under names
13
+ * only this editor uses, so nothing else on the page can pick them up, and
14
+ * puts those names first in a preview's `font-family`
15
+ */
16
+ export function withContentFonts(editor, fontFamily) {
17
+ const { ed, od } = editor;
18
+ if (ed === od) {
19
+ return fontFamily;
20
+ }
21
+ const state = carriedFor(editor);
22
+ carry(editor, state);
23
+ const webFonts = new Set();
24
+ ed.fonts.forEach(face => webFonts.add(familyName(face.family)));
25
+ return fontFamily
26
+ .split(',')
27
+ .map(family => {
28
+ const name = familyName(family);
29
+ return webFonts.has(name)
30
+ ? `"${state.prefix}${name}", ${family.trim()}`
31
+ : family.trim();
32
+ })
33
+ .join(', ');
34
+ }
35
+ function carriedFor(editor) {
36
+ let state = carried.get(editor);
37
+ if (!state) {
38
+ const { od } = editor;
39
+ const created = {
40
+ prefix: `jodit-preview-${++editors}-`,
41
+ faces: new Map(),
42
+ pending: false
43
+ };
44
+ carried.set(editor, created);
45
+ editor.e.on('beforeDestruct', () => created.faces.forEach(face => od.fonts.delete(face)));
46
+ state = created;
47
+ }
48
+ return state;
49
+ }
50
+ /**
51
+ * It looks each time the list opens, since the content's stylesheets may
52
+ * still have been loading the time before
53
+ */
54
+ function carry(editor, state) {
55
+ // Every preview in the list asks, but one look is enough
56
+ if (state.pending) {
57
+ return;
58
+ }
59
+ state.pending = true;
60
+ const { ed, od } = editor;
61
+ Promise.all(Array.from(ed.styleSheets, sheet => fontsOf(sheet, ed.baseURI))).then(lists => {
62
+ state.pending = false;
63
+ if (editor.isInDestruct) {
64
+ return;
65
+ }
66
+ lists.flat().forEach(font => {
67
+ const key = JSON.stringify(font);
68
+ if (!state.faces.has(key)) {
69
+ const face = new FontFace(state.prefix + font.family, font.source, font.descriptors);
70
+ od.fonts.add(face);
71
+ state.faces.set(key, face);
72
+ }
73
+ });
74
+ });
75
+ }
76
+ /**
77
+ * The web fonts a stylesheet and those it imports declare
78
+ */
79
+ function fontsOf(sheet, base) {
80
+ var _a;
81
+ let rules;
82
+ try {
83
+ rules = sheet.cssRules;
84
+ }
85
+ catch (_b) {
86
+ // Another site's stylesheet can't be read, but it can be fetched if
87
+ // the site allows it, as Google Fonts does
88
+ const { href } = sheet;
89
+ if (!href) {
90
+ return Promise.resolve([]);
91
+ }
92
+ let fonts = fetched.get(href);
93
+ if (!fonts) {
94
+ fonts = fetchFonts(href);
95
+ fetched.set(href, fonts);
96
+ }
97
+ return fonts;
98
+ }
99
+ return fontsIn(rules, (_a = sheet.href) !== null && _a !== void 0 ? _a : base);
100
+ }
101
+ function fontsIn(rules, base) {
102
+ return Promise.all(Array.from(rules, (rule) => {
103
+ if ('styleSheet' in rule) {
104
+ const { styleSheet } = rule;
105
+ return styleSheet ? fontsOf(styleSheet, base) : [];
106
+ }
107
+ if ('cssRules' in rule) {
108
+ return fontsIn(rule.cssRules, base);
109
+ }
110
+ return rule.cssText.startsWith('@font-face')
111
+ ? [fontOf(rule, base)]
112
+ : [];
113
+ })).then(lists => lists.flat());
114
+ }
115
+ function fontOf(rule, base) {
116
+ const value = (prop) => rule.style.getPropertyValue(prop) || undefined;
117
+ return {
118
+ family: familyName(rule.style.getPropertyValue('font-family')),
119
+ source: withAbsoluteUrls(rule.style.getPropertyValue('src'), base),
120
+ descriptors: {
121
+ style: value('font-style'),
122
+ weight: value('font-weight'),
123
+ stretch: value('font-stretch'),
124
+ unicodeRange: value('unicode-range')
125
+ }
126
+ };
127
+ }
128
+ function fetchFonts(href) {
129
+ return fetch(href)
130
+ .then(response => response.text())
131
+ .then(text => {
132
+ const doc = document.implementation.createHTMLDocument('');
133
+ const style = doc.createElement('style');
134
+ style.textContent = text;
135
+ doc.head.appendChild(style);
136
+ return style.sheet ? fontsIn(style.sheet.cssRules, href) : [];
137
+ })
138
+ .catch(() => []);
139
+ }
140
+ function familyName(family) {
141
+ return family.replace(/["']/g, '').trim().toLowerCase();
142
+ }
143
+ /**
144
+ * The fonts are added to the page, so a relative URL would point somewhere
145
+ * else
146
+ */
147
+ function withAbsoluteUrls(css, base) {
148
+ return css.replace(/url\(\s*(["']?)(.*?)\1\s*\)/g, (match, quote, url) => {
149
+ try {
150
+ return `url("${new URL(url, base).href}")`;
151
+ }
152
+ catch (_a) {
153
+ return match;
154
+ }
155
+ });
156
+ }
@@ -0,0 +1,31 @@
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/image-caption
8
+ */
9
+ import type { ImageCaptionMarkup } from "../../types/index";
10
+ declare module 'jodit/config' {
11
+ interface Config {
12
+ /**
13
+ * The elements a captioned image is kept in, read from the content and
14
+ * written by the Caption button in the image popup and the Caption
15
+ * checkbox in the image properties dialog. The default is a `<figure>`
16
+ * holding the image, or its link, and a `<figcaption>`. Content from
17
+ * another editor can be captioned in its own way, as Froala's is:
18
+ *
19
+ * ```javascript
20
+ * Jodit.make('#editor', {
21
+ * imageCaption: {
22
+ * wrapper: { tag: 'span', className: 'fr-img-caption' },
23
+ * inner: { tag: 'span', className: 'fr-img-wrap' },
24
+ * caption: { tag: 'span', className: 'fr-inner' }
25
+ * }
26
+ * });
27
+ * ```
28
+ */
29
+ imageCaption: ImageCaptionMarkup;
30
+ }
31
+ }
@@ -0,0 +1,11 @@
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 { Config } from "../../config.js";
7
+ Config.prototype.imageCaption = {
8
+ wrapper: { tag: 'figure', className: '' },
9
+ inner: null,
10
+ caption: { tag: 'figcaption', className: '' }
11
+ };
@@ -0,0 +1,140 @@
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
+ * [[include:plugins/image-caption/README.md]]
8
+ * @packageDocumentation
9
+ * @module plugins/image-caption
10
+ */
11
+ import type { IJodit, Nullable } from "../../types/index";
12
+ import { Plugin } from "../../core/plugin/plugin";
13
+ import "./config";
14
+ /**
15
+ * Captions images: wraps an image in `imageCaption`'s elements and back, and
16
+ * keeps the caret in the caption
17
+ */
18
+ export declare class imageCaption extends Plugin {
19
+ /** @override */
20
+ protected afterInit(jodit: IJodit): void;
21
+ /**
22
+ * Gives `image` a caption, or takes it away, as `on` says, or else the
23
+ * other way round from how it is. Returns the caption it gave, or null
24
+ * when it took one away
25
+ */
26
+ protected onToggleImageCaption(image: HTMLImageElement, on?: boolean): Nullable<HTMLElement> | void;
27
+ /**
28
+ * The caption given last, while nothing has changed round it and it's
29
+ * still blank, so taking it off can put everything back as it was
30
+ */
31
+ private __fresh;
32
+ private __freshCaption;
33
+ /**
34
+ * Giving a caption isn't a step in the history of its own, as the first
35
+ * thing typed in it is, so Undo never brings back a blank caption
36
+ */
37
+ private __caption;
38
+ /**
39
+ * Changes the content with no step in the history of its own, so Undo
40
+ * never brings back a blank caption. A step still open takes it in
41
+ */
42
+ private __unrecorded;
43
+ private __wrap;
44
+ /**
45
+ * Puts the image back as it was before its caption: in the line the
46
+ * caption split, and with its own alignment, margins and width. The image
47
+ * goes into the part of the line holding the caret, so the caret stays
48
+ */
49
+ private __restore;
50
+ private __uncaption;
51
+ private __create;
52
+ /**
53
+ * Puts `wrapper` where `target` is. A block can't go in a paragraph, so the
54
+ * paragraph is split round it, and a part left empty goes
55
+ */
56
+ private __insert;
57
+ /**
58
+ * The wrapper can't be edited, apart from its caption, so typing can't
59
+ * land between the image and the caption
60
+ */
61
+ private __mark;
62
+ private __placeholder;
63
+ protected onChange(): void;
64
+ /**
65
+ * The placeholder goes with the first letter typed or pasted, and comes
66
+ * back when the last is deleted
67
+ */
68
+ protected onInput(): void;
69
+ /**
70
+ * The editor's own attributes stay out of the value, as the caption would
71
+ * be editable on the page. So does a caption given and left blank, as
72
+ * leaving it takes it off, so saving at once keeps the image as it was
73
+ */
74
+ protected onAfterGetValueFromEditor(data: {
75
+ value: string;
76
+ }): void;
77
+ protected onChangePlace(): void;
78
+ private __press;
79
+ private __afterPress;
80
+ private __onMouseDown;
81
+ /**
82
+ * A caption left blank goes when the focus leaves it. That's checked once
83
+ * the focus has landed, as switching windows or opening the editor's own
84
+ * popups keeps it, and once a press that took the focus is over, as the
85
+ * browsers fire no click when its target moves
86
+ */
87
+ private __onFocusOut;
88
+ private __onMouseUp;
89
+ private __dropBlank;
90
+ /**
91
+ * The caption has the focus, or had it when another window took it, or
92
+ * the editor's own popups and dialogs have it, as the link form
93
+ */
94
+ private __keepsFocus;
95
+ /**
96
+ * The caption the caret is in
97
+ */
98
+ private __caretCaption;
99
+ /**
100
+ * Enter in a caption starts a line after the image, and Shift+Enter
101
+ * breaks the caption's line, as everywhere
102
+ */
103
+ protected onBeforeEnter(event?: KeyboardEvent): false | void;
104
+ /**
105
+ * The caption keeps the focus, as an editable element of its own, and
106
+ * would take the caret back, so the editor takes it before the caret
107
+ * leaves the caption
108
+ */
109
+ private __focusEditor;
110
+ private __line;
111
+ /**
112
+ * A caption holds text. An image, a table or a block put in it would end
113
+ * the captioned image, so it goes after the image, as Enter would
114
+ */
115
+ protected onBeforeInsertNode(node: Node): void;
116
+ private __arrow;
117
+ /**
118
+ * A selected captioned image goes as an image on a line of its own does,
119
+ * leaving the line empty, rather than joining the lines either side
120
+ */
121
+ protected onBeforeCommandDelete(): false | void;
122
+ /**
123
+ * The captioned image the selection holds, as a click on the image selects
124
+ */
125
+ private __selectedWrapper;
126
+ protected onKeyDown(event: KeyboardEvent): void;
127
+ /**
128
+ * An arrow key that couldn't move the caret in the caption takes it out,
129
+ * past the image, as the caption is an editable element of its own
130
+ */
131
+ protected onKeyUp(event: KeyboardEvent): void;
132
+ protected onBeforeCommand(command: string): false | void;
133
+ /**
134
+ * Select all in a caption selects the caption, as the caption is an
135
+ * editable element of its own
136
+ */
137
+ private __onSelectAll;
138
+ /** @override */
139
+ protected beforeDestruct(jodit: IJodit): void;
140
+ }