jodit 4.17.5 → 4.17.6

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 (58) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +5 -5
  4. package/es2015/jodit.js +86 -35
  5. package/es2015/jodit.min.js +5 -5
  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 +5 -5
  13. package/es2018/jodit.min.js +5 -5
  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 +7 -7
  18. package/es2021/jodit.js +84 -35
  19. package/es2021/jodit.min.js +7 -7
  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 +7 -7
  28. package/es2021.en/jodit.js +84 -35
  29. package/es2021.en/jodit.min.js +8 -8
  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 +89 -35
  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/core/selection/selection.js +31 -5
  52. package/esm/modules/history/history.js +20 -12
  53. package/esm/plugins/line-height/line-height.js +1 -1
  54. package/esm/plugins/placeholder/placeholder.js +1 -1
  55. package/esm/plugins/source/editor/engines/ace.d.ts +2 -0
  56. package/esm/plugins/source/editor/engines/ace.js +35 -3
  57. package/package.json +1 -1
  58. package/types/plugins/source/editor/engines/ace.d.ts +2 -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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5
4
+ * Version: v4.17.6
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.17.5";
6
+ export const APP_VERSION = "4.17.6";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -25,6 +25,15 @@ import { moveTheNodeAlongTheEdgeOutward } from "./helpers/move-the-node-along-th
25
25
  import "./interface.js";
26
26
  import { CommitStyle } from "./style/commit-style.js";
27
27
  import { composedRanges, cursorInTheEdgeOfString, findCorrectCurrentNode } from "./helpers/index.js";
28
+ /**
29
+ * A text node that is empty or holds only invisible caret placeholders.
30
+ */
31
+ function isBlankTextNode(node) {
32
+ var _a;
33
+ return (Dom.isText(node) &&
34
+ ((_a = node.nodeValue) !== null && _a !== void 0 ? _a : '').replace(consts.INVISIBLE_SPACE_REG_EXP(), '')
35
+ .length === 0);
36
+ }
28
37
  export class Selection {
29
38
  constructor(jodit) {
30
39
  this.jodit = jodit;
@@ -287,6 +296,7 @@ export class Selection {
287
296
  * Create marker element
288
297
  */
289
298
  marker(atStart = false, range) {
299
+ var _a;
290
300
  let newRange = null;
291
301
  if (range) {
292
302
  newRange = range.cloneRange();
@@ -308,10 +318,24 @@ export class Selection {
308
318
  Dom.append(marker, this.j.createInside.text(consts.INVISIBLE_SPACE));
309
319
  if (newRange) {
310
320
  if (Dom.isOrContains(this.area, atStart ? newRange.startContainer : newRange.endContainer)) {
311
- // Here need do unsafe inserting
312
- // Deny Dom.safeInsertNode(newRange, marker);
313
- // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
314
- newRange.insertNode(marker);
321
+ const { startContainer: node, startOffset: offset } = newRange;
322
+ // At either end of a text node the marker goes beside it. Splitting
323
+ // the node there would leave the selection's boundary in an empty
324
+ // text node, and WebKit neither repaints a selection that leaves one
325
+ // nor moves a selection that follows one when it's removed.
326
+ if (Dom.isText(node) && offset === 0) {
327
+ Dom.before(node, marker);
328
+ }
329
+ else if (Dom.isText(node) &&
330
+ offset === ((_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length)) {
331
+ Dom.after(node, marker);
332
+ }
333
+ else {
334
+ // Here need do unsafe inserting
335
+ // Deny Dom.safeInsertNode(newRange, marker);
336
+ // Apply style -> Test Style module -> Base apply -> For selection <p><strong>|test|</strong></p> apply style {"element":"em","style":{"fontStyle":"italic"}}
337
+ newRange.insertNode(marker);
338
+ }
315
339
  }
316
340
  }
317
341
  return marker;
@@ -651,7 +675,9 @@ export class Selection {
651
675
  () => { var _a; return (_a = firstChild === null || firstChild === void 0 ? void 0 : firstChild.previousSibling) === null || _a === void 0 ? void 0 : _a.lastChild; }
652
676
  ].forEach(getChildNode => {
653
677
  const childNode = getChildNode();
654
- if (childNode && Dom.isEmptyTextNode(childNode)) {
678
+ // Only a text node left with nothing in it by the split
679
+ // goes; one holding a space is content (`<b>a</b> |`).
680
+ if (childNode && isBlankTextNode(childNode)) {
655
681
  Dom.safeRemove(childNode);
656
682
  }
657
683
  });
@@ -133,20 +133,28 @@ export class History extends ViewComponent {
133
133
  */
134
134
  updateStack(replace = false) {
135
135
  const newValue = this.snapshot.make();
136
- if (!Snapshot.equal(newValue, this.startValue)) {
137
- const newCommand = new Command(this.startValue, newValue, this, this.updateTick);
138
- if (replace) {
139
- const command = this.__stack.current();
140
- if (command && this.updateTick === command.tick) {
141
- this.__stack.replace(newCommand);
142
- }
143
- }
144
- else {
145
- this.__stack.push(newCommand);
146
- }
136
+ if (Snapshot.equal(newValue, this.startValue)) {
137
+ return;
138
+ }
139
+ // Only the selection moved, for example when the selection markers
140
+ // went in before a switch to the source view. There is nothing to
141
+ // undo, but the next change has to start from this selection.
142
+ if (newValue.html === this.startValue.html) {
147
143
  this.startValue = newValue;
148
- this.fireChangeStack();
144
+ return;
145
+ }
146
+ const newCommand = new Command(this.startValue, newValue, this, this.updateTick);
147
+ if (replace) {
148
+ const command = this.__stack.current();
149
+ if (command && this.updateTick === command.tick) {
150
+ this.__stack.replace(newCommand);
151
+ }
149
152
  }
153
+ else {
154
+ this.__stack.push(newCommand);
155
+ }
156
+ this.startValue = newValue;
157
+ this.fireChangeStack();
150
158
  }
151
159
  fireChangeStack() {
152
160
  var _a;
@@ -58,7 +58,7 @@ export class lineHeight extends Plugin {
58
58
  try {
59
59
  if (s.isCollapsed()) {
60
60
  const fake = c.fake();
61
- s.insertNode(fake, false, false);
61
+ Dom.safeInsertNode(s.range, fake);
62
62
  apply(fake);
63
63
  Dom.safeRemove(fake);
64
64
  }
@@ -69,7 +69,7 @@ export class placeholder extends Plugin {
69
69
  .on('changePlace.placeholder', this.addNativeListeners)
70
70
  .on('change.placeholder focus.placeholder keyup.placeholder mouseup.placeholder keydown.placeholder ' +
71
71
  'mousedown.placeholder afterSetMode.placeholder changePlace.placeholder ' +
72
- 'internalChange.placeholder', this.toggle)
72
+ 'internalChange.placeholder afterCommand.placeholder', this.toggle)
73
73
  .on(window, 'load', this.toggle);
74
74
  this.addNativeListeners();
75
75
  this.toggle();
@@ -25,6 +25,8 @@ export declare class AceEditor extends SourceEditor<AceAjax.Editor> implements I
25
25
  init(editor: IJodit): any;
26
26
  destruct(): any;
27
27
  setValue(value: string): void;
28
+ private __settingValue;
29
+ private __onChange;
28
30
  getValue(): string;
29
31
  setReadOnly(isReadOnly: boolean): void;
30
32
  get isFocused(): boolean;
@@ -3,7 +3,18 @@
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
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
9
+ r = Reflect.decorate(decorators, target, key, desc);
10
+ else
11
+ for (var i = decorators.length - 1; i >= 0; i--)
12
+ if (d = decorators[i])
13
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
6
16
  import * as constants from "../../../../core/constants.js";
17
+ import { autobind } from "../../../../core/decorators/autobind/autobind.js";
7
18
  import { Dom } from "../../../../core/dom/dom.js";
8
19
  import { isString, loadNext } from "../../../../core/helpers/index.js";
9
20
  import { SourceEditor } from "../sourceEditor.js";
@@ -23,6 +34,7 @@ export class AceEditor extends SourceEditor {
23
34
  this.proxyOnMouseDown = (e) => {
24
35
  this.j.e.fire('mousedown', e);
25
36
  };
37
+ this.__settingValue = false;
26
38
  }
27
39
  aceExists() {
28
40
  return this.j.ow.ace !== undefined;
@@ -98,7 +110,7 @@ export class AceEditor extends SourceEditor {
98
110
  this.instance.setOption('wrap', editor.o.sourceEditorNativeOptions.wrap);
99
111
  this.instance.getSession().setUseWorker(false);
100
112
  this.instance.$blockScrolling = Infinity;
101
- this.instance.on('change', this.toWYSIWYG);
113
+ this.instance.on('change', this.__onChange);
102
114
  this.instance.on('focus', this.proxyOnFocus);
103
115
  this.instance.on('mousedown', this.proxyOnMouseDown);
104
116
  this.instance.on('blur', this.proxyOnBlur);
@@ -155,7 +167,7 @@ export class AceEditor extends SourceEditor {
155
167
  }
156
168
  destruct() {
157
169
  var _a, _b;
158
- this.instance.off('change', this.toWYSIWYG);
170
+ this.instance.off('change', this.__onChange);
159
171
  this.instance.off('focus', this.proxyOnFocus);
160
172
  this.instance.off('mousedown', this.proxyOnMouseDown);
161
173
  this.instance.destroy();
@@ -168,9 +180,26 @@ export class AceEditor extends SourceEditor {
168
180
  value = html;
169
181
  }
170
182
  }
171
- this.instance.setValue(value);
183
+ // ACE reports its own `setValue` as two changes, the removal of the
184
+ // old text and the insertion of the new one. Fed back into the
185
+ // editor they became two history entries, `content -> ''` and
186
+ // `'' -> content`, so the first undo after a switch to the source
187
+ // view and back emptied the editor. The text came from the editor
188
+ // in the first place, so there is nothing to send back.
189
+ this.__settingValue = true;
190
+ try {
191
+ this.instance.setValue(value);
192
+ }
193
+ finally {
194
+ this.__settingValue = false;
195
+ }
172
196
  this.instance.clearSelection();
173
197
  }
198
+ __onChange() {
199
+ if (!this.__settingValue) {
200
+ this.toWYSIWYG();
201
+ }
202
+ }
174
203
  getValue() {
175
204
  return this.instance.getValue();
176
205
  }
@@ -230,3 +259,6 @@ export class AceEditor extends SourceEditor {
230
259
  });
231
260
  }
232
261
  }
262
+ __decorate([
263
+ autobind
264
+ ], AceEditor.prototype, "__onChange", null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.17.5",
3
+ "version": "4.17.6",
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",
@@ -25,6 +25,8 @@ export declare class AceEditor extends SourceEditor<AceAjax.Editor> implements I
25
25
  init(editor: IJodit): any;
26
26
  destruct(): any;
27
27
  setValue(value: string): void;
28
+ private __settingValue;
29
+ private __onChange;
28
30
  getValue(): string;
29
31
  setReadOnly(isReadOnly: boolean): void;
30
32
  get isFocused(): boolean;