jodit 4.20.2 → 4.20.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 (61) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +6 -6
  4. package/es2015/jodit.js +90 -21
  5. package/es2015/jodit.min.js +6 -6
  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 +6 -6
  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 +6 -6
  18. package/es2021/jodit.js +87 -21
  19. package/es2021/jodit.min.js +6 -6
  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 +6 -6
  28. package/es2021.en/jodit.js +87 -21
  29. package/es2021.en/jodit.min.js +6 -6
  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 +98 -21
  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/core/constants.js +1 -1
  51. package/esm/modules/file-browser/builders/context-menu.js +6 -2
  52. package/esm/modules/toolbar/factory.js +3 -1
  53. package/esm/plugins/backspace/cases/check-not-collapsed.js +1 -1
  54. package/esm/plugins/delete/delete.d.ts +12 -0
  55. package/esm/plugins/delete/delete.js +66 -4
  56. package/esm/plugins/delete/interface.d.ts +4 -2
  57. package/esm/plugins/dtd/after-insert/remove-extra-br.js +7 -1
  58. package/esm/plugins/placeholder/placeholder.js +3 -1
  59. package/package.json +1 -1
  60. package/types/plugins/delete/delete.d.ts +12 -0
  61. package/types/plugins/delete/interface.d.ts +4 -2
@@ -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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.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.20.2
4
+ * Version: v4.20.3
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- export const APP_VERSION = "4.20.2";
6
+ export const APP_VERSION = "4.20.3";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -81,12 +81,13 @@ export default (self) => {
81
81
  }), temp_content = self.c.div(CLASS_PREVIEW, '<div class="jodit-icon_loader"></div>'), preview_box = self.c.div(CLASS_PREVIEW + '__box'), next = self.c.fromHTML(preview_tpl_next()), prev = self.c.fromHTML(preview_tpl_next('prev', 'left')), addLoadHandler = (src) => {
82
82
  const image = self.c.element('img');
83
83
  attr(image, 'src', src);
84
+ attr(image, 'alt', ga('data-name'));
84
85
  const onload = () => {
85
86
  var _a;
86
87
  if (self.isInDestruct) {
87
88
  return;
88
89
  }
89
- self.e.off(image, 'load');
90
+ self.e.off(image, 'load error');
90
91
  Dom.detach(temp_content);
91
92
  if (opt.showPreviewNavigation) {
92
93
  if (Dom.prevWithClass(item, self.files.getFullElName('item'))) {
@@ -101,7 +102,10 @@ export default (self) => {
101
102
  preview.setPosition();
102
103
  (_a = self === null || self === void 0 ? void 0 : self.events) === null || _a === void 0 ? void 0 : _a.fire('previewOpenedAndLoaded');
103
104
  };
104
- self.e.on(image, 'load', onload);
105
+ // An image that can't load is shown too,
106
+ // broken with the file's name, rather
107
+ // than the loader for good
108
+ self.e.on(image, 'load error', onload);
105
109
  if (image.complete) {
106
110
  onload();
107
111
  }
@@ -41,5 +41,7 @@ export function makeButton(jodit, control, target = null) {
41
41
  }
42
42
  export function makeSelect(view, control, target = null) {
43
43
  const ToolbarSelect = getComponentClass('ToolbarSelect');
44
- return new ToolbarSelect(view, control, target);
44
+ const select = new ToolbarSelect(view, control, target);
45
+ select.state.tabIndex = view.o.allowTabNavigation ? 0 : -1;
46
+ return select;
45
47
  }
@@ -18,7 +18,7 @@
18
18
  */
19
19
  export function checkNotCollapsed(jodit) {
20
20
  if (!jodit.s.isCollapsed()) {
21
- jodit.execCommand('Delete');
21
+ jodit.execCommand('delete', false, true);
22
22
  return true;
23
23
  }
24
24
  return false;
@@ -27,6 +27,18 @@ export declare class deleteCommand extends Plugin {
27
27
  * Firefox's own delete
28
28
  */
29
29
  private __moveEdgesIntoCells;
30
+ /**
31
+ * The formatting elements the deletion takes whole from its start,
32
+ * outermost first: `<strong>` and `<em>` for all of the text in
33
+ * `<strong><em>cd</em></strong>`
34
+ */
35
+ private __formatTakenWhole;
36
+ /**
37
+ * As the browsers do, the next letter typed keeps the formatting that was
38
+ * deleted whole: empty copies go where it was, round an invisible space,
39
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
40
+ */
41
+ private __keepFormat;
30
42
  /**
31
43
  * A selection that starts or ends in a table cell clears the selected part
32
44
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -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
- import { NBSP_SPACE } from "../../core/constants.js";
6
+ import { INVISIBLE_SPACE, NBSP_SPACE } from "../../core/constants.js";
7
7
  import { Dom } from "../../core/dom/index.js";
8
8
  import { pluginSystem } from "../../core/global.js";
9
9
  import { call, toArray, trimInv } from "../../core/helpers/index.js";
@@ -18,6 +18,18 @@ const NOT_EMPTY_CONTENT_TAGS = new Set([
18
18
  'hr'
19
19
  ]);
20
20
  const KEEPS_SPACES = new Set(['pre', 'pre-wrap', 'break-spaces']);
21
+ /**
22
+ * Formatting that the next letter keeps once all of the text in it is
23
+ * deleted with a key: a formatting tag, or a span with styles of its own.
24
+ * Not a link, which new text isn't added to, or a wrapper such as a video's
25
+ */
26
+ function keepsFormat(node) {
27
+ return (Dom.isHTMLElement(node) &&
28
+ !node.hasAttribute('contenteditable') &&
29
+ !Dom.isTemporary(node) &&
30
+ (/^(STRONG|B|EM|I|U|S|SUB|SUP)$/.test(node.nodeName) ||
31
+ (Dom.isTag(node, 'span') && node.hasAttribute('style'))));
32
+ }
21
33
  /**
22
34
  * A plain space beside this neighbor isn't shown: there is none, or it's a
23
35
  * line break, a block or text starting (or ending) with a plain space
@@ -76,7 +88,7 @@ export class deleteCommand extends Plugin {
76
88
  jodit.s.removeNode(node);
77
89
  }
78
90
  }
79
- __onDeleteCommand() {
91
+ __onDeleteCommand(command, showUI, keepFormat) {
80
92
  const { jodit } = this;
81
93
  if (jodit.s.isCollapsed()) {
82
94
  return;
@@ -84,6 +96,7 @@ export class deleteCommand extends Plugin {
84
96
  jodit.s.expandSelection();
85
97
  const range = jodit.s.range;
86
98
  this.__moveEdgesIntoCells(range);
99
+ const format = keepFormat === true ? this.__formatTakenWhole(range) : [];
87
100
  const caret = this.__clearSelectedCells(range);
88
101
  if (caret && range.collapsed) {
89
102
  jodit.s.selectRange(caret);
@@ -99,8 +112,13 @@ export class deleteCommand extends Plugin {
99
112
  this.__keepSpacesVisibleBesideTable(fake);
100
113
  range.setStartBefore(fake);
101
114
  range.collapse(true);
102
- this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
103
- this.__addBrInEmptyBlock(fake, range);
115
+ if (format.length && !caret) {
116
+ this.__keepFormat(format, fake, range);
117
+ }
118
+ else {
119
+ this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
120
+ this.__addBrInEmptyBlock(fake, range);
121
+ }
104
122
  Dom.safeRemove(fake);
105
123
  jodit.s.selectRange(caret !== null && caret !== void 0 ? caret : range);
106
124
  return false;
@@ -126,6 +144,50 @@ export class deleteCommand extends Plugin {
126
144
  range.setEnd(last, last.childNodes.length);
127
145
  }
128
146
  }
147
+ /**
148
+ * The formatting elements the deletion takes whole from its start,
149
+ * outermost first: `<strong>` and `<em>` for all of the text in
150
+ * `<strong><em>cd</em></strong>`
151
+ */
152
+ __formatTakenWhole(range) {
153
+ const format = [];
154
+ const whole = this.jodit.s.createRange();
155
+ const { startContainer, startOffset } = range;
156
+ let node = Dom.isText(startContainer)
157
+ ? null
158
+ : startContainer.childNodes[startOffset];
159
+ // Through a block taken whole, as a line holding only the word is
160
+ while (Dom.isHTMLElement(node)) {
161
+ whole.selectNode(node);
162
+ if (range.compareBoundaryPoints(Range.END_TO_END, whole) < 0) {
163
+ break;
164
+ }
165
+ if (keepsFormat(node)) {
166
+ format.push(node);
167
+ }
168
+ else if (format.length || !Dom.isBlock(node)) {
169
+ break;
170
+ }
171
+ node = toArray(node.childNodes).find(child => { var _a; return !Dom.isText(child) || trimInv((_a = child.nodeValue) !== null && _a !== void 0 ? _a : ''); });
172
+ }
173
+ return format;
174
+ }
175
+ /**
176
+ * As the browsers do, the next letter typed keeps the formatting that was
177
+ * deleted whole: empty copies go where it was, round an invisible space,
178
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
179
+ */
180
+ __keepFormat(format, fake, range) {
181
+ const copies = format.map(element => element.cloneNode(false));
182
+ for (let i = 1; i < copies.length; i += 1) {
183
+ Dom.append(copies[i - 1], copies[i]);
184
+ }
185
+ const text = this.jodit.createInside.text(INVISIBLE_SPACE);
186
+ Dom.append(copies[copies.length - 1], text);
187
+ Dom.before(fake, copies[0]);
188
+ range.setStartAfter(text);
189
+ range.collapse(true);
190
+ }
129
191
  /**
130
192
  * A selection that starts or ends in a table cell clears the selected part
131
193
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -9,8 +9,10 @@
9
9
  declare module 'jodit/types/jodit' {
10
10
  interface IJodit {
11
11
  /**
12
- * Delete plugin: Remove selected text
12
+ * Delete plugin: Remove selected text. With `keepFormat`, as after
13
+ * Backspace or Delete, the next letter keeps the formatting of an
14
+ * element whose text was deleted whole
13
15
  */
14
- execCommand(command: 'delete'): void;
16
+ execCommand(command: 'delete', showUI?: boolean, keepFormat?: boolean): void;
15
17
  }
16
18
  }
@@ -37,7 +37,13 @@ export function removeExtraBr(jodit, node) {
37
37
  // text; moving it before the `<br>` would put it on a line of its own
38
38
  // below the block (#1315)
39
39
  if (!Dom.isOrContains(node, jodit.s.range.startContainer)) {
40
- jodit.s.setCursorBefore(br);
40
+ // Not with setCursorBefore: the text node it adds for the caret
41
+ // stays after the inserted element once the `<br>` has gone, and
42
+ // Right or End then take the caret into it, out of the element
43
+ const range = jodit.s.createRange();
44
+ range.setStartBefore(br);
45
+ range.collapse(true);
46
+ jodit.s.selectRange(range);
41
47
  }
42
48
  Dom.safeRemove(br);
43
49
  }
@@ -19,6 +19,7 @@ import { debounce } from "../../core/decorators/index.js";
19
19
  import { Dom } from "../../core/dom/dom.js";
20
20
  import { pluginSystem } from "../../core/global.js";
21
21
  import { isMarker } from "../../core/helpers/checker/is-marker.js";
22
+ import { isAnchor } from "../../core/helpers/utils/anchor.js";
22
23
  import { attr } from "../../core/helpers/utils/attr.js";
23
24
  import { css } from "../../core/helpers/utils/css.js";
24
25
  import { Plugin } from "../../core/plugin/plugin.js";
@@ -51,8 +52,9 @@ function isBlank(root) {
51
52
  if (Dom.isText(first) && !next) {
52
53
  return Dom.isEmptyTextNode(first);
53
54
  }
55
+ // An anchor has no text, but it's content, shown as a marker
54
56
  return (!next &&
55
- Dom.each(first, elm => !(Dom.isLeaf(elm) || Dom.isList(elm)) &&
57
+ Dom.each(first, elm => !(Dom.isLeaf(elm) || Dom.isList(elm) || isAnchor(elm)) &&
56
58
  (Dom.isEmpty(elm) || Dom.isTag(elm, 'br'))));
57
59
  }
58
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.20.2",
3
+ "version": "4.20.3",
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",
@@ -27,6 +27,18 @@ export declare class deleteCommand extends Plugin {
27
27
  * Firefox's own delete
28
28
  */
29
29
  private __moveEdgesIntoCells;
30
+ /**
31
+ * The formatting elements the deletion takes whole from its start,
32
+ * outermost first: `<strong>` and `<em>` for all of the text in
33
+ * `<strong><em>cd</em></strong>`
34
+ */
35
+ private __formatTakenWhole;
36
+ /**
37
+ * As the browsers do, the next letter typed keeps the formatting that was
38
+ * deleted whole: empty copies go where it was, round an invisible space,
39
+ * as Bold does at a collapsed caret, and the caret goes inside (#1784)
40
+ */
41
+ private __keepFormat;
30
42
  /**
31
43
  * A selection that starts or ends in a table cell clears the selected part
32
44
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -9,8 +9,10 @@
9
9
  declare module 'jodit/types/jodit' {
10
10
  interface IJodit {
11
11
  /**
12
- * Delete plugin: Remove selected text
12
+ * Delete plugin: Remove selected text. With `keepFormat`, as after
13
+ * Backspace or Delete, the next letter keeps the formatting of an
14
+ * element whose text was deleted whole
13
15
  */
14
- execCommand(command: 'delete'): void;
16
+ execCommand(command: 'delete', showUI?: boolean, keepFormat?: boolean): void;
15
17
  }
16
18
  }