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
@@ -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) {
@@ -25515,6 +25541,7 @@ class backspace extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__.Plugin {
25515
25541
  sel.focus();
25516
25542
  }
25517
25543
  if ((0,_cases_check_not_collapsed__WEBPACK_IMPORTED_MODULE_8__.checkNotCollapsed)(jodit)) {
25544
+ jodit.e.fire('backSpaceAfterDelete', backspace);
25518
25545
  return false;
25519
25546
  }
25520
25547
  const range = sel.range;
@@ -29558,11 +29585,17 @@ function focus(editor) {
29558
29585
  }
29559
29586
  const focus = ()=>{
29560
29587
  editor.s.focus();
29561
- if (editor.o.cursorAfterAutofocus === 'end') {
29562
- const lastTextNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29563
- if (lastTextNode) {
29564
- editor.s.setCursorIn(lastTextNode, false);
29565
- }
29588
+ let textNode = null;
29589
+ switch(editor.o.cursorAfterAutofocus){
29590
+ case 'start':
29591
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.first(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29592
+ break;
29593
+ case 'end':
29594
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node));
29595
+ break;
29596
+ }
29597
+ if (textNode) {
29598
+ editor.s.setCursorIn(textNode, editor.o.cursorAfterAutofocus === 'start');
29566
29599
  }
29567
29600
  };
29568
29601
  editor.e.on('afterInit', ()=>{
@@ -36881,6 +36914,27 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
36881
36914
  /**
36882
36915
  * @private
36883
36916
  */ const TMP_ATTR = 'jd-tmp-selection';
36917
+ const HIGHLIGHT_CSS = 'background-color: var(--jd-color-background-selection); color: var(--jd-color-text-selection);';
36918
+ const injectedDocs = new WeakSet();
36919
+ function ensureHighlightStyle(doc, useHighlightAPI) {
36920
+ if (injectedDocs.has(doc)) {
36921
+ return;
36922
+ }
36923
+ injectedDocs.add(doc);
36924
+ const rule = useHighlightAPI ? `::highlight(jodit-search-result) { ${HIGHLIGHT_CSS} }` : `[${TMP_ATTR}] { ${HIGHLIGHT_CSS} }`;
36925
+ try {
36926
+ const sheet = new CSSStyleSheet();
36927
+ sheet.insertRule(rule);
36928
+ doc.adoptedStyleSheets = [
36929
+ ...doc.adoptedStyleSheets,
36930
+ sheet
36931
+ ];
36932
+ } catch {
36933
+ const style = doc.createElement('style');
36934
+ style.textContent = rule;
36935
+ doc.head.appendChild(style);
36936
+ }
36937
+ }
36884
36938
  /**
36885
36939
  * @private
36886
36940
  */ function highlightTextRanges(jodit, rng, restRanges, ci, root) {
@@ -36890,6 +36944,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
36890
36944
  if (checkNativeSelectionMethod(jodit, rng, restRanges)) {
36891
36945
  return;
36892
36946
  }
36947
+ ensureHighlightStyle(jodit.ed, false);
36893
36948
  const span = ci.element('span', {
36894
36949
  [TMP_ATTR]: true
36895
36950
  });
@@ -36949,6 +37004,7 @@ function checkNativeSelectionMethod(jodit, rng, restRanges) {
36949
37004
  range.setEnd(rng.endContainer, rng.endOffset);
36950
37005
  return range;
36951
37006
  });
37007
+ ensureHighlightStyle(jodit.ed, true);
36952
37008
  const searchHighlight = new Highlight(...ranges);
36953
37009
  // @ts-ignore
36954
37010
  CSS.highlights.clear();
@@ -40765,7 +40821,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
40765
40821
  if (!jodit.isEditorMode()) {
40766
40822
  return;
40767
40823
  }
40768
- let child = jodit.editor.firstChild, isChanged = false;
40824
+ let child = jodit.editor.firstChild;
40825
+ let isChanged = false;
40769
40826
  while(child){
40770
40827
  child = checkAloneListLeaf(child, jodit);
40771
40828
  if (this.isSuitableStart(child)) {
@@ -40803,7 +40860,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
40803
40860
  const br = jodit.createInside.element('br');
40804
40861
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.append(box, br);
40805
40862
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.append(jodit.editor, box);
40806
- jodit.s.isFocused() && jodit.s.setCursorBefore(br);
40863
+ if (jodit.s.isFocused() || jodit.e.current === 'backSpaceAfterDelete') {
40864
+ jodit.s.setCursorBefore(br);
40865
+ }
40807
40866
  jodit.e.fire('internalChange');
40808
40867
  }
40809
40868
  constructor(...args){