jodit 4.11.6 → 4.11.7

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 (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/es2015/jodit.css +1 -6
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +14 -14
  5. package/es2015/jodit.js +70 -11
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +5 -5
  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 +5 -5
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +25 -25
  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 +1 -6
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +6 -6
  23. package/es2021/jodit.js +70 -11
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +6 -6
  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 -6
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +6 -6
  35. package/es2021.en/jodit.js +70 -11
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +6 -6
  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 +2 -10
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +76 -13
  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/core/constants.js +1 -1
  60. package/esm/core/dom/dom.d.ts +4 -0
  61. package/esm/core/dom/dom.js +28 -0
  62. package/esm/core/selection/selection.js +3 -2
  63. package/esm/plugins/backspace/backspace.js +1 -0
  64. package/esm/plugins/focus/focus.js +11 -5
  65. package/esm/plugins/search/helpers/highlight-text-ranges.js +23 -0
  66. package/esm/plugins/wrap-nodes/wrap-nodes.js +5 -2
  67. package/package.json +1 -1
  68. package/types/core/dom/dom.d.ts +4 -0
package/es2021/jodit.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.11.6
4
+ * Version: v4.11.7
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1758,7 +1758,7 @@ __webpack_require__.r(__webpack_exports__);
1758
1758
  * ```
1759
1759
  * @packageDocumentation
1760
1760
  * @module constants
1761
- */ const APP_VERSION = "4.11.6";
1761
+ */ const APP_VERSION = "4.11.7";
1762
1762
  // prettier-ignore
1763
1763
  const ES = "es2021";
1764
1764
  const IS_ES_MODERN = true;
@@ -3208,6 +3208,31 @@ function wait(condition) {
3208
3208
  */ static canSplitBlock(node) {
3209
3209
  return !(0,jodit_core_helpers_checker_is_void__WEBPACK_IMPORTED_MODULE_7__.isVoid)(node) && Dom.isHTMLElement(node) && Dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && node.style !== undefined && !/^(fixed|absolute)/i.test(node.style.position);
3210
3210
  }
3211
+ /**
3212
+ * Get first matched node inside root
3213
+ */ static first(root, condition) {
3214
+ let first = root?.firstChild;
3215
+ if (!first) {
3216
+ return null;
3217
+ }
3218
+ do {
3219
+ if (condition(first)) {
3220
+ return first;
3221
+ }
3222
+ let next = first.firstChild;
3223
+ if (!next) {
3224
+ next = first.nextSibling;
3225
+ }
3226
+ if (!next && first.parentNode !== root) {
3227
+ do {
3228
+ first = first.parentNode;
3229
+ }while (first && !first?.nextSibling && first.parentNode !== root)
3230
+ next = first?.nextSibling;
3231
+ }
3232
+ first = next;
3233
+ }while (first)
3234
+ return null;
3235
+ }
3211
3236
  /**
3212
3237
  * Get last matched node inside root
3213
3238
  */ static last(root, condition) {
@@ -10137,7 +10162,8 @@ class Selection {
10137
10162
  */ restore() {
10138
10163
  let range = false;
10139
10164
  const markAttr = (start)=>`span[data-${jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.MARKER_CLASS}=${start ? 'start' : 'end'}]`;
10140
- const start = this.area.querySelector(markAttr(true)), end = this.area.querySelector(markAttr(false));
10165
+ const start = this.area.querySelector(markAttr(true));
10166
+ const end = this.area.querySelector(markAttr(false));
10141
10167
  if (!start) {
10142
10168
  return;
10143
10169
  }
@@ -10698,7 +10724,7 @@ class Selection {
10698
10724
  * Set range selection
10699
10725
  */ selectRange(range, focus = true) {
10700
10726
  const sel = this.sel;
10701
- if (focus && !this.isFocused()) {
10727
+ if (focus && !this.isFocused() && this.j.e.current !== 'focus') {
10702
10728
  this.focus();
10703
10729
  }
10704
10730
  if (sel) {
@@ -25585,6 +25611,7 @@ class backspace extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__.Plugin {
25585
25611
  sel.focus();
25586
25612
  }
25587
25613
  if ((0,_cases_check_not_collapsed__WEBPACK_IMPORTED_MODULE_8__.checkNotCollapsed)(jodit)) {
25614
+ jodit.e.fire('backSpaceAfterDelete', backspace);
25588
25615
  return false;
25589
25616
  }
25590
25617
  const range = sel.range;
@@ -29962,11 +29989,17 @@ function focus(editor) {
29962
29989
  }
29963
29990
  const focus = ()=>{
29964
29991
  editor.s.focus();
29965
- if (editor.o.cursorAfterAutofocus === 'end') {
29966
- const lastTextNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29967
- if (lastTextNode) {
29968
- editor.s.setCursorIn(lastTextNode, false);
29969
- }
29992
+ let textNode = null;
29993
+ switch(editor.o.cursorAfterAutofocus){
29994
+ case 'start':
29995
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.first(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29996
+ break;
29997
+ case 'end':
29998
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29999
+ break;
30000
+ }
30001
+ if (textNode) {
30002
+ editor.s.setCursorIn(textNode, editor.o.cursorAfterAutofocus === 'start');
29970
30003
  }
29971
30004
  };
29972
30005
  editor.e.on('afterInit', ()=>{
@@ -37635,6 +37668,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
37635
37668
  /**
37636
37669
  * @private
37637
37670
  */ const TMP_ATTR = 'jd-tmp-selection';
37671
+ const HIGHLIGHT_CSS = 'background-color: var(--jd-color-background-selection); color: var(--jd-color-text-selection);';
37672
+ const injectedDocs = new WeakSet();
37673
+ function ensureHighlightStyle(doc, useHighlightAPI) {
37674
+ if (injectedDocs.has(doc)) {
37675
+ return;
37676
+ }
37677
+ injectedDocs.add(doc);
37678
+ const rule = useHighlightAPI ? `::highlight(jodit-search-result) { ${HIGHLIGHT_CSS} }` : `[${TMP_ATTR}] { ${HIGHLIGHT_CSS} }`;
37679
+ try {
37680
+ const sheet = new CSSStyleSheet();
37681
+ sheet.insertRule(rule);
37682
+ doc.adoptedStyleSheets = [
37683
+ ...doc.adoptedStyleSheets,
37684
+ sheet
37685
+ ];
37686
+ } catch {
37687
+ const style = doc.createElement('style');
37688
+ style.textContent = rule;
37689
+ doc.head.appendChild(style);
37690
+ }
37691
+ }
37638
37692
  /**
37639
37693
  * @private
37640
37694
  */ function highlightTextRanges(jodit, rng, restRanges, ci, root) {
@@ -37644,6 +37698,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
37644
37698
  if (checkNativeSelectionMethod(jodit, rng, restRanges)) {
37645
37699
  return;
37646
37700
  }
37701
+ ensureHighlightStyle(jodit.ed, false);
37647
37702
  const span = ci.element('span', {
37648
37703
  [TMP_ATTR]: true
37649
37704
  });
@@ -37703,6 +37758,7 @@ function checkNativeSelectionMethod(jodit, rng, restRanges) {
37703
37758
  range.setEnd(rng.endContainer, rng.endOffset);
37704
37759
  return range;
37705
37760
  });
37761
+ ensureHighlightStyle(jodit.ed, true);
37706
37762
  const searchHighlight = new Highlight(...ranges);
37707
37763
  // @ts-ignore
37708
37764
  CSS.highlights.clear();
@@ -42235,7 +42291,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
42235
42291
  if (!jodit.isEditorMode()) {
42236
42292
  return;
42237
42293
  }
42238
- let child = jodit.editor.firstChild, isChanged = false;
42294
+ let child = jodit.editor.firstChild;
42295
+ let isChanged = false;
42239
42296
  while(child){
42240
42297
  child = checkAloneListLeaf(child, jodit);
42241
42298
  if (this.isSuitableStart(child)) {
@@ -42273,7 +42330,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
42273
42330
  const br = jodit.createInside.element('br');
42274
42331
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.append(box, br);
42275
42332
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.append(jodit.editor, box);
42276
- jodit.s.isFocused() && jodit.s.setCursorBefore(br);
42333
+ if (jodit.s.isFocused() || jodit.e.current === 'backSpaceAfterDelete') {
42334
+ jodit.s.setCursorBefore(br);
42335
+ }
42277
42336
  jodit.e.fire('internalChange');
42278
42337
  }
42279
42338
  constructor(...args){