jodit 4.12.44 → 4.13.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 (69) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/es2015/jodit.css +6 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +14 -14
  5. package/es2015/jodit.js +156 -17
  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 +3 -3
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +5 -5
  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 +6 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +4 -4
  23. package/es2021/jodit.js +147 -17
  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 +6 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +5 -5
  35. package/es2021.en/jodit.js +147 -17
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +5 -5
  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 +7 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +192 -17
  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/selection/selection.d.ts +31 -0
  61. package/esm/core/selection/selection.js +143 -14
  62. package/esm/core/view/view-with-toolbar.d.ts +6 -0
  63. package/esm/core/view/view-with-toolbar.js +18 -2
  64. package/esm/jodit.js +7 -0
  65. package/esm/types/jodit.d.ts +2 -0
  66. package/package.json +1 -1
  67. package/types/core/selection/selection.d.ts +31 -0
  68. package/types/core/view/view-with-toolbar.d.ts +6 -0
  69. package/types/types/jodit.d.ts +2 -0
package/es2015/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.12.44
4
+ * Version: v4.13.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1849,7 +1849,7 @@ __webpack_require__.r(__webpack_exports__);
1849
1849
  * ```
1850
1850
  * @packageDocumentation
1851
1851
  * @module constants
1852
- */ const APP_VERSION = "4.12.44";
1852
+ */ const APP_VERSION = "4.13.3";
1853
1853
  // prettier-ignore
1854
1854
  const ES = "es2015";
1855
1855
  const IS_ES_MODERN = true;
@@ -11370,6 +11370,137 @@ class Selection {
11370
11370
  }
11371
11371
  return '';
11372
11372
  }
11373
+ /**
11374
+ * Splits the boundaries of the current selection and wraps every
11375
+ * contiguous run of selected inline content (grouped by block) into a
11376
+ * `<font>` element, returning those wrappers in document order.
11377
+ *
11378
+ * This is a pure-DOM replacement for the old
11379
+ * `nativeExecCommand('fontsize', false, '7')` trick which relied on the
11380
+ * browser to split the selection into `<font size="7">` fragments.
11381
+ */ __wrapSelectionFragments() {
11382
+ const range = this.range;
11383
+ this.__splitSelectionBoundaries(range);
11384
+ let root = range.commonAncestorContainer;
11385
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(root)) {
11386
+ root = root.parentNode;
11387
+ }
11388
+ if (!root) {
11389
+ return [];
11390
+ }
11391
+ return this.__wrapSelectionRuns(this.__collectContainedNodes(root, range));
11392
+ }
11393
+ /**
11394
+ * Splits the text nodes at both ends of the range so that its boundaries
11395
+ * always fall between nodes. Afterwards every node inside the range is
11396
+ * fully (not partially) selected.
11397
+ */ __splitSelectionBoundaries(range) {
11398
+ var _ref, _ref1;
11399
+ var _endContainer_nodeValue, _startContainer_nodeValue;
11400
+ let { startContainer, endContainer } = range;
11401
+ let { startOffset, endOffset } = range;
11402
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(endContainer) && endOffset > 0 && endOffset < ((_ref = (_endContainer_nodeValue = endContainer.nodeValue) === null || _endContainer_nodeValue === void 0 ? void 0 : _endContainer_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0)) {
11403
+ var _ref2;
11404
+ var _endContainer_nodeValue1;
11405
+ endContainer.splitText(endOffset);
11406
+ endOffset = (_ref2 = (_endContainer_nodeValue1 = endContainer.nodeValue) === null || _endContainer_nodeValue1 === void 0 ? void 0 : _endContainer_nodeValue1.length) !== null && _ref2 !== void 0 ? _ref2 : endOffset;
11407
+ }
11408
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(startContainer) && startOffset > 0 && startOffset < ((_ref1 = (_startContainer_nodeValue = startContainer.nodeValue) === null || _startContainer_nodeValue === void 0 ? void 0 : _startContainer_nodeValue.length) !== null && _ref1 !== void 0 ? _ref1 : 0)) {
11409
+ const middle = startContainer.splitText(startOffset);
11410
+ // Selection located inside a single text node - the tail we just
11411
+ // cut off is the actual selected fragment.
11412
+ if (startContainer === endContainer) {
11413
+ var _ref3;
11414
+ var _middle_nodeValue;
11415
+ endContainer = middle;
11416
+ endOffset = (_ref3 = (_middle_nodeValue = middle.nodeValue) === null || _middle_nodeValue === void 0 ? void 0 : _middle_nodeValue.length) !== null && _ref3 !== void 0 ? _ref3 : 0;
11417
+ }
11418
+ startContainer = middle;
11419
+ startOffset = 0;
11420
+ }
11421
+ range.setStart(startContainer, startOffset);
11422
+ range.setEnd(endContainer, endOffset);
11423
+ // Normalize text-edge boundaries (e.g. `(text, 0)` or `(text, length)`)
11424
+ // to the element level so that containment checks based on
11425
+ // `selectNode()` treat a fully selected text node as contained.
11426
+ this.__normalizeRangeBoundary(range, true);
11427
+ this.__normalizeRangeBoundary(range, false);
11428
+ }
11429
+ __normalizeRangeBoundary(range, atStart) {
11430
+ var _ref;
11431
+ var _container_nodeValue;
11432
+ const container = atStart ? range.startContainer : range.endContainer;
11433
+ if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isText(container)) {
11434
+ return;
11435
+ }
11436
+ const offset = atStart ? range.startOffset : range.endOffset;
11437
+ const length = (_ref = (_container_nodeValue = container.nodeValue) === null || _container_nodeValue === void 0 ? void 0 : _container_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0;
11438
+ if (offset === 0) {
11439
+ atStart ? range.setStartBefore(container) : range.setEndBefore(container);
11440
+ } else if (offset >= length) {
11441
+ atStart ? range.setStartAfter(container) : range.setEndAfter(container);
11442
+ }
11443
+ }
11444
+ /**
11445
+ * Collects the highest-level nodes that are completely inside the range,
11446
+ * descending into nodes that are only partially selected.
11447
+ */ __collectContainedNodes(root, range) {
11448
+ const result = [];
11449
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(root.childNodes).forEach((child)=>{
11450
+ if (this.__isFullyContained(range, child)) {
11451
+ result.push(child);
11452
+ } else if (child.childNodes.length && range.intersectsNode(child)) {
11453
+ result.push(...this.__collectContainedNodes(child, range));
11454
+ }
11455
+ });
11456
+ return result;
11457
+ }
11458
+ __isFullyContained(range, node) {
11459
+ const nodeRange = this.createRange();
11460
+ nodeRange.selectNode(node);
11461
+ return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
11462
+ }
11463
+ /**
11464
+ * Wraps every contiguous run of selected inline siblings into a `<font>`
11465
+ * element. Block-level nodes are never wrapped themselves - their inline
11466
+ * content is wrapped instead, keeping every `<font>` inside a single block.
11467
+ */ __wrapSelectionRuns(nodes) {
11468
+ const fonts = [];
11469
+ let run = [];
11470
+ const flush = ()=>{
11471
+ if (run.length) {
11472
+ fonts.push(this.__wrapRunInFont(run));
11473
+ run = [];
11474
+ }
11475
+ };
11476
+ nodes.forEach((node)=>{
11477
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isElement(node) && this.__isOrContainsBlock(node)) {
11478
+ flush();
11479
+ fonts.push(...this.__wrapSelectionRuns((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes)));
11480
+ } else {
11481
+ if (run.length && run[run.length - 1].parentNode !== node.parentNode) {
11482
+ flush();
11483
+ }
11484
+ run.push(node);
11485
+ }
11486
+ });
11487
+ flush();
11488
+ return fonts;
11489
+ }
11490
+ __isOrContainsBlock(node) {
11491
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isBlock(node)) {
11492
+ return true;
11493
+ }
11494
+ return (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.toArray)(node.childNodes).some((child)=>this.__isOrContainsBlock(child));
11495
+ }
11496
+ __wrapRunInFont(run) {
11497
+ var _first_parentNode;
11498
+ const font = this.j.createInside.element('font');
11499
+ const [first] = run;
11500
+ (_first_parentNode = first.parentNode) === null || _first_parentNode === void 0 ? void 0 : _first_parentNode.insertBefore(font, first);
11501
+ run.forEach((node)=>font.appendChild(node));
11502
+ return font;
11503
+ }
11373
11504
  /**
11374
11505
  * Wrap all selected fragments inside Tag or apply some callback
11375
11506
  */ *wrapInTagGen(fakes) {
@@ -11383,20 +11514,7 @@ class Selection {
11383
11514
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.unwrap(font);
11384
11515
  return;
11385
11516
  }
11386
- // fix issue https://github.com/xdan/jodit/issues/65
11387
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[style*=font-size]', this.area).forEach((elm)=>{
11388
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', elm.style.fontSize.toString());
11389
- elm.style.removeProperty('font-size');
11390
- });
11391
- this.j.nativeExecCommand('fontsize', false, '7');
11392
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('*[data-font-size]', this.area).forEach((elm)=>{
11393
- const fontSize = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size');
11394
- if (fontSize) {
11395
- elm.style.fontSize = fontSize;
11396
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.attr)(elm, 'data-font-size', null);
11397
- }
11398
- });
11399
- const elms = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.$$)('font[size="7"]', this.area);
11517
+ const elms = this.__wrapSelectionFragments();
11400
11518
  for (const font of elms){
11401
11519
  const { firstChild, lastChild } = font;
11402
11520
  if (firstChild && firstChild === lastChild && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isMarker)(firstChild)) {
@@ -16650,9 +16768,23 @@ class ViewWithToolbar extends jodit_core_view_view__WEBPACK_IMPORTED_MODULE_11__
16650
16768
  if (!this.o.fullsize && ((0,jodit_core_helpers_checker_is_string__WEBPACK_IMPORTED_MODULE_7__.isString)(this.o.toolbar) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isHTMLElement(this.o.toolbar))) {
16651
16769
  return (0,jodit_core_helpers_utils_selector__WEBPACK_IMPORTED_MODULE_8__.resolveElement)(this.o.toolbar, this.o.shadowRoot || this.od);
16652
16770
  }
16653
- this.o.toolbar && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.appendChildFirst(this.container, this.__defaultToolbarContainer);
16771
+ this.o.toolbar && this.__appendToolbarBox();
16654
16772
  return this.__defaultToolbarContainer;
16655
16773
  }
16774
+ /**
16775
+ * Keep the toolbar box as the first child of the container, except that
16776
+ * children flagged with `data-jodit-above-toolbar` (e.g. the `above`
16777
+ * workplace slot used for presence bars and banners) stay above it.
16778
+ */ __appendToolbarBox() {
16779
+ const box = this.__defaultToolbarContainer;
16780
+ let anchor = this.container.firstElementChild;
16781
+ while(anchor && anchor !== box && anchor.hasAttribute('data-jodit-above-toolbar')){
16782
+ anchor = anchor.nextElementSibling;
16783
+ }
16784
+ if (anchor !== box) {
16785
+ this.container.insertBefore(box, anchor);
16786
+ }
16787
+ }
16656
16788
  /**
16657
16789
  * Change panel container
16658
16790
  */ setPanel(element) {
@@ -17934,6 +18066,12 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_10__.ViewWithToolbar
17934
18066
  element.style.display = 'none';
17935
18067
  }
17936
18068
  const SLOT = 'workplace-slot';
18069
+ // A slot that always stays ABOVE the toolbar (presence bars, banners…).
18070
+ // The `data-jodit-above-toolbar` attribute tells ViewWithToolbar to keep
18071
+ // the toolbar box below it when (re)attaching the toolbar container.
18072
+ const aboveSlot = this.c.div(this.getFullElName(SLOT, 'above'), NOEDIT);
18073
+ aboveSlot.setAttribute('data-jodit-above-toolbar', '');
18074
+ jodit_modules__WEBPACK_IMPORTED_MODULE_10__.Dom.appendChildFirst(container, aboveSlot);
17937
18075
  const topSlot = this.c.div(this.getFullElName(SLOT, 'top'), NOEDIT);
17938
18076
  container.appendChild(topSlot);
17939
18077
  const centerSlot = this.c.div(this.getFullElName(SLOT, 'center'), NOEDIT);
@@ -17966,6 +18104,7 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_10__.ViewWithToolbar
17966
18104
  container,
17967
18105
  workplace,
17968
18106
  slots: {
18107
+ above: aboveSlot,
17969
18108
  top: topSlot,
17970
18109
  bottom: bottomPanel,
17971
18110
  center: centerSlot,