jodit-pro-react 5.5.61 → 5.5.63

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.
@@ -5168,15 +5168,20 @@ svg.jodit-icon {
5168
5168
  --jd-slot-left-width:auto;
5169
5169
  --jd-slot-right-width:auto;
5170
5170
  }
5171
+ .jodit .jodit-jodit__workplace-slot_above_true,
5171
5172
  .jodit .jodit-jodit__workplace-slot_bottom_true,
5172
5173
  .jodit .jodit-jodit__workplace-slot_top_true {
5173
5174
  flex: 0 0 auto;
5174
5175
  min-width: 0;
5175
5176
  }
5177
+ .jodit .jodit-jodit__workplace-slot_above_true:empty,
5176
5178
  .jodit .jodit-jodit__workplace-slot_bottom_true:empty,
5177
5179
  .jodit .jodit-jodit__workplace-slot_top_true:empty {
5178
5180
  display: none;
5179
5181
  }
5182
+ .jodit .jodit-jodit__workplace-slot_above_true:not(:empty) {
5183
+ border-bottom: 1px solid var(--jd-color-border,transparent);
5184
+ }
5180
5185
  .jodit .jodit-jodit__workplace-slot_top_true {
5181
5186
  height: var(--jd-slot-top-height);
5182
5187
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JoditEditor_default
3
- } from "./chunk-SKAZCX7F.mjs";
3
+ } from "./chunk-G4TUESYO.mjs";
4
4
  export {
5
5
  JoditEditor_default as default
6
6
  };
@@ -193,7 +193,7 @@ var APP_VERSION, ES, IS_ES_MODERN, IS_ES_NEXT, IS_PROD, IS_TEST, FAT_MODE, HOMEP
193
193
  var init_constants = __esm({
194
194
  "node_modules/jodit/esm/core/constants.js"() {
195
195
  "use strict";
196
- APP_VERSION = "4.12.43";
196
+ APP_VERSION = "4.13.3";
197
197
  ES = "es2020";
198
198
  IS_ES_MODERN = true;
199
199
  IS_ES_NEXT = true;
@@ -3679,6 +3679,7 @@ var init_config = __esm({
3679
3679
  this.inline = false;
3680
3680
  this.theme = "default";
3681
3681
  this.saveModeInStorage = false;
3682
+ this.asyncStorage = {};
3682
3683
  this.editorClassName = false;
3683
3684
  this.className = false;
3684
3685
  this.style = false;
@@ -10904,7 +10905,12 @@ var LocalStorageProvider = class {
10904
10905
  }
10905
10906
  delete(key3) {
10906
10907
  try {
10907
- this.storage.removeItem(this.rootKey);
10908
+ const buffer = this.storage.getItem(this.rootKey);
10909
+ if (buffer) {
10910
+ const json = JSON.parse(buffer);
10911
+ delete json[key3];
10912
+ this.storage.setItem(this.rootKey, JSON.stringify(json));
10913
+ }
10908
10914
  } catch (_a2) {
10909
10915
  }
10910
10916
  return this;
@@ -11055,9 +11061,20 @@ var AsyncStorage = class _AsyncStorage {
11055
11061
  }
11056
11062
  });
11057
11063
  }
11058
- static makeStorage(persistentOrStrategy = false, suffix) {
11064
+ static makeStorage(persistentOrStrategy = false, suffix, options2) {
11059
11065
  let provider = void 0;
11060
11066
  let storage = null;
11067
+ const defaultProvider = options2 === null || options2 === void 0 ? void 0 : options2.defaultProvider;
11068
+ if (defaultProvider != null) {
11069
+ if (defaultProvider === "local") {
11070
+ provider = canUsePersistentStorage("localStorage") ? new LocalStorageProvider(StorageKey + (suffix || "")) : new MemoryStorageProvider();
11071
+ } else if (defaultProvider === "memory") {
11072
+ provider = new MemoryStorageProvider();
11073
+ } else {
11074
+ provider = defaultProvider;
11075
+ }
11076
+ return new _AsyncStorage(Promise.resolve(provider), suffix);
11077
+ }
11061
11078
  if (persistentOrStrategy === "localStorage" || persistentOrStrategy === "sessionStorage") {
11062
11079
  if (canUsePersistentStorage(persistentOrStrategy)) {
11063
11080
  provider = new LocalStorageProvider(StorageKey + (suffix || ""), persistentOrStrategy);
@@ -11301,7 +11318,7 @@ var View = View_1 = class View2 extends Component {
11301
11318
  * Container for persistent set/get value
11302
11319
  */
11303
11320
  get asyncStorage() {
11304
- return AsyncStorage.makeStorage(true, this.id);
11321
+ return AsyncStorage.makeStorage(true, this.id, this.o.asyncStorage);
11305
11322
  }
11306
11323
  /**
11307
11324
  * Short alias for `create`
@@ -11577,9 +11594,24 @@ var ViewWithToolbar = class extends View {
11577
11594
  if (!this.o.fullsize && (isString(this.o.toolbar) || Dom.isHTMLElement(this.o.toolbar))) {
11578
11595
  return resolveElement(this.o.toolbar, this.o.shadowRoot || this.od);
11579
11596
  }
11580
- this.o.toolbar && Dom.appendChildFirst(this.container, this.__defaultToolbarContainer);
11597
+ this.o.toolbar && this.__appendToolbarBox();
11581
11598
  return this.__defaultToolbarContainer;
11582
11599
  }
11600
+ /**
11601
+ * Keep the toolbar box as the first child of the container, except that
11602
+ * children flagged with `data-jodit-above-toolbar` (e.g. the `above`
11603
+ * workplace slot used for presence bars and banners) stay above it.
11604
+ */
11605
+ __appendToolbarBox() {
11606
+ const box = this.__defaultToolbarContainer;
11607
+ let anchor = this.container.firstElementChild;
11608
+ while (anchor && anchor !== box && anchor.hasAttribute("data-jodit-above-toolbar")) {
11609
+ anchor = anchor.nextElementSibling;
11610
+ }
11611
+ if (anchor !== box) {
11612
+ this.container.insertBefore(box, anchor);
11613
+ }
11614
+ }
11583
11615
  /**
11584
11616
  * Change panel container
11585
11617
  */
@@ -18793,6 +18825,130 @@ var Selection = class {
18793
18825
  }
18794
18826
  return "";
18795
18827
  }
18828
+ /**
18829
+ * Splits the boundaries of the current selection and wraps every
18830
+ * contiguous run of selected inline content (grouped by block) into a
18831
+ * `<font>` element, returning those wrappers in document order.
18832
+ *
18833
+ * This is a pure-DOM replacement for the old
18834
+ * `nativeExecCommand('fontsize', false, '7')` trick which relied on the
18835
+ * browser to split the selection into `<font size="7">` fragments.
18836
+ */
18837
+ __wrapSelectionFragments() {
18838
+ const range = this.range;
18839
+ this.__splitSelectionBoundaries(range);
18840
+ let root = range.commonAncestorContainer;
18841
+ if (Dom.isText(root)) {
18842
+ root = root.parentNode;
18843
+ }
18844
+ if (!root) {
18845
+ return [];
18846
+ }
18847
+ return this.__wrapSelectionRuns(this.__collectContainedNodes(root, range));
18848
+ }
18849
+ /**
18850
+ * Splits the text nodes at both ends of the range so that its boundaries
18851
+ * always fall between nodes. Afterwards every node inside the range is
18852
+ * fully (not partially) selected.
18853
+ */
18854
+ __splitSelectionBoundaries(range) {
18855
+ var _a2, _b, _c, _d, _e2, _f, _g, _h;
18856
+ let { startContainer, endContainer } = range;
18857
+ let { startOffset, endOffset } = range;
18858
+ if (Dom.isText(endContainer) && endOffset > 0 && endOffset < ((_b = (_a2 = endContainer.nodeValue) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b !== void 0 ? _b : 0)) {
18859
+ endContainer.splitText(endOffset);
18860
+ endOffset = (_d = (_c = endContainer.nodeValue) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : endOffset;
18861
+ }
18862
+ if (Dom.isText(startContainer) && startOffset > 0 && startOffset < ((_f = (_e2 = startContainer.nodeValue) === null || _e2 === void 0 ? void 0 : _e2.length) !== null && _f !== void 0 ? _f : 0)) {
18863
+ const middle = startContainer.splitText(startOffset);
18864
+ if (startContainer === endContainer) {
18865
+ endContainer = middle;
18866
+ endOffset = (_h = (_g = middle.nodeValue) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
18867
+ }
18868
+ startContainer = middle;
18869
+ startOffset = 0;
18870
+ }
18871
+ range.setStart(startContainer, startOffset);
18872
+ range.setEnd(endContainer, endOffset);
18873
+ this.__normalizeRangeBoundary(range, true);
18874
+ this.__normalizeRangeBoundary(range, false);
18875
+ }
18876
+ __normalizeRangeBoundary(range, atStart) {
18877
+ var _a2, _b;
18878
+ const container = atStart ? range.startContainer : range.endContainer;
18879
+ if (!Dom.isText(container)) {
18880
+ return;
18881
+ }
18882
+ const offset2 = atStart ? range.startOffset : range.endOffset;
18883
+ const length = (_b = (_a2 = container.nodeValue) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b !== void 0 ? _b : 0;
18884
+ if (offset2 === 0) {
18885
+ atStart ? range.setStartBefore(container) : range.setEndBefore(container);
18886
+ } else if (offset2 >= length) {
18887
+ atStart ? range.setStartAfter(container) : range.setEndAfter(container);
18888
+ }
18889
+ }
18890
+ /**
18891
+ * Collects the highest-level nodes that are completely inside the range,
18892
+ * descending into nodes that are only partially selected.
18893
+ */
18894
+ __collectContainedNodes(root, range) {
18895
+ const result = [];
18896
+ toArray(root.childNodes).forEach((child) => {
18897
+ if (this.__isFullyContained(range, child)) {
18898
+ result.push(child);
18899
+ } else if (child.childNodes.length && range.intersectsNode(child)) {
18900
+ result.push(...this.__collectContainedNodes(child, range));
18901
+ }
18902
+ });
18903
+ return result;
18904
+ }
18905
+ __isFullyContained(range, node) {
18906
+ const nodeRange = this.createRange();
18907
+ nodeRange.selectNode(node);
18908
+ return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
18909
+ }
18910
+ /**
18911
+ * Wraps every contiguous run of selected inline siblings into a `<font>`
18912
+ * element. Block-level nodes are never wrapped themselves - their inline
18913
+ * content is wrapped instead, keeping every `<font>` inside a single block.
18914
+ */
18915
+ __wrapSelectionRuns(nodes) {
18916
+ const fonts = [];
18917
+ let run = [];
18918
+ const flush = () => {
18919
+ if (run.length) {
18920
+ fonts.push(this.__wrapRunInFont(run));
18921
+ run = [];
18922
+ }
18923
+ };
18924
+ nodes.forEach((node) => {
18925
+ if (Dom.isElement(node) && this.__isOrContainsBlock(node)) {
18926
+ flush();
18927
+ fonts.push(...this.__wrapSelectionRuns(toArray(node.childNodes)));
18928
+ } else {
18929
+ if (run.length && run[run.length - 1].parentNode !== node.parentNode) {
18930
+ flush();
18931
+ }
18932
+ run.push(node);
18933
+ }
18934
+ });
18935
+ flush();
18936
+ return fonts;
18937
+ }
18938
+ __isOrContainsBlock(node) {
18939
+ if (Dom.isBlock(node)) {
18940
+ return true;
18941
+ }
18942
+ return toArray(node.childNodes).some((child) => this.__isOrContainsBlock(child));
18943
+ }
18944
+ __wrapRunInFont(run) {
18945
+ var _a2;
18946
+ const font2 = this.j.createInside.element("font");
18947
+ const [first] = run;
18948
+ (_a2 = first.parentNode) === null || _a2 === void 0 ? void 0 : _a2.insertBefore(font2, first);
18949
+ run.forEach((node) => font2.appendChild(node));
18950
+ return font2;
18951
+ }
18796
18952
  /**
18797
18953
  * Wrap all selected fragments inside Tag or apply some callback
18798
18954
  */
@@ -18807,19 +18963,7 @@ var Selection = class {
18807
18963
  Dom.unwrap(font2);
18808
18964
  return;
18809
18965
  }
18810
- $$("*[style*=font-size]", this.area).forEach((elm) => {
18811
- attr(elm, "data-font-size", elm.style.fontSize.toString());
18812
- elm.style.removeProperty("font-size");
18813
- });
18814
- this.j.nativeExecCommand("fontsize", false, "7");
18815
- $$("*[data-font-size]", this.area).forEach((elm) => {
18816
- const fontSize = attr(elm, "data-font-size");
18817
- if (fontSize) {
18818
- elm.style.fontSize = fontSize;
18819
- attr(elm, "data-font-size", null);
18820
- }
18821
- });
18822
- const elms = $$('font[size="7"]', this.area);
18966
+ const elms = this.__wrapSelectionFragments();
18823
18967
  for (const font2 of elms) {
18824
18968
  const { firstChild, lastChild } = font2;
18825
18969
  if (firstChild && firstChild === lastChild && isMarker(firstChild)) {
@@ -33356,6 +33500,9 @@ var Jodit2 = Jodit_1 = class Jodit3 extends ViewWithToolbar {
33356
33500
  element.style.display = "none";
33357
33501
  }
33358
33502
  const SLOT = "workplace-slot";
33503
+ const aboveSlot = this.c.div(this.getFullElName(SLOT, "above"), NOEDIT);
33504
+ aboveSlot.setAttribute("data-jodit-above-toolbar", "");
33505
+ Dom.appendChildFirst(container, aboveSlot);
33359
33506
  const topSlot = this.c.div(this.getFullElName(SLOT, "top"), NOEDIT);
33360
33507
  container.appendChild(topSlot);
33361
33508
  const centerSlot = this.c.div(this.getFullElName(SLOT, "center"), NOEDIT);
@@ -33388,6 +33535,7 @@ var Jodit2 = Jodit_1 = class Jodit3 extends ViewWithToolbar {
33388
33535
  container,
33389
33536
  workplace,
33390
33537
  slots: {
33538
+ above: aboveSlot,
33391
33539
  top: topSlot,
33392
33540
  bottom: bottomPanel,
33393
33541
  center: centerSlot,
@@ -5168,15 +5168,20 @@ svg.jodit-icon {
5168
5168
  --jd-slot-left-width:auto;
5169
5169
  --jd-slot-right-width:auto;
5170
5170
  }
5171
+ .jodit .jodit-jodit__workplace-slot_above_true,
5171
5172
  .jodit .jodit-jodit__workplace-slot_bottom_true,
5172
5173
  .jodit .jodit-jodit__workplace-slot_top_true {
5173
5174
  flex: 0 0 auto;
5174
5175
  min-width: 0;
5175
5176
  }
5177
+ .jodit .jodit-jodit__workplace-slot_above_true:empty,
5176
5178
  .jodit .jodit-jodit__workplace-slot_bottom_true:empty,
5177
5179
  .jodit .jodit-jodit__workplace-slot_top_true:empty {
5178
5180
  display: none;
5179
5181
  }
5182
+ .jodit .jodit-jodit__workplace-slot_above_true:not(:empty) {
5183
+ border-bottom: 1px solid var(--jd-color-border,transparent);
5184
+ }
5180
5185
  .jodit .jodit-jodit__workplace-slot_top_true {
5181
5186
  height: var(--jd-slot-top-height);
5182
5187
  }
@@ -2,7 +2,7 @@ import {
2
2
  Config,
3
3
  JoditEditor_default,
4
4
  n
5
- } from "./chunk-SKAZCX7F.mjs";
5
+ } from "./chunk-G4TUESYO.mjs";
6
6
 
7
7
  // src/index.ts
8
8
  var index_default = JoditEditor_default;