jodit 4.10.3 → 4.11.3

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 (87) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +15 -15
  4. package/es2015/jodit.js +359 -62
  5. package/es2015/jodit.min.js +7 -7
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.fat.min.js +6 -6
  13. package/es2018/jodit.min.js +15 -15
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +8 -8
  18. package/es2021/jodit.js +358 -62
  19. package/es2021/jodit.min.js +9 -9
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +50 -50
  28. package/es2021.en/jodit.js +358 -62
  29. package/es2021.en/jodit.min.js +25 -25
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +416 -62
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/config.d.ts +85 -0
  51. package/esm/core/constants.js +1 -1
  52. package/esm/core/dom/dom.d.ts +1 -0
  53. package/esm/core/helpers/html/safe-html.d.ts +3 -2
  54. package/esm/core/helpers/html/safe-html.js +42 -3
  55. package/esm/plugins/clean-html/clean-html.js +4 -0
  56. package/esm/plugins/clean-html/config.d.ts +85 -0
  57. package/esm/plugins/clean-html/config.js +7 -1
  58. package/esm/plugins/clean-html/helpers/visitor/filters/convert-unsafe-embeds.d.ts +14 -0
  59. package/esm/plugins/clean-html/helpers/visitor/filters/convert-unsafe-embeds.js +37 -0
  60. package/esm/plugins/clean-html/helpers/visitor/filters/index.d.ts +4 -0
  61. package/esm/plugins/clean-html/helpers/visitor/filters/index.js +4 -0
  62. package/esm/plugins/clean-html/helpers/visitor/filters/safe-links-target.d.ts +14 -0
  63. package/esm/plugins/clean-html/helpers/visitor/filters/safe-links-target.js +38 -0
  64. package/esm/plugins/clean-html/helpers/visitor/filters/sandbox-iframes-in-content.d.ts +14 -0
  65. package/esm/plugins/clean-html/helpers/visitor/filters/sandbox-iframes-in-content.js +24 -0
  66. package/esm/plugins/clean-html/helpers/visitor/filters/sanitize-attributes.js +10 -5
  67. package/esm/plugins/clean-html/helpers/visitor/filters/sanitize-styles.d.ts +14 -0
  68. package/esm/plugins/clean-html/helpers/visitor/filters/sanitize-styles.js +70 -0
  69. package/esm/plugins/drag-and-drop/drag-and-drop.js +1 -1
  70. package/esm/plugins/enter/helpers/insert-paragraph.js +2 -1
  71. package/esm/plugins/file/file.js +3 -2
  72. package/esm/plugins/iframe/iframe.js +8 -6
  73. package/esm/plugins/image/image.js +3 -2
  74. package/esm/plugins/image-properties/writers/link.js +6 -0
  75. package/esm/plugins/link/link.js +15 -3
  76. package/esm/plugins/resizer/resizer.js +2 -2
  77. package/esm/plugins/source/editor/engines/area.js +3 -7
  78. package/package.json +1 -1
  79. package/types/config.d.ts +85 -0
  80. package/types/core/dom/dom.d.ts +1 -0
  81. package/types/core/helpers/html/safe-html.d.ts +3 -2
  82. package/types/plugins/clean-html/config.d.ts +85 -0
  83. package/types/plugins/clean-html/helpers/visitor/filters/convert-unsafe-embeds.d.ts +14 -0
  84. package/types/plugins/clean-html/helpers/visitor/filters/index.d.ts +4 -0
  85. package/types/plugins/clean-html/helpers/visitor/filters/safe-links-target.d.ts +14 -0
  86. package/types/plugins/clean-html/helpers/visitor/filters/sandbox-iframes-in-content.d.ts +14 -0
  87. package/types/plugins/clean-html/helpers/visitor/filters/sanitize-styles.d.ts +14 -0
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
package/es5/polyfills.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.10.3
4
+ * Version: v4.11.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
package/esm/config.d.ts CHANGED
@@ -947,13 +947,98 @@ interface Config {
947
947
  */
948
948
  useIframeSandbox: boolean;
949
949
  /**
950
+ * @deprecated Use `removeEventAttributes` instead
950
951
  * Remove onError attributes
951
952
  */
952
953
  removeOnError: boolean;
954
+ /**
955
+ * Remove all `on*` event handler attributes (onerror, onclick, onload, onmouseover, etc.)
956
+ * When enabled, this replaces the legacy `removeOnError` behavior with comprehensive protection.
957
+ *
958
+ * ```javascript
959
+ * Jodit.make('#editor', {
960
+ * cleanHTML: {
961
+ * removeEventAttributes: true
962
+ * }
963
+ * });
964
+ * ```
965
+ */
966
+ removeEventAttributes: boolean;
953
967
  /**
954
968
  * Safe href="javascript:" links
955
969
  */
956
970
  safeJavaScriptLink: boolean;
971
+ /**
972
+ * Automatically add `rel="noopener noreferrer"` to links with `target="_blank"`
973
+ *
974
+ * ```javascript
975
+ * Jodit.make('#editor', {
976
+ * cleanHTML: {
977
+ * safeLinksTarget: true
978
+ * }
979
+ * });
980
+ * ```
981
+ */
982
+ safeLinksTarget: boolean;
983
+ /**
984
+ * Whitelist of allowed CSS properties inside `style` attributes.
985
+ * If set, all CSS properties not in the list will be removed.
986
+ *
987
+ * ```javascript
988
+ * Jodit.make('#editor', {
989
+ * cleanHTML: {
990
+ * allowedStyles: {
991
+ * '*': ['color', 'background-color', 'font-size', 'text-align'],
992
+ * img: ['width', 'height']
993
+ * }
994
+ * }
995
+ * });
996
+ * ```
997
+ */
998
+ allowedStyles: false | IDictionary<string[]>;
999
+ /**
1000
+ * Custom sanitizer function. Called after Jodit's built-in sanitization.
1001
+ * Use this to integrate DOMPurify or other external sanitizers.
1002
+ *
1003
+ * ```javascript
1004
+ * import DOMPurify from 'dompurify';
1005
+ *
1006
+ * Jodit.make('#editor', {
1007
+ * cleanHTML: {
1008
+ * sanitizer: (html) => DOMPurify.sanitize(html)
1009
+ * }
1010
+ * });
1011
+ * ```
1012
+ */
1013
+ sanitizer: false | ((value: string) => string);
1014
+ /**
1015
+ * Automatically add `sandbox=""` attribute to all `<iframe>` elements in editor content.
1016
+ * Prevents embedded content from running scripts or accessing the parent page.
1017
+ *
1018
+ * ```javascript
1019
+ * Jodit.make('#editor', {
1020
+ * cleanHTML: {
1021
+ * sandboxIframesInContent: true
1022
+ * }
1023
+ * });
1024
+ * ```
1025
+ */
1026
+ sandboxIframesInContent: boolean;
1027
+ /**
1028
+ * Convert unsafe embed elements to sandboxed `<iframe>`.
1029
+ * - `['object', 'embed']` — default
1030
+ * - `false` — disabled
1031
+ * - `string[]` — custom list of tag names to convert
1032
+ *
1033
+ * ```javascript
1034
+ * Jodit.make('#editor', {
1035
+ * cleanHTML: {
1036
+ * convertUnsafeEmbeds: Jodit.atom(['object', 'embed', 'applet'])
1037
+ * }
1038
+ * });
1039
+ * ```
1040
+ */
1041
+ convertUnsafeEmbeds: false | string[];
957
1042
  /**
958
1043
  * The allowTags option defines which elements will remain in the
959
1044
  * edited text when the editor saves. You can use this limit the returned HTML.
@@ -3,7 +3,7 @@
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
- export const APP_VERSION = "4.10.3";
6
+ export const APP_VERSION = "4.11.3";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -52,6 +52,7 @@ export declare class Dom {
52
52
  */
53
53
  static replace<T extends HTMLElement>(elm: Node, newTagName: HTMLTagNames): T;
54
54
  static replace<T extends HTMLElement>(elm: Node, newTagName: HTMLTagNames, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
55
+ static replace<T extends Node>(elm: Node, newTagName: T): T;
55
56
  static replace<T extends Node>(elm: Node, newTagName: T | string, create?: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
56
57
  /**
57
58
  * Checks whether the Node text and blank (in this case it may contain invisible auxiliary characters ,
@@ -3,13 +3,14 @@
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
- type safeOptions = {
6
+ export type safeOptions = {
7
7
  removeOnError: boolean;
8
8
  safeJavaScriptLink: boolean;
9
+ removeEventAttributes?: boolean;
10
+ safeLinksTarget?: boolean;
9
11
  };
10
12
  /**
11
13
  * Removes dangerous constructs from HTML
12
14
  */
13
15
  export declare function safeHTML(box: HTMLElement | DocumentFragment, options: safeOptions): void;
14
16
  export declare function sanitizeHTMLElement(elm: Element | DocumentFragment, { safeJavaScriptLink, removeOnError }?: safeOptions): boolean;
15
- export {};
@@ -12,17 +12,56 @@ import { $$, attr } from "../utils/index.js";
12
12
  * Removes dangerous constructs from HTML
13
13
  */
14
14
  export function safeHTML(box, options) {
15
+ var _a;
15
16
  if (!Dom.isElement(box) && !Dom.isFragment(box)) {
16
17
  return;
17
18
  }
18
- if (options.removeOnError) {
19
- sanitizeHTMLElement(box);
19
+ const removeEvents = (_a = options.removeEventAttributes) !== null && _a !== void 0 ? _a : options.removeOnError;
20
+ if (removeEvents) {
21
+ removeAllEventAttributes(box);
22
+ $$('*', box).forEach(elm => removeAllEventAttributes(elm));
23
+ }
24
+ else if (options.removeOnError) {
25
+ sanitizeHTMLElement(box, options);
20
26
  $$('[onerror]', box).forEach(elm => sanitizeHTMLElement(elm, options));
21
27
  }
22
28
  if (options.safeJavaScriptLink) {
23
- sanitizeHTMLElement(box);
29
+ sanitizeHTMLElement(box, options);
24
30
  $$('a[href^="javascript"]', box).forEach(elm => sanitizeHTMLElement(elm, options));
25
31
  }
32
+ if (options.safeLinksTarget) {
33
+ $$('a[target="_blank"]', box).forEach(elm => {
34
+ const rel = elm.getAttribute('rel') || '';
35
+ const parts = rel.split(/\s+/).filter(Boolean);
36
+ if (!parts.includes('noopener')) {
37
+ parts.push('noopener');
38
+ }
39
+ if (!parts.includes('noreferrer')) {
40
+ parts.push('noreferrer');
41
+ }
42
+ attr(elm, 'rel', parts.join(' '));
43
+ });
44
+ }
45
+ }
46
+ /**
47
+ * Remove all on* event handler attributes from an element
48
+ */
49
+ function removeAllEventAttributes(elm) {
50
+ if (!Dom.isElement(elm)) {
51
+ return false;
52
+ }
53
+ let effected = false;
54
+ const toRemove = [];
55
+ for (let i = 0; i < elm.attributes.length; i++) {
56
+ if (elm.attributes[i].name.toLowerCase().startsWith('on')) {
57
+ toRemove.push(elm.attributes[i].name);
58
+ }
59
+ }
60
+ for (const name of toRemove) {
61
+ elm.removeAttribute(name);
62
+ effected = true;
63
+ }
64
+ return effected;
26
65
  }
27
66
  export function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError } = {
28
67
  safeJavaScriptLink: true,
@@ -95,6 +95,10 @@ export class cleanHtml extends Plugin {
95
95
  return false;
96
96
  }
97
97
  onSafeHTML(sandBox) {
98
+ const sanitizer = this.j.o.cleanHTML.sanitizer;
99
+ if (sanitizer) {
100
+ sandBox.innerHTML = sanitizer(sandBox.innerHTML);
101
+ }
98
102
  safeHTML(sandBox, this.j.o.cleanHTML);
99
103
  }
100
104
  /** @override */
@@ -41,13 +41,98 @@ declare module 'jodit/config' {
41
41
  */
42
42
  useIframeSandbox: boolean;
43
43
  /**
44
+ * @deprecated Use `removeEventAttributes` instead
44
45
  * Remove onError attributes
45
46
  */
46
47
  removeOnError: boolean;
48
+ /**
49
+ * Remove all `on*` event handler attributes (onerror, onclick, onload, onmouseover, etc.)
50
+ * When enabled, this replaces the legacy `removeOnError` behavior with comprehensive protection.
51
+ *
52
+ * ```javascript
53
+ * Jodit.make('#editor', {
54
+ * cleanHTML: {
55
+ * removeEventAttributes: true
56
+ * }
57
+ * });
58
+ * ```
59
+ */
60
+ removeEventAttributes: boolean;
47
61
  /**
48
62
  * Safe href="javascript:" links
49
63
  */
50
64
  safeJavaScriptLink: boolean;
65
+ /**
66
+ * Automatically add `rel="noopener noreferrer"` to links with `target="_blank"`
67
+ *
68
+ * ```javascript
69
+ * Jodit.make('#editor', {
70
+ * cleanHTML: {
71
+ * safeLinksTarget: true
72
+ * }
73
+ * });
74
+ * ```
75
+ */
76
+ safeLinksTarget: boolean;
77
+ /**
78
+ * Whitelist of allowed CSS properties inside `style` attributes.
79
+ * If set, all CSS properties not in the list will be removed.
80
+ *
81
+ * ```javascript
82
+ * Jodit.make('#editor', {
83
+ * cleanHTML: {
84
+ * allowedStyles: {
85
+ * '*': ['color', 'background-color', 'font-size', 'text-align'],
86
+ * img: ['width', 'height']
87
+ * }
88
+ * }
89
+ * });
90
+ * ```
91
+ */
92
+ allowedStyles: false | IDictionary<string[]>;
93
+ /**
94
+ * Custom sanitizer function. Called after Jodit's built-in sanitization.
95
+ * Use this to integrate DOMPurify or other external sanitizers.
96
+ *
97
+ * ```javascript
98
+ * import DOMPurify from 'dompurify';
99
+ *
100
+ * Jodit.make('#editor', {
101
+ * cleanHTML: {
102
+ * sanitizer: (html) => DOMPurify.sanitize(html)
103
+ * }
104
+ * });
105
+ * ```
106
+ */
107
+ sanitizer: false | ((value: string) => string);
108
+ /**
109
+ * Automatically add `sandbox=""` attribute to all `<iframe>` elements in editor content.
110
+ * Prevents embedded content from running scripts or accessing the parent page.
111
+ *
112
+ * ```javascript
113
+ * Jodit.make('#editor', {
114
+ * cleanHTML: {
115
+ * sandboxIframesInContent: true
116
+ * }
117
+ * });
118
+ * ```
119
+ */
120
+ sandboxIframesInContent: boolean;
121
+ /**
122
+ * Convert unsafe embed elements to sandboxed `<iframe>`.
123
+ * - `['object', 'embed']` — default
124
+ * - `false` — disabled
125
+ * - `string[]` — custom list of tag names to convert
126
+ *
127
+ * ```javascript
128
+ * Jodit.make('#editor', {
129
+ * cleanHTML: {
130
+ * convertUnsafeEmbeds: Jodit.atom(['object', 'embed', 'applet'])
131
+ * }
132
+ * });
133
+ * ```
134
+ */
135
+ convertUnsafeEmbeds: false | string[];
51
136
  /**
52
137
  * The allowTags option defines which elements will remain in the
53
138
  * edited text when the editor saves. You can use this limit the returned HTML.
@@ -16,10 +16,16 @@ Config.prototype.cleanHTML = {
16
16
  b: 'strong'
17
17
  },
18
18
  allowTags: false,
19
- denyTags: 'script',
19
+ denyTags: 'script,iframe,object,embed',
20
20
  useIframeSandbox: false,
21
21
  removeOnError: true,
22
+ removeEventAttributes: true,
22
23
  safeJavaScriptLink: true,
24
+ safeLinksTarget: true,
25
+ allowedStyles: false,
26
+ sanitizer: false,
27
+ sandboxIframesInContent: true,
28
+ convertUnsafeEmbeds: ['object', 'embed'],
23
29
  disableCleanFilter: null
24
30
  };
25
31
  Config.prototype.controls.eraser = {
@@ -0,0 +1,14 @@
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/clean-html
8
+ */
9
+ import type { IJodit } from "../../../../../types/index";
10
+ /**
11
+ * Convert `<object>` and `<embed>` elements to safer `<iframe>` elements.
12
+ * @private
13
+ */
14
+ export declare function convertUnsafeEmbeds(jodit: IJodit, nodeElm: Node, hadEffect: boolean): boolean;
@@ -0,0 +1,37 @@
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 { Dom } from "../../../../../core/dom/dom.js";
7
+ import { attr } from "../../../../../core/helpers/utils/attr.js";
8
+ /**
9
+ * Convert `<object>` and `<embed>` elements to safer `<iframe>` elements.
10
+ * @private
11
+ */
12
+ export function convertUnsafeEmbeds(jodit, nodeElm, hadEffect) {
13
+ const opt = jodit.o.cleanHTML.convertUnsafeEmbeds;
14
+ if (!opt || !Dom.isElement(nodeElm)) {
15
+ return hadEffect;
16
+ }
17
+ const tag = nodeElm.nodeName.toLowerCase();
18
+ if (!opt.includes(tag)) {
19
+ return hadEffect;
20
+ }
21
+ const elm = nodeElm;
22
+ const src = attr(elm, 'data') || attr(elm, 'src') || attr(elm, 'movie') || '';
23
+ if (!src) {
24
+ Dom.safeRemove(elm);
25
+ return true;
26
+ }
27
+ const iframe = jodit.createInside.element('iframe');
28
+ attr(iframe, {
29
+ src,
30
+ sandbox: '',
31
+ frameborder: '0',
32
+ width: attr(elm, 'width'),
33
+ height: attr(elm, 'height')
34
+ });
35
+ Dom.replace(elm, iframe, undefined, false, true);
36
+ return true;
37
+ }
@@ -10,9 +10,13 @@
10
10
  * @private
11
11
  */
12
12
  export * from "./allow-attributes";
13
+ export * from "./convert-unsafe-embeds";
13
14
  export * from "./fill-empty-paragraph";
14
15
  export * from "./remove-empty-text-node";
15
16
  export * from "./remove-inv-text-nodes";
16
17
  export * from "./replace-old-tags";
18
+ export * from "./safe-links-target";
19
+ export * from "./sandbox-iframes-in-content";
17
20
  export * from "./sanitize-attributes";
21
+ export * from "./sanitize-styles";
18
22
  export * from "./try-remove-node";
@@ -10,9 +10,13 @@
10
10
  * @private
11
11
  */
12
12
  export * from "./allow-attributes.js";
13
+ export * from "./convert-unsafe-embeds.js";
13
14
  export * from "./fill-empty-paragraph.js";
14
15
  export * from "./remove-empty-text-node.js";
15
16
  export * from "./remove-inv-text-nodes.js";
16
17
  export * from "./replace-old-tags.js";
18
+ export * from "./safe-links-target.js";
19
+ export * from "./sandbox-iframes-in-content.js";
17
20
  export * from "./sanitize-attributes.js";
21
+ export * from "./sanitize-styles.js";
18
22
  export * from "./try-remove-node.js";
@@ -0,0 +1,14 @@
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/clean-html
8
+ */
9
+ import type { IJodit } from "../../../../../types/index";
10
+ /**
11
+ * Automatically add `rel="noopener noreferrer"` to links with `target="_blank"`
12
+ * @private
13
+ */
14
+ export declare function safeLinksTarget(jodit: IJodit, nodeElm: Node, hadEffect: boolean): boolean;
@@ -0,0 +1,38 @@
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 { Dom } from "../../../../../core/dom/dom.js";
7
+ import { attr } from "../../../../../core/helpers/utils/attr.js";
8
+ /**
9
+ * Automatically add `rel="noopener noreferrer"` to links with `target="_blank"`
10
+ * @private
11
+ */
12
+ export function safeLinksTarget(jodit, nodeElm, hadEffect) {
13
+ if (!jodit.o.cleanHTML.safeLinksTarget ||
14
+ !Dom.isElement(nodeElm) ||
15
+ nodeElm.nodeName !== 'A') {
16
+ return hadEffect;
17
+ }
18
+ const elm = nodeElm;
19
+ if (attr(elm, 'target') !== '_blank') {
20
+ return hadEffect;
21
+ }
22
+ const rel = attr(elm, 'rel') || '';
23
+ const parts = rel.split(/\s+/).filter(Boolean);
24
+ let changed = false;
25
+ if (!parts.includes('noopener')) {
26
+ parts.push('noopener');
27
+ changed = true;
28
+ }
29
+ if (!parts.includes('noreferrer')) {
30
+ parts.push('noreferrer');
31
+ changed = true;
32
+ }
33
+ if (changed) {
34
+ attr(elm, 'rel', parts.join(' '));
35
+ return true;
36
+ }
37
+ return hadEffect;
38
+ }
@@ -0,0 +1,14 @@
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/clean-html
8
+ */
9
+ import type { IJodit } from "../../../../../types/index";
10
+ /**
11
+ * Add `sandbox=""` attribute to all `<iframe>` elements in the editor content
12
+ * @private
13
+ */
14
+ export declare function sandboxIframesInContent(jodit: IJodit, nodeElm: Node, hadEffect: boolean): boolean;
@@ -0,0 +1,24 @@
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 { Dom } from "../../../../../core/dom/dom.js";
7
+ import { attr } from "../../../../../core/helpers/utils/attr.js";
8
+ /**
9
+ * Add `sandbox=""` attribute to all `<iframe>` elements in the editor content
10
+ * @private
11
+ */
12
+ export function sandboxIframesInContent(jodit, nodeElm, hadEffect) {
13
+ if (!jodit.o.cleanHTML.sandboxIframesInContent ||
14
+ !Dom.isElement(nodeElm) ||
15
+ nodeElm.nodeName !== 'IFRAME') {
16
+ return hadEffect;
17
+ }
18
+ const elm = nodeElm;
19
+ if (!elm.hasAttribute('sandbox')) {
20
+ attr(elm, 'sandbox', '');
21
+ return true;
22
+ }
23
+ return hadEffect;
24
+ }
@@ -9,11 +9,16 @@ import { sanitizeHTMLElement } from "../../../../../core/helpers/index.js";
9
9
  * @private
10
10
  */
11
11
  export function sanitizeAttributes(jodit, nodeElm, hadEffect) {
12
- if (Dom.isElement(nodeElm) &&
13
- sanitizeHTMLElement(nodeElm, {
14
- safeJavaScriptLink: jodit.options.cleanHTML.safeJavaScriptLink,
15
- removeOnError: jodit.options.cleanHTML.removeOnError
16
- })) {
12
+ if (!Dom.isElement(nodeElm)) {
13
+ return hadEffect;
14
+ }
15
+ const opts = jodit.options.cleanHTML;
16
+ if (sanitizeHTMLElement(nodeElm, {
17
+ safeJavaScriptLink: opts.safeJavaScriptLink,
18
+ removeOnError: opts.removeOnError,
19
+ removeEventAttributes: opts.removeEventAttributes,
20
+ safeLinksTarget: opts.safeLinksTarget
21
+ })) {
17
22
  return true;
18
23
  }
19
24
  return hadEffect;
@@ -0,0 +1,14 @@
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/clean-html
8
+ */
9
+ import type { IJodit } from "../../../../../types/index";
10
+ /**
11
+ * Filter CSS properties in style attributes based on allowedStyles whitelist
12
+ * @private
13
+ */
14
+ export declare function sanitizeStyles(jodit: IJodit, nodeElm: Node, hadEffect: boolean): boolean;