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/es5/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
  */
@@ -2022,7 +2022,7 @@ __webpack_require__.r(__webpack_exports__);
2022
2022
  * @packageDocumentation
2023
2023
  * @module constants
2024
2024
  */
2025
- var APP_VERSION = "4.11.6";
2025
+ var APP_VERSION = "4.11.7";
2026
2026
  // prettier-ignore
2027
2027
  var ES = "es5";
2028
2028
  var IS_ES_MODERN = false;
@@ -3703,6 +3703,34 @@ function wait(condition) {
3703
3703
  return !(0,jodit_core_helpers_checker_is_void__WEBPACK_IMPORTED_MODULE_13__.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);
3704
3704
  }
3705
3705
  },
3706
+ {
3707
+ key: "first",
3708
+ value: /**
3709
+ * Get first matched node inside root
3710
+ */ function first(root, condition) {
3711
+ var first = root === null || root === void 0 ? void 0 : root.firstChild;
3712
+ if (!first) {
3713
+ return null;
3714
+ }
3715
+ do {
3716
+ if (condition(first)) {
3717
+ return first;
3718
+ }
3719
+ var next = first.firstChild;
3720
+ if (!next) {
3721
+ next = first.nextSibling;
3722
+ }
3723
+ if (!next && first.parentNode !== root) {
3724
+ do {
3725
+ first = first.parentNode;
3726
+ }while (first && !(first === null || first === void 0 ? void 0 : first.nextSibling) && first.parentNode !== root);
3727
+ next = first === null || first === void 0 ? void 0 : first.nextSibling;
3728
+ }
3729
+ first = next;
3730
+ }while (first);
3731
+ return null;
3732
+ }
3733
+ },
3706
3734
  {
3707
3735
  key: "last",
3708
3736
  value: /**
@@ -11546,7 +11574,8 @@ var Selection = /*#__PURE__*/ function() {
11546
11574
  var markAttr = function markAttr(start) {
11547
11575
  return "span[data-".concat(jodit_core_constants__WEBPACK_IMPORTED_MODULE_7__.MARKER_CLASS, "=").concat(start ? 'start' : 'end', "]");
11548
11576
  };
11549
- var start = this.area.querySelector(markAttr(true)), end = this.area.querySelector(markAttr(false));
11577
+ var start = this.area.querySelector(markAttr(true));
11578
+ var end = this.area.querySelector(markAttr(false));
11550
11579
  if (!start) {
11551
11580
  return;
11552
11581
  }
@@ -12201,7 +12230,7 @@ var Selection = /*#__PURE__*/ function() {
12201
12230
  value: function selectRange(range) {
12202
12231
  var focus = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
12203
12232
  var sel = this.sel;
12204
- if (focus && !this.isFocused()) {
12233
+ if (focus && !this.isFocused() && this.j.e.current !== 'focus') {
12205
12234
  this.focus();
12206
12235
  }
12207
12236
  if (sel) {
@@ -30955,6 +30984,7 @@ var backspace = /*#__PURE__*/ function(Plugin) {
30955
30984
  sel.focus();
30956
30985
  }
30957
30986
  if ((0,_cases_check_not_collapsed__WEBPACK_IMPORTED_MODULE_13__.checkNotCollapsed)(jodit)) {
30987
+ jodit.e.fire('backSpaceAfterDelete', backspace);
30958
30988
  return false;
30959
30989
  }
30960
30990
  var range = sel.range;
@@ -35734,13 +35764,21 @@ function focus(editor) {
35734
35764
  }
35735
35765
  var _$focus = function focus() {
35736
35766
  editor.s.focus();
35737
- if (editor.o.cursorAfterAutofocus === 'end') {
35738
- var lastTextNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, function(node) {
35739
- return jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node);
35740
- });
35741
- if (lastTextNode) {
35742
- editor.s.setCursorIn(lastTextNode, false);
35743
- }
35767
+ var textNode = null;
35768
+ switch(editor.o.cursorAfterAutofocus){
35769
+ case 'start':
35770
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.first(editor.editor, function(node) {
35771
+ return jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node);
35772
+ });
35773
+ break;
35774
+ case 'end':
35775
+ textNode = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.last(editor.editor, function(node) {
35776
+ return jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isText(node);
35777
+ });
35778
+ break;
35779
+ }
35780
+ if (textNode) {
35781
+ editor.s.setCursorIn(textNode, editor.o.cursorAfterAutofocus === 'start');
35744
35782
  }
35745
35783
  };
35746
35784
  editor.e.on('afterInit', function() {
@@ -44688,6 +44726,26 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
44688
44726
  /**
44689
44727
  * @private
44690
44728
  */ var TMP_ATTR = 'jd-tmp-selection';
44729
+ var HIGHLIGHT_CSS = 'background-color: var(--jd-color-background-selection); color: var(--jd-color-text-selection);';
44730
+ var injectedDocs = new WeakSet();
44731
+ function ensureHighlightStyle(doc, useHighlightAPI) {
44732
+ if (injectedDocs.has(doc)) {
44733
+ return;
44734
+ }
44735
+ injectedDocs.add(doc);
44736
+ var rule = useHighlightAPI ? "::highlight(jodit-search-result) { ".concat(HIGHLIGHT_CSS, " }") : "[".concat(TMP_ATTR, "] { ").concat(HIGHLIGHT_CSS, " }");
44737
+ try {
44738
+ var sheet = new CSSStyleSheet();
44739
+ sheet.insertRule(rule);
44740
+ doc.adoptedStyleSheets = (0,_swc_helpers_to_consumable_array__WEBPACK_IMPORTED_MODULE_2__._)(doc.adoptedStyleSheets).concat([
44741
+ sheet
44742
+ ]);
44743
+ } catch (unused) {
44744
+ var style = doc.createElement('style');
44745
+ style.textContent = rule;
44746
+ doc.head.appendChild(style);
44747
+ }
44748
+ }
44691
44749
  /**
44692
44750
  * @private
44693
44751
  */ function highlightTextRanges(jodit, rng, restRanges, ci, root) {
@@ -44697,6 +44755,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.find = {
44697
44755
  if (checkNativeSelectionMethod(jodit, rng, restRanges)) {
44698
44756
  return;
44699
44757
  }
44758
+ ensureHighlightStyle(jodit.ed, false);
44700
44759
  var span = ci.element('span', (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)({}, TMP_ATTR, true));
44701
44760
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.markTemporary(span);
44702
44761
  normalizeRanges(rng, restRanges, ci);
@@ -44755,6 +44814,7 @@ function checkNativeSelectionMethod(jodit, rng, restRanges) {
44755
44814
  range.setEnd(rng.endContainer, rng.endOffset);
44756
44815
  return range;
44757
44816
  });
44817
+ ensureHighlightStyle(jodit.ed, true);
44758
44818
  var searchHighlight = (0,_swc_helpers_construct__WEBPACK_IMPORTED_MODULE_0__._)(Highlight, (0,_swc_helpers_to_consumable_array__WEBPACK_IMPORTED_MODULE_2__._)(ranges));
44759
44819
  // @ts-ignore
44760
44820
  CSS.highlights.clear();
@@ -50265,7 +50325,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
50265
50325
  if (!jodit.isEditorMode()) {
50266
50326
  return;
50267
50327
  }
50268
- var child = jodit.editor.firstChild, isChanged = false;
50328
+ var child = jodit.editor.firstChild;
50329
+ var isChanged = false;
50269
50330
  while(child){
50270
50331
  child = checkAloneListLeaf(child, jodit);
50271
50332
  if (this.isSuitableStart(child)) {
@@ -50306,7 +50367,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.wrapNodes = {
50306
50367
  var br = jodit.createInside.element('br');
50307
50368
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.append(box, br);
50308
50369
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.append(jodit.editor, box);
50309
- jodit.s.isFocused() && jodit.s.setCursorBefore(br);
50370
+ if (jodit.s.isFocused() || jodit.e.current === 'backSpaceAfterDelete') {
50371
+ jodit.s.setCursorBefore(br);
50372
+ }
50310
50373
  jodit.e.fire('internalChange');
50311
50374
  }
50312
50375
  }