jodit 4.4.7 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +25 -3
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +82 -40
  5. package/es2015/jodit.min.js +2 -2
  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.css +1 -1
  13. package/es2018/jodit.fat.min.js +2 -2
  14. package/es2018/jodit.js +82 -40
  15. package/es2018/jodit.min.js +2 -2
  16. package/es2018/plugins/debug/debug.css +1 -1
  17. package/es2018/plugins/debug/debug.js +1 -1
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  20. package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  22. package/es2021/jodit.css +1 -1
  23. package/es2021/jodit.fat.min.js +2 -2
  24. package/es2021/jodit.js +82 -40
  25. package/es2021/jodit.min.js +2 -2
  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 +1 -1
  33. package/es2021.en/jodit.fat.min.js +2 -2
  34. package/es2021.en/jodit.js +82 -40
  35. package/es2021.en/jodit.min.js +2 -2
  36. package/es2021.en/plugins/debug/debug.css +1 -1
  37. package/es2021.en/plugins/debug/debug.js +1 -1
  38. package/es2021.en/plugins/debug/debug.min.js +1 -1
  39. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  40. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  42. package/es5/5.fat.min.js +1 -1
  43. package/es5/5.min.js +1 -1
  44. package/es5/975.fat.min.js +1 -1
  45. package/es5/975.min.js +1 -1
  46. package/es5/jodit.css +2 -2
  47. package/es5/jodit.fat.min.js +2 -2
  48. package/es5/jodit.js +82 -40
  49. package/es5/jodit.min.css +2 -2
  50. package/es5/jodit.min.js +2 -2
  51. package/es5/plugins/debug/debug.css +1 -1
  52. package/es5/plugins/debug/debug.js +1 -1
  53. package/es5/plugins/debug/debug.min.js +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  56. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  57. package/esm/core/constants.js +1 -1
  58. package/esm/core/dom/dom.d.ts +5 -0
  59. package/esm/core/dom/dom.js +36 -12
  60. package/esm/plugins/clean-html/helpers/visitor/filters/try-remove-node.js +11 -5
  61. package/esm/plugins/indent/indent.js +34 -22
  62. package/package.json +1 -1
  63. package/types/core/dom/dom.d.ts +5 -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.4.7
4
+ * Version: v4.5.1
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.4.7
4
+ * Version: v4.5.1
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.4.7
4
+ * Version: v4.5.1
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.4.7
4
+ * Version: v4.5.1
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.4.7
4
+ * Version: v4.5.1
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.4.7
4
+ * Version: v4.5.1
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -3,7 +3,7 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- export const APP_VERSION = "4.4.7";
6
+ export const APP_VERSION = "4.5.1";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -18,6 +18,11 @@ export declare class Dom {
18
18
  * Remove all content from element
19
19
  */
20
20
  static detach(node: Nullable<Node>): void;
21
+ /**
22
+ * Wrap all inline next siblings
23
+ */
24
+ static wrapNextInline(current: Node, tag: Node | HTMLTagNames, editor: IJodit): HTMLElement;
25
+ private static __wrapElements;
21
26
  /**
22
27
  * Wrap all inline siblings
23
28
  */
@@ -25,28 +25,25 @@ export class Dom {
25
25
  }
26
26
  }
27
27
  /**
28
- * Wrap all inline siblings
28
+ * Wrap all inline next siblings
29
29
  */
30
- static wrapInline(current, tag, editor) {
31
- let tmp, first = current, last = current;
30
+ static wrapNextInline(current, tag, editor) {
31
+ let tmp;
32
+ const first = current;
33
+ let last = current;
32
34
  editor.s.save();
33
35
  let needFindNext = false;
34
- do {
35
- needFindNext = false;
36
- tmp = first.previousSibling;
37
- if (tmp && !Dom.isBlock(tmp)) {
38
- needFindNext = true;
39
- first = tmp;
40
- }
41
- } while (needFindNext);
42
36
  do {
43
37
  needFindNext = false;
44
38
  tmp = last.nextSibling;
45
- if (tmp && !Dom.isBlock(tmp)) {
39
+ if (tmp && !Dom.isBlock(tmp) && !Dom.isTag(tmp, 'br')) {
46
40
  needFindNext = true;
47
41
  last = tmp;
48
42
  }
49
43
  } while (needFindNext);
44
+ return Dom.__wrapElements(tag, editor, first, last);
45
+ }
46
+ static __wrapElements(tag, editor, first, last) {
50
47
  const wrapper = isString(tag) ? editor.createInside.element(tag) : tag;
51
48
  if (first.parentNode) {
52
49
  first.parentNode.insertBefore(wrapper, first);
@@ -63,6 +60,33 @@ export class Dom {
63
60
  editor.s.restore();
64
61
  return wrapper;
65
62
  }
63
+ /**
64
+ * Wrap all inline siblings
65
+ */
66
+ static wrapInline(current, tag, editor) {
67
+ let tmp;
68
+ let first = current;
69
+ let last = current;
70
+ editor.s.save();
71
+ let needFindNext = false;
72
+ do {
73
+ needFindNext = false;
74
+ tmp = first.previousSibling;
75
+ if (tmp && !Dom.isBlock(tmp)) {
76
+ needFindNext = true;
77
+ first = tmp;
78
+ }
79
+ } while (needFindNext);
80
+ do {
81
+ needFindNext = false;
82
+ tmp = last.nextSibling;
83
+ if (tmp && !Dom.isBlock(tmp)) {
84
+ needFindNext = true;
85
+ last = tmp;
86
+ }
87
+ } while (needFindNext);
88
+ return Dom.__wrapElements(tag, editor, first, last);
89
+ }
66
90
  /**
67
91
  * Wrap node inside another node
68
92
  */
@@ -20,12 +20,18 @@ export function tryRemoveNode(jodit, nodeElm, hadEffect, allowTags, denyTags, cu
20
20
  * @private
21
21
  */
22
22
  function isRemovableNode(jodit, node, current, allow, deny) {
23
- if (!Dom.isText(node) &&
24
- ((allow && !allow[node.nodeName]) || (deny && deny[node.nodeName]))) {
25
- return true;
23
+ if (!Dom.isText(node)) {
24
+ if (allow && !allow[node.nodeName]) {
25
+ return true;
26
+ }
27
+ if (!allow && deny && deny[node.nodeName]) {
28
+ return true;
29
+ }
30
+ }
31
+ if (!jodit.o.cleanHTML.removeEmptyElements) {
32
+ return false;
26
33
  }
27
- return (jodit.o.cleanHTML.removeEmptyElements &&
28
- Dom.isElement(node) &&
34
+ return (Dom.isElement(node) &&
29
35
  node.nodeName.match(IS_INLINE) != null &&
30
36
  !Dom.isTemporary(node) &&
31
37
  trim(node.innerHTML).length === 0 &&
@@ -3,12 +3,28 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- import { BR, PARAGRAPH } from "../../core/constants.js";
6
+ import { BR } from "../../core/constants.js";
7
7
  import { Dom } from "../../core/dom/index.js";
8
8
  import { pluginSystem } from "../../core/global.js";
9
- import { attr } from "../../core/helpers/index.js";
9
+ import { attr, call } from "../../core/helpers/utils/index.js";
10
10
  import "./config.js";
11
11
  import { getKey } from "./helpers.js";
12
+ const applyIndentToBox = (processedElements, currentBox, editor, command) => {
13
+ if (!currentBox) {
14
+ return;
15
+ }
16
+ if (processedElements.has(currentBox)) {
17
+ return;
18
+ }
19
+ const key = getKey(editor.o.direction, currentBox);
20
+ processedElements.add(currentBox);
21
+ let value = currentBox.style[key] ? parseInt(currentBox.style[key], 10) : 0;
22
+ value += editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
23
+ currentBox.style[key] = value > 0 ? value + 'px' : '';
24
+ if (!attr(currentBox, 'style')) {
25
+ attr(currentBox, 'style', null);
26
+ }
27
+ };
12
28
  /**
13
29
  * Indents the line containing the selection or insertion point.
14
30
  */
@@ -22,46 +38,42 @@ export function indent(editor) {
22
38
  name: 'outdent',
23
39
  group: 'indent'
24
40
  });
25
- const callback = (command) => {
26
- const processedElements = [];
41
+ const indentCommand = (command) => {
42
+ const processedElements = new Set();
43
+ const { enter, enterBlock } = editor.o;
44
+ const isBrMode = enter.toLowerCase() === BR;
45
+ const current = editor.s.current();
46
+ if (isBrMode && editor.s.isCollapsed()) {
47
+ if (current) {
48
+ const box = Dom.wrapNextInline(current, enterBlock, editor);
49
+ applyIndentToBox(processedElements, box, editor, command);
50
+ return false;
51
+ }
52
+ }
27
53
  editor.s.eachSelection((current) => {
28
54
  editor.s.save();
29
55
  let currentBox = current
30
56
  ? Dom.up(current, Dom.isBlock, editor.editor)
31
57
  : false;
32
- const { enter } = editor.o;
33
58
  if (!currentBox && current) {
34
- currentBox = Dom.wrapInline(current, enter !== BR ? enter : PARAGRAPH, editor);
59
+ currentBox = call(!isBrMode ? Dom.wrapInline : Dom.wrapNextInline, current, !isBrMode ? enter.toLowerCase() : enterBlock, editor);
35
60
  }
36
61
  if (!currentBox) {
37
62
  editor.s.restore();
38
63
  return false;
39
64
  }
40
- const alreadyIndented = processedElements.includes(currentBox);
41
- if (currentBox && !alreadyIndented) {
42
- const key = getKey(editor.o.direction, currentBox);
43
- processedElements.push(currentBox);
44
- let value = currentBox.style[key]
45
- ? parseInt(currentBox.style[key], 10)
46
- : 0;
47
- value +=
48
- editor.o.indentMargin * (command === 'outdent' ? -1 : 1);
49
- currentBox.style[key] = value > 0 ? value + 'px' : '';
50
- if (!attr(currentBox, 'style')) {
51
- attr(currentBox, 'style', null);
52
- }
53
- }
65
+ applyIndentToBox(processedElements, currentBox, editor, command);
54
66
  editor.s.restore();
55
67
  });
56
68
  editor.synchronizeValues();
57
69
  return false;
58
70
  };
59
71
  editor.registerCommand('indent', {
60
- exec: callback,
72
+ exec: indentCommand,
61
73
  hotkeys: ['ctrl+]', 'cmd+]']
62
74
  });
63
75
  editor.registerCommand('outdent', {
64
- exec: callback,
76
+ exec: indentCommand,
65
77
  hotkeys: ['ctrl+[', 'cmd+[']
66
78
  });
67
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.4.7",
3
+ "version": "4.5.1",
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",
@@ -18,6 +18,11 @@ export declare class Dom {
18
18
  * Remove all content from element
19
19
  */
20
20
  static detach(node: Nullable<Node>): void;
21
+ /**
22
+ * Wrap all inline next siblings
23
+ */
24
+ static wrapNextInline(current: Node, tag: Node | HTMLTagNames, editor: IJodit): HTMLElement;
25
+ private static __wrapElements;
21
26
  /**
22
27
  * Wrap all inline siblings
23
28
  */