@solibo/solibo-ui 2.2.9 → 2.2.11

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.
@@ -1,51 +1,146 @@
1
- import '../../assets/index43.css';var Ot = Object.defineProperty;
2
- var Pt = (s, r, e) => r in s ? Ot(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
3
- var K = (s, r, e) => Pt(s, typeof r != "symbol" ? r + "" : r, e);
4
- import { jsx as n, jsxs as B, Fragment as _t } from "react/jsx-runtime";
5
- import { $generateHtmlFromNodes as $t, $generateNodesFromDOM as Rt } from "@lexical/html";
6
- import { TOGGLE_LINK_COMMAND as ft, $isLinkNode as ot, AutoLinkNode as Ut, LinkNode as zt } from "@lexical/link";
7
- import { $isListNode as pt, $isListItemNode as bt, REMOVE_LIST_COMMAND as Ht, INSERT_UNORDERED_LIST_COMMAND as Bt, ListNode as Ft, ListItemNode as Wt } from "@lexical/list";
8
- import { AutoFocusPlugin as Kt } from "@lexical/react/LexicalAutoFocusPlugin";
9
- import { AutoLinkPlugin as jt } from "@lexical/react/LexicalAutoLinkPlugin";
10
- import { useLexicalComposerContext as At } from "@lexical/react/LexicalComposerContext";
11
- import { ContentEditable as Gt } from "@lexical/react/LexicalContentEditable";
12
- import { LexicalErrorBoundary as Zt } from "@lexical/react/LexicalErrorBoundary";
13
- import { LexicalExtensionComposer as qt } from "@lexical/react/LexicalExtensionComposer";
14
- import { HistoryPlugin as Yt } from "@lexical/react/LexicalHistoryPlugin";
15
- import { LinkPlugin as Vt } from "@lexical/react/LexicalLinkPlugin";
1
+ import '../../assets/index43.css';var Rt = Object.defineProperty;
2
+ var Ot = (s, r, e) => r in s ? Rt(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
3
+ var j = (s, r, e) => Ot(s, typeof r != "symbol" ? r + "" : r, e);
4
+ import { jsxs as O, jsx as o, Fragment as ct } from "react/jsx-runtime";
5
+ import { $generateHtmlFromNodes as $t, $generateNodesFromDOM as Ut } from "@lexical/html";
6
+ import { TOGGLE_LINK_COMMAND as ft, $isLinkNode as rt, AutoLinkNode as zt, LinkNode as Bt } from "@lexical/link";
7
+ import { $isListNode as pt, $isListItemNode as _t, REMOVE_LIST_COMMAND as Ht, INSERT_UNORDERED_LIST_COMMAND as Ft, ListNode as Wt, ListItemNode as Kt } from "@lexical/list";
8
+ import { AutoFocusPlugin as jt } from "@lexical/react/LexicalAutoFocusPlugin";
9
+ import { AutoLinkPlugin as Gt } from "@lexical/react/LexicalAutoLinkPlugin";
10
+ import { useLexicalComposerContext as wt } from "@lexical/react/LexicalComposerContext";
11
+ import { ContentEditable as Zt } from "@lexical/react/LexicalContentEditable";
12
+ import { LexicalErrorBoundary as qt } from "@lexical/react/LexicalErrorBoundary";
13
+ import { LexicalExtensionComposer as Vt } from "@lexical/react/LexicalExtensionComposer";
14
+ import { HistoryPlugin as Xt } from "@lexical/react/LexicalHistoryPlugin";
15
+ import { LinkPlugin as Yt } from "@lexical/react/LexicalLinkPlugin";
16
16
  import { ListPlugin as Jt } from "@lexical/react/LexicalListPlugin";
17
- import { OnChangePlugin as Xt } from "@lexical/react/LexicalOnChangePlugin";
18
- import { RichTextPlugin as Qt } from "@lexical/react/LexicalRichTextPlugin";
19
- import lt from "classix";
20
- import { DecoratorNode as te, $applyNodeReplacement as ee, createCommand as re, PASTE_COMMAND as ie, $insertNodes as Mt, COMMAND_PRIORITY_HIGH as ne, $isRangeSelection as vt, $setSelection as xt, $getSelection as Dt, $isTextNode as st, $createTextNode as oe, $getNodeByKey as It, $isParagraphNode as se, $isNodeSelection as le, COMMAND_PRIORITY_LOW as Et, SELECTION_CHANGE_COMMAND as ae, FORMAT_TEXT_COMMAND as kt, defineExtension as ce, $getRoot as ue } from "lexical";
21
- import { useEffect as j, useRef as O, useState as f, useCallback as b, useId as de } from "react";
22
- import wt from "sanitize-html";
23
- import { Button as L } from "../button/index.js";
24
- import { File as me } from "../file/index.js";
25
- import { mergeRegister as he } from "@lexical/utils";
26
- import { Icon as y } from "../icon/index.js";
27
- import { I as yt } from "../../index-Dd20d_9U.js";
28
- import { Toolbar as _e } from "../toolbar/index.js";
29
- const Tt = re();
30
- class at extends te {
31
- constructor(e, l, _, h, g, o, d) {
32
- super(g);
33
- K(this, "__src");
34
- K(this, "__alt");
35
- K(this, "__width");
36
- K(this, "__height");
37
- K(this, "__soliboDocumentId");
38
- K(this, "__soliboDocumentSlot");
39
- this.__src = e, this.__alt = l, this.__width = _, this.__height = h, this.__soliboDocumentId = o, this.__soliboDocumentSlot = d;
17
+ import { OnChangePlugin as Qt } from "@lexical/react/LexicalOnChangePlugin";
18
+ import { RichTextPlugin as te } from "@lexical/react/LexicalRichTextPlugin";
19
+ import nt from "classix";
20
+ import { $getNodeByKey as ut, $isParagraphNode as xt, DecoratorNode as ee, $applyNodeReplacement as re, createCommand as Et, COMMAND_PRIORITY_HIGH as Mt, PASTE_COMMAND as ie, $insertNodes as Ct, $isRangeSelection as bt, $setSelection as Pt, $getSelection as kt, $isTextNode as it, $createTextNode as ne, $isNodeSelection as oe, COMMAND_PRIORITY_LOW as yt, SELECTION_CHANGE_COMMAND as ae, FORMAT_TEXT_COMMAND as Dt, defineExtension as se, $getRoot as le } from "lexical";
21
+ import { useRef as x, useState as k, useEffect as F, useCallback as C, useId as ce } from "react";
22
+ import vt from "sanitize-html";
23
+ import { Button as N } from "../button/index.js";
24
+ import { File as ue } from "../file/index.js";
25
+ import { mergeRegister as de } from "@lexical/utils";
26
+ import { Icon as P } from "../icon/index.js";
27
+ import { I as Nt } from "../../index-Dd20d_9U.js";
28
+ import { Toolbar as me } from "../toolbar/index.js";
29
+ const he = "_field_1trki_3", ge = "_editor_1trki_8", fe = "_submit_1trki_26", pe = "_resizable_1trki_56", _e = "_resized_1trki_60", be = "_invalid_1trki_86", ke = "_error_1trki_90", De = "_dragging_1trki_96", ve = "_content_1trki_100", Ie = "_files_1trki_116", we = "_placeholder_1trki_125", Ce = "_fill_1trki_133", Le = "_meta_1trki_161", Ae = "_active_1trki_170", Me = "_bold_1trki_240", ye = "_italic_1trki_244", Ne = "_underline_1trki_248", xe = "_link_1trki_252", Ee = "_list_1trki_258", Pe = "_paragraph_1trki_259", h = {
30
+ field: he,
31
+ editor: ge,
32
+ submit: fe,
33
+ "image-resize-handle": "_image-resize-handle_1trki_50",
34
+ resizable: pe,
35
+ resized: _e,
36
+ "resize-handle": "_resize-handle_1trki_64",
37
+ invalid: be,
38
+ error: ke,
39
+ dragging: De,
40
+ content: ve,
41
+ "has-files": "_has-files_1trki_112",
42
+ files: Ie,
43
+ placeholder: we,
44
+ fill: Ce,
45
+ "fill-editor": "_fill-editor_1trki_141",
46
+ meta: Le,
47
+ active: Ae,
48
+ "inline-image": "_inline-image_1trki_182",
49
+ bold: Me,
50
+ italic: ye,
51
+ underline: Ne,
52
+ link: xe,
53
+ list: Ee,
54
+ paragraph: Pe
55
+ };
56
+ function Se({
57
+ alt: s = "",
58
+ editor: r,
59
+ height: e,
60
+ nodeKey: c,
61
+ soliboDocumentId: g,
62
+ soliboDocumentSlot: m,
63
+ src: p,
64
+ width: n
65
+ }) {
66
+ const u = x(null), f = x(null), [$, A] = k(), L = () => {
67
+ const i = r.getRootElement();
68
+ if (!i) return 1 / 0;
69
+ const l = getComputedStyle(i);
70
+ return Math.max(1, i.clientWidth - (parseFloat(l.paddingLeft) || 0) - (parseFloat(l.paddingRight) || 0));
71
+ }, S = (i, l = L()) => Math.round(Math.min(l, Math.max(Math.min(32, l), i))), w = (i) => {
72
+ r.update(() => {
73
+ const l = ut(c);
74
+ mt(l) && l.setWidth(i);
75
+ }), A(void 0);
76
+ };
77
+ return /* @__PURE__ */ O("span", { className: h["inline-image"], contentEditable: !1, tabIndex: m ? 0 : void 0, onKeyDown: (i) => {
78
+ !m || i.target !== i.currentTarget || !["Backspace", "Delete"].includes(i.key) || (i.preventDefault(), i.stopPropagation(), r.update(() => {
79
+ const l = ut(c);
80
+ if (!mt(l)) return;
81
+ const b = l.getParent();
82
+ xt(b) && b.getChildrenSize() === 1 ? b.remove() : l.remove(), r.dispatchCommand(St, m);
83
+ }), r.focus());
84
+ }, "data-component": "editorimage", children: [
85
+ /* @__PURE__ */ o("img", { alt: s, "data-solibo-document-id": g, "data-solibo-document-slot": m, draggable: !1, height: $ === void 0 ? e : void 0, ref: u, src: p, width: $ ?? n, onClick: (i) => {
86
+ var l;
87
+ i.preventDefault(), m && ((l = i.currentTarget.parentElement) == null || l.focus()), r.dispatchCommand(Tt, {
88
+ key: c,
89
+ soliboDocumentSlot: m,
90
+ src: p,
91
+ width: n
92
+ });
93
+ } }),
94
+ /* @__PURE__ */ o("button", { type: "button", "aria-label": `Resize image${s ? `: ${s}` : ""}`, title: "Drag to resize; use arrow keys to adjust width", className: h["image-resize-handle"], tabIndex: 0, onClick: (i) => {
95
+ i.preventDefault(), i.stopPropagation();
96
+ }, onKeyDown: (i) => {
97
+ var b;
98
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(i.key)) return;
99
+ i.preventDefault(), i.stopPropagation();
100
+ const l = ((b = u.current) == null ? void 0 : b.getBoundingClientRect().width) ?? n ?? 32;
101
+ w(S(l + (["ArrowRight", "ArrowUp"].includes(i.key) ? 10 : -10)));
102
+ }, onPointerDown: (i) => {
103
+ i.button !== 0 || !u.current || (i.preventDefault(), i.stopPropagation(), i.currentTarget.focus({
104
+ preventScroll: !0
105
+ }), i.currentTarget.setPointerCapture(i.pointerId), f.current = {
106
+ pointerId: i.pointerId,
107
+ x: i.clientX,
108
+ width: u.current.getBoundingClientRect().width,
109
+ maximum: L()
110
+ });
111
+ }, onPointerMove: (i) => {
112
+ const l = f.current;
113
+ !l || l.pointerId !== i.pointerId || A(S(l.width + i.clientX - l.x, l.maximum));
114
+ }, onPointerUp: (i) => {
115
+ const l = f.current;
116
+ !l || l.pointerId !== i.pointerId || (f.current = null, w(S(l.width + i.clientX - l.x, l.maximum)), i.currentTarget.releasePointerCapture(i.pointerId));
117
+ }, onPointerCancel: () => {
118
+ f.current = null, A(void 0);
119
+ }, onLostPointerCapture: () => {
120
+ f.current = null, A(void 0);
121
+ } })
122
+ ] });
123
+ }
124
+ const St = Et(), Tt = Et();
125
+ class ot extends ee {
126
+ constructor(e, c, g, m, p, n, u) {
127
+ super(p);
128
+ j(this, "__src");
129
+ j(this, "__alt");
130
+ j(this, "__width");
131
+ j(this, "__height");
132
+ j(this, "__soliboDocumentId");
133
+ j(this, "__soliboDocumentSlot");
134
+ this.__src = e, this.__alt = c, this.__width = g, this.__height = m, this.__soliboDocumentId = n, this.__soliboDocumentSlot = u;
40
135
  }
41
136
  static getType() {
42
137
  return "image";
43
138
  }
44
139
  static clone(e) {
45
- return new at(e.__src, e.__alt, e.__width, e.__height, e.__key, e.__soliboDocumentId, e.__soliboDocumentSlot);
140
+ return new ot(e.__src, e.__alt, e.__width, e.__height, e.__key, e.__soliboDocumentId, e.__soliboDocumentSlot);
46
141
  }
47
142
  static importJSON(e) {
48
- return gt({
143
+ return dt({
49
144
  alt: e.alt,
50
145
  height: e.height,
51
146
  soliboDocumentId: e.soliboDocumentId,
@@ -74,21 +169,21 @@ class at extends te {
74
169
  return {
75
170
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
76
171
  img: (e) => ({
77
- conversion: (l) => {
78
- if (!(l instanceof HTMLImageElement))
172
+ conversion: (c) => {
173
+ if (!(c instanceof HTMLImageElement))
79
174
  return null;
80
- const _ = l.getAttribute("src") ?? "";
81
- if (!_)
175
+ const g = c.getAttribute("src") ?? "";
176
+ if (!g)
82
177
  return null;
83
- const h = l.getAttribute("width"), g = l.getAttribute("height");
178
+ const m = c.getAttribute("width"), p = c.getAttribute("height");
84
179
  return {
85
- node: gt({
86
- alt: l.getAttribute("alt") ?? "",
87
- height: g ? Number(g) : void 0,
88
- soliboDocumentId: l.getAttribute("data-solibo-document-id") ?? void 0,
89
- soliboDocumentSlot: l.getAttribute("data-solibo-document-slot") ?? void 0,
90
- src: _,
91
- width: h ? Number(h) : void 0
180
+ node: dt({
181
+ alt: c.getAttribute("alt") ?? "",
182
+ height: p ? Number(p) : void 0,
183
+ soliboDocumentId: c.getAttribute("data-solibo-document-id") ?? void 0,
184
+ soliboDocumentSlot: c.getAttribute("data-solibo-document-slot") ?? void 0,
185
+ src: g,
186
+ width: m ? Number(m) : void 0
92
187
  })
93
188
  };
94
189
  },
@@ -115,58 +210,52 @@ class at extends te {
115
210
  return this.__src;
116
211
  }
117
212
  setSrc(e) {
118
- const l = this.getWritable();
119
- return l.__src = e, l;
213
+ const c = this.getWritable();
214
+ return c.__src = e, c;
120
215
  }
121
216
  setWidth(e) {
122
- const l = this.getWritable();
123
- return l.__width = e, l.__height = void 0, l;
217
+ const c = this.getWritable();
218
+ return c.__width = e, c.__height = void 0, c;
124
219
  }
125
220
  decorate(e) {
126
- return /* @__PURE__ */ n("img", { alt: this.__alt, height: this.__height, "data-solibo-document-id": this.__soliboDocumentId, "data-solibo-document-slot": this.__soliboDocumentSlot, onClick: (l) => {
127
- l.preventDefault(), e.dispatchCommand(Tt, {
128
- key: this.getKey(),
129
- soliboDocumentSlot: this.__soliboDocumentSlot,
130
- src: this.__src,
131
- width: this.__width
132
- });
133
- }, src: this.__src, width: this.__width });
221
+ return /* @__PURE__ */ o(Se, { alt: this.__alt, editor: e, height: this.__height, nodeKey: this.getKey(), soliboDocumentId: this.__soliboDocumentId, soliboDocumentSlot: this.__soliboDocumentSlot, src: this.__src, width: this.__width });
134
222
  }
135
223
  }
136
- function gt({
224
+ function dt({
137
225
  alt: s = "",
138
226
  height: r,
139
227
  soliboDocumentId: e,
140
- soliboDocumentSlot: l,
141
- src: _,
142
- width: h
228
+ soliboDocumentSlot: c,
229
+ src: g,
230
+ width: m
143
231
  }) {
144
- return ee(new at(_, s, h, r, void 0, e, l));
232
+ return re(new ot(g, s, m, r, void 0, e, c));
145
233
  }
146
- function Lt(s) {
147
- return s instanceof at;
234
+ function mt(s) {
235
+ return s instanceof ot;
148
236
  }
149
- const ge = ({
150
- createImages: s
237
+ const Te = ({
238
+ createImages: s,
239
+ onRemove: r
151
240
  }) => {
152
- const [r] = At();
153
- return j(() => r.registerCommand(ie, (e) => {
154
- var g;
155
- if (!("clipboardData" in e)) return !1;
156
- const l = e, _ = Array.from(((g = l.clipboardData) == null ? void 0 : g.items) ?? []).flatMap((o) => {
157
- if (o.kind !== "file" || !o.type.startsWith("image/")) return [];
158
- const d = o.getAsFile();
159
- return d ? [d] : [];
241
+ const [e] = wt();
242
+ return F(() => e.registerCommand(St, (c) => (r(c), !0), Mt), [e, r]), F(() => e.registerCommand(ie, (c) => {
243
+ var n;
244
+ if (!("clipboardData" in c)) return !1;
245
+ const g = c, m = Array.from(((n = g.clipboardData) == null ? void 0 : n.items) ?? []).flatMap((u) => {
246
+ if (u.kind !== "file" || !u.type.startsWith("image/")) return [];
247
+ const f = u.getAsFile();
248
+ return f ? [f] : [];
160
249
  });
161
- if (_.length === 0) return !1;
162
- l.preventDefault();
163
- const h = s(_);
164
- return r.update(() => {
165
- Mt(h.map((o) => gt(o)));
250
+ if (m.length === 0) return !1;
251
+ g.preventDefault();
252
+ const p = s(m);
253
+ return e.update(() => {
254
+ Ct(p.map((u) => dt(u)));
166
255
  }), !0;
167
- }, ne), [s, r]), null;
168
- }, fe = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/, pe = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/, be = [(s) => {
169
- const r = fe.exec(s);
256
+ }, Mt), [s, e]), null;
257
+ }, Re = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/, Oe = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/, $e = [(s) => {
258
+ const r = Re.exec(s);
170
259
  return r != null && r.length ? {
171
260
  index: r.index,
172
261
  length: r[0].length,
@@ -174,7 +263,7 @@ const ge = ({
174
263
  url: `mailto:${r[0]}`
175
264
  } : null;
176
265
  }, (s) => {
177
- const r = pe.exec(s);
266
+ const r = Oe.exec(s);
178
267
  return r != null && r.length ? {
179
268
  index: r.index,
180
269
  length: r[0].length,
@@ -182,7 +271,7 @@ const ge = ({
182
271
  url: r[0].startsWith("http") ? r[0] : `https://${r[0]}`
183
272
  } : null;
184
273
  }];
185
- function Ct(s) {
274
+ function It(s) {
186
275
  try {
187
276
  const r = new URL(s);
188
277
  return r.protocol === "http:" || r.protocol === "https:";
@@ -190,442 +279,395 @@ function Ct(s) {
190
279
  return !1;
191
280
  }
192
281
  }
193
- const ve = "_field_1clme_3", De = "_editor_1clme_8", Ie = "_submit_1clme_26", ke = "_resizable_1clme_56", we = "_resized_1clme_60", Le = "_invalid_1clme_86", Ce = "_error_1clme_90", Ae = "_dragging_1clme_96", Me = "_content_1clme_100", Se = "_files_1clme_116", Ne = "_placeholder_1clme_125", Ee = "_fill_1clme_133", ye = "_meta_1clme_161", xe = "_active_1clme_170", Te = "_bold_1clme_202", Oe = "_italic_1clme_206", Pe = "_underline_1clme_210", $e = "_link_1clme_214", Re = "_list_1clme_220", Ue = "_paragraph_1clme_221", m = {
194
- field: ve,
195
- editor: De,
196
- submit: Ie,
197
- resizable: ke,
198
- resized: we,
199
- "resize-handle": "_resize-handle_1clme_64",
200
- invalid: Le,
201
- error: Ce,
202
- dragging: Ae,
203
- content: Me,
204
- "has-files": "_has-files_1clme_112",
205
- files: Se,
206
- placeholder: Ne,
207
- fill: Ee,
208
- "fill-editor": "_fill-editor_1clme_141",
209
- meta: ye,
210
- active: xe,
211
- "image-sizes": "_image-sizes_1clme_182",
212
- bold: Te,
213
- italic: Oe,
214
- underline: Pe,
215
- link: $e,
216
- list: Re,
217
- paragraph: Ue
218
- };
219
- function ze({
282
+ function Ue({
220
283
  editableRef: s
221
284
  }) {
222
- const r = O(null), [e, l] = f(0), [_, h] = f(0);
223
- j(() => {
224
- const o = s.current;
225
- if (!o) return;
226
- const d = () => {
227
- l(Math.round(o.getBoundingClientRect().height)), h(Math.round(parseFloat(getComputedStyle(o).minHeight) || 0));
285
+ const r = x(null), [e, c] = k(0), [g, m] = k(0);
286
+ F(() => {
287
+ const n = s.current;
288
+ if (!n) return;
289
+ const u = () => {
290
+ c(Math.round(n.getBoundingClientRect().height)), m(Math.round(parseFloat(getComputedStyle(n).minHeight) || 0));
228
291
  };
229
- if (d(), typeof ResizeObserver > "u") return;
230
- const C = new ResizeObserver(d);
231
- return C.observe(o), () => C.disconnect();
292
+ if (u(), typeof ResizeObserver > "u") return;
293
+ const f = new ResizeObserver(u);
294
+ return f.observe(n), () => f.disconnect();
232
295
  }, [s]);
233
- const g = (o) => {
234
- const d = s.current;
235
- if (!d) return;
236
- const C = parseFloat(getComputedStyle(d).minHeight) || 0;
237
- d.style.height = `${Math.max(C, o)}px`;
296
+ const p = (n) => {
297
+ const u = s.current;
298
+ if (!u) return;
299
+ const f = parseFloat(getComputedStyle(u).minHeight) || 0;
300
+ u.style.height = `${Math.max(f, n)}px`;
238
301
  };
239
- return /* @__PURE__ */ n("div", { "aria-label": "Resize editor", "aria-orientation": "horizontal", "aria-valuemin": _, "aria-valuenow": e, "aria-valuetext": `${e} pixels`, className: m["resize-handle"], role: "separator", tabIndex: 0, onDoubleClick: () => {
240
- var o;
241
- return (o = s.current) == null ? void 0 : o.style.removeProperty("height");
242
- }, onKeyDown: (o) => {
243
- const d = s.current;
244
- d && (o.key === "Home" ? (o.preventDefault(), d.style.removeProperty("height")) : (o.key === "ArrowUp" || o.key === "ArrowDown") && (o.preventDefault(), g(d.getBoundingClientRect().height + (o.key === "ArrowUp" ? 20 : -20))));
245
- }, onPointerDown: (o) => {
246
- const d = s.current;
247
- o.button !== 0 || !d || (o.preventDefault(), o.currentTarget.focus({
302
+ return /* @__PURE__ */ o("div", { "aria-label": "Resize editor", "aria-orientation": "horizontal", "aria-valuemin": g, "aria-valuenow": e, "aria-valuetext": `${e} pixels`, className: h["resize-handle"], role: "separator", tabIndex: 0, onDoubleClick: () => {
303
+ var n;
304
+ return (n = s.current) == null ? void 0 : n.style.removeProperty("height");
305
+ }, onKeyDown: (n) => {
306
+ const u = s.current;
307
+ u && (n.key === "Home" ? (n.preventDefault(), u.style.removeProperty("height")) : (n.key === "ArrowUp" || n.key === "ArrowDown") && (n.preventDefault(), p(u.getBoundingClientRect().height + (n.key === "ArrowUp" ? 20 : -20))));
308
+ }, onPointerDown: (n) => {
309
+ const u = s.current;
310
+ n.button !== 0 || !u || (n.preventDefault(), n.currentTarget.focus({
248
311
  preventScroll: !0
249
- }), o.currentTarget.setPointerCapture(o.pointerId), r.current = {
250
- pointerId: o.pointerId,
251
- y: o.clientY,
252
- height: d.getBoundingClientRect().height
312
+ }), n.currentTarget.setPointerCapture(n.pointerId), r.current = {
313
+ pointerId: n.pointerId,
314
+ y: n.clientY,
315
+ height: u.getBoundingClientRect().height
253
316
  });
254
- }, onPointerMove: (o) => {
255
- !r.current || r.current.pointerId !== o.pointerId || g(r.current.height + r.current.y - o.clientY);
256
- }, onPointerUp: (o) => {
257
- !r.current || r.current.pointerId !== o.pointerId || (r.current = null, o.currentTarget.releasePointerCapture(o.pointerId));
317
+ }, onPointerMove: (n) => {
318
+ !r.current || r.current.pointerId !== n.pointerId || p(r.current.height + r.current.y - n.clientY);
319
+ }, onPointerUp: (n) => {
320
+ !r.current || r.current.pointerId !== n.pointerId || (r.current = null, n.currentTarget.releasePointerCapture(n.pointerId));
258
321
  }, onLostPointerCapture: () => {
259
322
  r.current = null;
260
323
  }, onPointerCancel: () => {
261
324
  r.current = null;
262
325
  }, "data-component": "editorresizehandle" });
263
326
  }
264
- const He = [{
265
- label: "Small",
266
- width: 320
267
- }, {
268
- label: "Medium",
269
- width: 640
270
- }, {
271
- label: "Large",
272
- width: 960
273
- }, {
274
- label: "Original",
275
- width: void 0
276
- }], Be = ({
327
+ const ze = ({
277
328
  onFilesSelected: s,
278
329
  onInlineImageRemove: r
279
330
  }) => {
280
- const [e] = At(), [l, _] = f(!1), [h, g] = f(!1), [o, d] = f(!1), [C, Q] = f(!1), [F, N] = f(!1), [tt, A] = f(!1), [x, P] = f(""), [p, G] = f(null), [Z, $] = f(null), [ct, q] = f(void 0), [R, D] = f(""), ut = Ct(R.trim()), et = O(null), dt = O(null), U = O(null), T = O(null), Y = O(!1), rt = (t) => t.preventDefault(), V = b((t) => {
281
- T.current = vt(t) ? t.clone() : null;
282
- }, []), I = b((t) => {
331
+ const [e] = wt(), [c, g] = k(!1), [m, p] = k(!1), [n, u] = k(!1), [f, $] = k(!1), [A, L] = k(!1), [S, w] = k(!1), [i, l] = k(""), [b, G] = k(null), [Z, U] = k(null), [z, M] = k(""), Q = It(z.trim()), q = x(null), at = x(null), tt = x(null), T = x(null), E = x(!1), st = (t) => t.preventDefault(), V = C((t) => {
332
+ T.current = bt(t) ? t.clone() : null;
333
+ }, []), X = C((t) => {
283
334
  e.update(() => {
284
- T.current && xt(T.current), t();
335
+ T.current && Pt(T.current), t();
285
336
  }), T.current = null;
286
- }, [e]), k = (t) => {
287
- Y.current = !0, t.preventDefault();
288
- }, z = () => {
289
- if (Y.current) {
290
- Y.current = !1;
337
+ }, [e]), lt = (t) => {
338
+ E.current = !0, t.preventDefault();
339
+ }, R = () => {
340
+ if (E.current) {
341
+ E.current = !1;
291
342
  return;
292
343
  }
293
- nt();
294
- }, v = b(() => {
295
- g(!1), P(""), G(null), $(null), q(void 0);
296
- }, []), M = b(() => {
297
- N(!1), D("");
298
- }, []), mt = b((t) => {
299
- g(!0), P((t == null ? void 0 : t.src) ?? ""), G((t == null ? void 0 : t.key) ?? null), $((t == null ? void 0 : t.soliboDocumentSlot) ?? null), q(t == null ? void 0 : t.width), M(), t != null && t.soliboDocumentSlot || setTimeout(() => {
300
- var c;
301
- return (c = dt.current) == null ? void 0 : c.focus();
344
+ Y();
345
+ }, _ = C(() => {
346
+ p(!1), l(""), G(null), U(null);
347
+ }, []), v = C(() => {
348
+ L(!1), M("");
349
+ }, []), W = C((t) => {
350
+ p(!0), l((t == null ? void 0 : t.src) ?? ""), G((t == null ? void 0 : t.key) ?? null), U((t == null ? void 0 : t.soliboDocumentSlot) ?? null), v(), t != null && t.soliboDocumentSlot || setTimeout(() => {
351
+ var a;
352
+ return (a = at.current) == null ? void 0 : a.focus();
302
353
  }, 0);
303
- }, [M]), ht = b((t) => {
354
+ }, [v]), K = C((t) => {
304
355
  e.getEditorState().read(() => {
305
- V(Dt());
306
- }), N(!0), D(t), v(), setTimeout(() => {
307
- var c;
308
- return (c = U.current) == null ? void 0 : c.focus();
356
+ V(kt());
357
+ }), L(!0), M(t), _(), setTimeout(() => {
358
+ var a;
359
+ return (a = tt.current) == null ? void 0 : a.focus();
309
360
  }, 0);
310
- }, [v, e, V]), it = b(() => {
311
- const t = R.trim();
312
- Ct(t) && (I(() => {
361
+ }, [_, e, V]), et = C(() => {
362
+ const t = z.trim();
363
+ It(t) && (X(() => {
313
364
  e.dispatchCommand(ft, {
314
365
  url: t,
315
366
  target: "_blank"
316
367
  });
317
- const c = Dt();
318
- if (!vt(c)) return;
319
- const E = c.getNodes().at(-1) ?? null, W = (E == null ? void 0 : E.getParent()) ?? null, w = ot(E) ? E : ot(W) ? W : null;
320
- if (w) {
321
- const H = w.getLastChild();
322
- if (st(H)) {
323
- const St = H.getTextContent(), Nt = St.replace(/\s+$/, "");
324
- Nt !== St && H.setTextContent(Nt);
368
+ const a = kt();
369
+ if (!bt(a)) return;
370
+ const d = a.getNodes().at(-1) ?? null, D = (d == null ? void 0 : d.getParent()) ?? null, I = rt(d) ? d : rt(D) ? D : null;
371
+ if (I) {
372
+ const H = I.getLastChild();
373
+ if (it(H)) {
374
+ const Lt = H.getTextContent(), At = Lt.replace(/\s+$/, "");
375
+ At !== Lt && H.setTextContent(At);
325
376
  }
326
- const X = w.getNextSibling();
327
- if (st(X) && /^\s/.test(X.getTextContent())) {
328
- X.select(1, 1);
377
+ const J = I.getNextSibling();
378
+ if (it(J) && /^\s/.test(J.getTextContent())) {
379
+ J.select(1, 1);
329
380
  return;
330
381
  }
331
- const S = oe(" ");
332
- w.insertAfter(S), S.selectEnd();
382
+ const y = ne(" ");
383
+ I.insertAfter(y), y.selectEnd();
333
384
  }
334
- }), M());
335
- }, [M, e, R, I]), nt = b(() => {
336
- const t = x.trim();
385
+ }), v());
386
+ }, [v, e, z, X]), Y = C(() => {
387
+ const t = i.trim();
337
388
  if (!t) {
338
- v();
389
+ _();
339
390
  return;
340
391
  }
341
392
  e.update(() => {
342
- if (p) {
343
- const c = It(p);
344
- Lt(c) && c.setSrc(t);
393
+ if (b) {
394
+ const a = ut(b);
395
+ mt(a) && a.setSrc(t);
345
396
  return;
346
397
  }
347
- Mt([gt({
398
+ Ct([dt({
348
399
  src: t
349
400
  })]);
350
- }), v();
351
- }, [v, e, p, x]), J = b(() => {
352
- if (!p) {
353
- v();
401
+ }), _();
402
+ }, [_, e, b, i]), ht = C(() => {
403
+ if (!b) {
404
+ _();
354
405
  return;
355
406
  }
356
407
  e.update(() => {
357
- const t = It(p);
358
- if (Lt(t)) {
359
- const c = t.getParent();
360
- se(c) && c.getChildrenSize() === 1 ? c.remove() : t.remove(), Z && (r == null || r(Z));
408
+ const t = ut(b);
409
+ if (mt(t)) {
410
+ const a = t.getParent();
411
+ xt(a) && a.getChildrenSize() === 1 ? a.remove() : t.remove(), Z && (r == null || r(Z));
361
412
  }
362
- }), v();
363
- }, [v, e, p, Z, r]), i = b((t) => {
364
- p && (e.update(() => {
365
- const c = It(p);
366
- Lt(c) && c.setWidth(t);
367
- }), q(t));
368
- }, [e, p]), a = b(() => {
369
- I(() => {
413
+ }), _();
414
+ }, [_, e, b, Z, r]), gt = C(() => {
415
+ X(() => {
370
416
  e.dispatchCommand(ft, null);
371
- }), M();
372
- }, [M, e, I]), u = b(() => {
373
- const t = Dt();
374
- if (!vt(t)) {
375
- if (le(t)) {
376
- const W = t.getNodes(), w = W[0] ?? null, H = (w == null ? void 0 : w.getParent()) ?? null;
377
- _(W.some((S) => st(S) && S.hasFormat("bold"))), d(W.some((S) => st(S) && S.hasFormat("italic"))), Q(W.some((S) => st(S) && S.hasFormat("underline"))), A(pt(H) || bt(H) || pt(w) || bt(w));
378
- const X = ot(w) ? w : ot(H) ? H : null;
379
- if (X) {
380
- N(!0), D(X.getURL());
417
+ }), v();
418
+ }, [v, e, X]), B = C(() => {
419
+ const t = kt();
420
+ if (!bt(t)) {
421
+ if (oe(t)) {
422
+ const D = t.getNodes(), I = D[0] ?? null, H = (I == null ? void 0 : I.getParent()) ?? null;
423
+ g(D.some((y) => it(y) && y.hasFormat("bold"))), u(D.some((y) => it(y) && y.hasFormat("italic"))), $(D.some((y) => it(y) && y.hasFormat("underline"))), w(pt(H) || _t(H) || pt(I) || _t(I));
424
+ const J = rt(I) ? I : rt(H) ? H : null;
425
+ if (J) {
426
+ L(!0), M(J.getURL());
381
427
  return;
382
428
  }
383
- N(!1), D(""), T.current = null;
429
+ L(!1), M(""), T.current = null;
384
430
  return;
385
431
  }
386
- _(!1), d(!1), Q(!1), A(!1), N(!1), D(""), T.current = null;
432
+ g(!1), u(!1), $(!1), w(!1), L(!1), M(""), T.current = null;
387
433
  return;
388
434
  }
389
- const [c] = t.getNodes(), E = (c == null ? void 0 : c.getParent()) ?? null;
390
- if (_(t.hasFormat("bold")), d(t.hasFormat("italic")), Q(t.hasFormat("underline")), A(pt(E) || bt(E)), ot(E)) {
391
- N(!0), D(E.getURL()), V(t);
435
+ const [a] = t.getNodes(), d = (a == null ? void 0 : a.getParent()) ?? null;
436
+ if (g(t.hasFormat("bold")), u(t.hasFormat("italic")), $(t.hasFormat("underline")), w(pt(d) || _t(d)), rt(d)) {
437
+ L(!0), M(d.getURL()), V(t);
392
438
  return;
393
439
  }
394
- N(!1), D(""), T.current = null;
440
+ L(!1), M(""), T.current = null;
395
441
  }, [V]);
396
- return j(() => he(e.registerUpdateListener(({
442
+ return F(() => de(e.registerUpdateListener(({
397
443
  editorState: t
398
444
  }) => {
399
445
  t.read(() => {
400
- u();
446
+ B();
401
447
  });
402
- }), e.registerCommand(Tt, (t) => (mt(t), !0), Et), e.registerCommand(ae, () => (e.getEditorState().read(() => {
403
- u();
404
- }), !1), Et)), [e, mt, u]), /* @__PURE__ */ B(_e, { variant: "editor", "data-component": "editortoolbar", children: [
405
- /* @__PURE__ */ n(L, { "aria-label": "Bold", "data-active": l, onClick: () => {
406
- e.dispatchCommand(kt, "bold");
407
- }, title: "Bold", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "TextB" }) }),
408
- /* @__PURE__ */ n(L, { "aria-label": "Italic", "data-active": o, onClick: () => {
409
- e.dispatchCommand(kt, "italic");
410
- }, title: "Italic", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "TextItalic" }) }),
411
- /* @__PURE__ */ n(L, { "aria-label": "Underline", "data-active": C, onClick: () => {
412
- e.dispatchCommand(kt, "underline");
413
- }, title: "Underline", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "TextUnderline" }) }),
414
- /* @__PURE__ */ n(L, { "aria-label": "List", "data-active": tt, onClick: () => {
415
- tt ? e.dispatchCommand(Ht, void 0) : e.dispatchCommand(Bt, void 0);
416
- }, title: "List", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "ListBullets" }) }),
417
- /* @__PURE__ */ n(L, { "aria-label": "Link", "data-active": F, onClick: () => {
418
- F ? ht(R) : (e.dispatchCommand(ft, {
448
+ }), e.registerCommand(Tt, (t) => (t.soliboDocumentSlot ? (_(), v()) : W(t), !0), yt), e.registerCommand(ae, () => (e.getEditorState().read(() => {
449
+ B();
450
+ }), !1), yt)), [_, v, e, W, B]), /* @__PURE__ */ O(me, { variant: "editor", "data-component": "editortoolbar", children: [
451
+ /* @__PURE__ */ o(N, { "aria-label": "Bold", "data-active": c, onClick: () => {
452
+ e.dispatchCommand(Dt, "bold");
453
+ }, title: "Bold", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextB" }) }),
454
+ /* @__PURE__ */ o(N, { "aria-label": "Italic", "data-active": n, onClick: () => {
455
+ e.dispatchCommand(Dt, "italic");
456
+ }, title: "Italic", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextItalic" }) }),
457
+ /* @__PURE__ */ o(N, { "aria-label": "Underline", "data-active": f, onClick: () => {
458
+ e.dispatchCommand(Dt, "underline");
459
+ }, title: "Underline", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "TextUnderline" }) }),
460
+ /* @__PURE__ */ o(N, { "aria-label": "List", "data-active": S, onClick: () => {
461
+ S ? e.dispatchCommand(Ht, void 0) : e.dispatchCommand(Ft, void 0);
462
+ }, title: "List", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "ListBullets" }) }),
463
+ /* @__PURE__ */ o(N, { "aria-label": "Link", "data-active": A, onClick: () => {
464
+ A ? K(z) : (e.dispatchCommand(ft, {
419
465
  url: "https://"
420
- }), ht("https://"));
421
- }, title: "Link", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Link" }) }),
422
- s && /* @__PURE__ */ B(_t, { children: [
423
- /* @__PURE__ */ n("input", { hidden: !0, multiple: !0, onChange: (t) => {
466
+ }), K("https://"));
467
+ }, title: "Link", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Link" }) }),
468
+ s && /* @__PURE__ */ O(ct, { children: [
469
+ /* @__PURE__ */ o("input", { hidden: !0, multiple: !0, onChange: (t) => {
424
470
  t.target.files && s(t.target.files), t.target.value = "";
425
- }, ref: et, type: "file" }),
426
- /* @__PURE__ */ n(L, { "aria-label": "Upload files", onClick: () => {
471
+ }, ref: q, type: "file" }),
472
+ /* @__PURE__ */ o(N, { "aria-label": "Upload files", onClick: () => {
427
473
  var t;
428
- return (t = et.current) == null ? void 0 : t.click();
429
- }, title: "Upload files", variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Paperclip" }) })
474
+ return (t = q.current) == null ? void 0 : t.click();
475
+ }, title: "Upload files", variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Paperclip" }) })
430
476
  ] }),
431
- /* @__PURE__ */ B("div", { className: lt(m.meta, F || h ? m.active : ""), children: [
432
- F && /* @__PURE__ */ B(_t, { children: [
433
- /* @__PURE__ */ n(yt, { "aria-invalid": !ut, onBlur: () => it(), onChange: (t) => D(t.target.value), onKeyDown: (t) => {
434
- t.key === "Enter" && (t.preventDefault(), it());
435
- }, ref: U, value: R }),
436
- /* @__PURE__ */ n(L, { "aria-label": "Apply link", disabled: !ut, onClick: () => {
437
- it();
438
- }, onMouseDown: rt, variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Check" }) }),
439
- /* @__PURE__ */ n(L, { "aria-label": "Remove link", onClick: () => a(), onMouseDown: rt, variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Trash", variant: "danger" }) })
477
+ /* @__PURE__ */ O("div", { className: nt(h.meta, A || m ? h.active : ""), children: [
478
+ A && /* @__PURE__ */ O(ct, { children: [
479
+ /* @__PURE__ */ o(Nt, { "aria-invalid": !Q, onBlur: () => et(), onChange: (t) => M(t.target.value), onKeyDown: (t) => {
480
+ t.key === "Enter" && (t.preventDefault(), et());
481
+ }, ref: tt, value: z }),
482
+ /* @__PURE__ */ o(N, { "aria-label": "Apply link", disabled: !Q, onClick: () => {
483
+ et();
484
+ }, onMouseDown: st, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Check" }) }),
485
+ /* @__PURE__ */ o(N, { "aria-label": "Remove link", onClick: () => gt(), onMouseDown: st, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Trash", variant: "danger" }) })
440
486
  ] }),
441
- h && /* @__PURE__ */ B(_t, { children: [
442
- !Z && /* @__PURE__ */ B(_t, { children: [
443
- /* @__PURE__ */ n(yt, { className: lt(m.active), onBlur: z, onChange: (t) => P(t.target.value), onKeyDown: (t) => {
444
- t.key === "Enter" && (t.preventDefault(), Y.current = !0, nt());
445
- }, ref: dt, value: x }),
446
- /* @__PURE__ */ n(L, { "aria-label": "Apply image", onClick: () => nt(), onMouseDown: k, variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Check" }) })
487
+ m && /* @__PURE__ */ O(ct, { children: [
488
+ !Z && /* @__PURE__ */ O(ct, { children: [
489
+ /* @__PURE__ */ o(Nt, { className: nt(h.active), onBlur: R, onChange: (t) => l(t.target.value), onKeyDown: (t) => {
490
+ t.key === "Enter" && (t.preventDefault(), E.current = !0, Y());
491
+ }, ref: at, value: i }),
492
+ /* @__PURE__ */ o(N, { "aria-label": "Apply image", onClick: () => Y(), onMouseDown: lt, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Check" }) })
447
493
  ] }),
448
- /* @__PURE__ */ n("div", { className: m["image-sizes"], children: He.map(({
449
- label: t,
450
- width: c
451
- }) => /* @__PURE__ */ n(L, { "aria-label": `${t} image`, "data-active": ct === c, onClick: () => i(c), onMouseDown: rt, variant: "tertiary", children: t }, t)) }),
452
- /* @__PURE__ */ n(L, { "aria-label": "Remove image", onClick: () => J(), onMouseDown: k, variant: "tertiary", children: /* @__PURE__ */ n(y, { name: "Trash", variant: "danger" }) })
494
+ /* @__PURE__ */ o(N, { "aria-label": "Remove image", onClick: () => ht(), onMouseDown: lt, variant: "tertiary", children: /* @__PURE__ */ o(P, { name: "Trash", variant: "danger" }) })
453
495
  ] })
454
496
  ] })
455
497
  ] });
456
- }, Fe = ce({
498
+ }, Be = se({
457
499
  name: "solibo-editor",
458
500
  namespace: "Editor",
459
- nodes: [Ut, zt, Ft, Wt, at],
501
+ nodes: [zt, Bt, Wt, Kt, ot],
460
502
  onError(s) {
461
503
  throw s;
462
504
  },
463
505
  theme: {
464
- link: m.link,
506
+ link: h.link,
465
507
  list: {
466
- ol: m.list,
467
- ul: m.list
508
+ ol: h.list,
509
+ ul: h.list
468
510
  },
469
- paragraph: m.paragraph,
511
+ paragraph: h.paragraph,
470
512
  text: {
471
- bold: m.bold,
472
- italic: m.italic,
473
- underline: m.underline
513
+ bold: h.bold,
514
+ italic: h.italic,
515
+ underline: h.underline
474
516
  }
475
517
  }
476
518
  });
477
- function We({
519
+ function He({
478
520
  autofocus: s,
479
521
  content: r = "",
480
522
  lastEmittedContentRef: e
481
523
  }) {
482
- const [l] = At();
483
- return j(() => {
484
- e.current !== r && l.update(() => {
485
- const h = new DOMParser().parseFromString(r, "text/html"), g = Rt(l, h), o = ue();
486
- o.clear().select(), Mt(g), s ? o.selectEnd() : xt(null);
524
+ const [c] = wt();
525
+ return F(() => {
526
+ e.current !== r && c.update(() => {
527
+ const m = new DOMParser().parseFromString(r, "text/html"), p = Ut(c, m), n = le();
528
+ n.clear().select(), Ct(p), s ? n.selectEnd() : Pt(null);
487
529
  });
488
- }, [s, r, l, e]), null;
530
+ }, [s, r, c, e]), null;
489
531
  }
490
- const fr = ({
532
+ const gr = ({
491
533
  autofocus: s = !1,
492
534
  autolink: r = !1,
493
535
  content: e,
494
- disabled: l = !1,
495
- errorMessage: _,
496
- fill: h = !1,
497
- files: g,
498
- inline: o = !1,
499
- inlineImages: d,
500
- invalid: C = !1,
501
- isSubmitting: Q = !1,
502
- maxRows: F = 12,
503
- minRows: N = 1,
504
- onChange: tt,
505
- onFilesChange: A,
506
- onInlineImagesChange: x,
507
- onSubmit: P,
508
- onUpload: p,
536
+ disabled: c = !1,
537
+ errorMessage: g,
538
+ fill: m = !1,
539
+ files: p,
540
+ inline: n = !1,
541
+ inlineImages: u,
542
+ invalid: f = !1,
543
+ isSubmitting: $ = !1,
544
+ maxRows: A = 12,
545
+ minRows: L = 1,
546
+ onChange: S,
547
+ onFilesChange: w,
548
+ onInlineImagesChange: i,
549
+ onSubmit: l,
550
+ onUpload: b,
509
551
  placeholder: G,
510
552
  required: Z = !1,
511
- resizable: $ = !1,
512
- submitLabel: ct = "Submit"
553
+ resizable: U = !1,
554
+ submitLabel: z = "Submit"
513
555
  }) => {
514
- const q = de(), R = O(void 0), D = O(null), [ut, et] = f(!1), [dt, U] = f(!1), [T, Y] = f([]), [rt, V] = f([]), I = O(/* @__PURE__ */ new Map()), k = g ?? T, z = d ?? rt;
515
- j(() => {
516
- const i = D.current;
517
- if (!i) return;
518
- if (!$ || h) {
519
- i.style.removeProperty("height"), et(!1);
556
+ const M = ce(), Q = x(void 0), q = x(null), [at, tt] = k(!1), [T, E] = k(!1), [st, V] = k([]), [X, lt] = k([]), R = x(/* @__PURE__ */ new Map()), _ = p ?? st, v = u ?? X;
557
+ F(() => {
558
+ const t = q.current;
559
+ if (!t) return;
560
+ if (!U || m) {
561
+ t.style.removeProperty("height"), tt(!1);
520
562
  return;
521
563
  }
522
- const a = () => et(i.style.height !== ""), u = new MutationObserver(a);
523
- return u.observe(i, {
564
+ const a = () => tt(t.style.height !== ""), d = new MutationObserver(a);
565
+ return d.observe(t, {
524
566
  attributes: !0,
525
567
  attributeFilter: ["style"]
526
- }), a(), () => u.disconnect();
527
- }, [h, $]);
528
- const v = (i) => {
529
- g === void 0 && Y(i), A == null || A(i);
530
- }, M = b((i) => {
531
- d === void 0 && V(i), x == null || x(i);
532
- }, [d, x]), mt = b((i) => {
533
- const a = i.map((u) => {
534
- const t = `pasted-${crypto.randomUUID()}`, c = URL.createObjectURL(u);
535
- return I.current.set(t, c), {
568
+ }), a(), () => d.disconnect();
569
+ }, [m, U]);
570
+ const W = (t) => {
571
+ p === void 0 && V(t), w == null || w(t);
572
+ }, K = C((t) => {
573
+ u === void 0 && lt(t), i == null || i(t);
574
+ }, [u, i]), et = C((t) => {
575
+ const a = t.map((d) => {
576
+ const D = `pasted-${crypto.randomUUID()}`, I = URL.createObjectURL(d);
577
+ return R.current.set(D, I), {
536
578
  image: {
537
- alt: u.name,
538
- soliboDocumentSlot: t,
539
- src: c
579
+ alt: d.name,
580
+ soliboDocumentSlot: D,
581
+ src: I
540
582
  },
541
583
  pending: {
542
- file: u,
543
- slot: t
584
+ file: d,
585
+ slot: D
544
586
  }
545
587
  };
546
588
  });
547
- return M([...z, ...a.map(({
548
- pending: u
549
- }) => u)]), a.map(({
550
- image: u
551
- }) => u);
552
- }, [z, M]), ht = b((i) => {
553
- M(z.filter((u) => u.slot !== i));
554
- const a = I.current.get(i);
555
- a && URL.revokeObjectURL(a), I.current.delete(i);
556
- }, [z, M]);
557
- j(() => () => {
558
- I.current.forEach((i) => URL.revokeObjectURL(i)), I.current.clear();
559
- }, []), j(() => {
560
- const i = new Set(z.map((a) => a.slot));
561
- I.current.forEach((a, u) => {
562
- i.has(u) || (URL.revokeObjectURL(a), I.current.delete(u));
589
+ return K([...v, ...a.map(({
590
+ pending: d
591
+ }) => d)]), a.map(({
592
+ image: d
593
+ }) => d);
594
+ }, [v, K]), Y = C((t) => {
595
+ K(v.filter((d) => d.slot !== t));
596
+ const a = R.current.get(t);
597
+ a && URL.revokeObjectURL(a), R.current.delete(t);
598
+ }, [v, K]);
599
+ F(() => () => {
600
+ R.current.forEach((t) => URL.revokeObjectURL(t)), R.current.clear();
601
+ }, []), F(() => {
602
+ const t = new Set(v.map((a) => a.slot));
603
+ R.current.forEach((a, d) => {
604
+ t.has(d) || (URL.revokeObjectURL(a), R.current.delete(d));
563
605
  });
564
- }, [z]);
565
- const it = (i) => {
606
+ }, [v]);
607
+ const ht = (t) => {
566
608
  if (typeof DataTransfer < "u") {
567
609
  const a = new DataTransfer();
568
- return i.forEach((u) => a.items.add(u)), a.files;
610
+ return t.forEach((d) => a.items.add(d)), a.files;
569
611
  }
570
- return Object.assign([...i], {
571
- item: (a) => i[a] ?? null
612
+ return Object.assign([...t], {
613
+ item: (a) => t[a] ?? null
572
614
  });
573
- }, nt = async () => {
615
+ }, gt = async () => {
574
616
  try {
575
- k.length > 0 && await (p == null ? void 0 : p(it(k))), await (P == null ? void 0 : P()), k.length > 0 && v([]);
617
+ _.length > 0 && await (b == null ? void 0 : b(ht(_))), await (l == null ? void 0 : l()), _.length > 0 && W([]);
576
618
  } catch {
577
619
  return;
578
620
  }
579
- }, J = (i) => {
580
- i.preventDefault(), i.stopPropagation();
621
+ }, B = (t) => {
622
+ t.preventDefault(), t.stopPropagation();
581
623
  };
582
- return /* @__PURE__ */ B("div", { className: lt(m.field, h && m.fill), "data-max-rows": F, "data-min-rows": N, onDragEnter: (i) => {
583
- J(i), U(!!A);
584
- }, onDragOver: (i) => {
585
- J(i), U(!!A);
586
- }, onDragLeave: (i) => {
587
- J(i), U(!1);
588
- }, onDropCapture: (i) => {
589
- var u;
590
- const a = (u = i.dataTransfer) == null ? void 0 : u.files;
591
- a != null && a.length && (J(i), (A || p) && v([...k, ...Array.from(a)]), U(!1));
592
- }, onDrop: (i) => {
593
- i.preventDefault(), U(!1);
624
+ return /* @__PURE__ */ O("div", { className: nt(h.field, m && h.fill), "data-max-rows": A, "data-min-rows": L, onDragEnter: (t) => {
625
+ B(t), E(!!w);
626
+ }, onDragOver: (t) => {
627
+ B(t), E(!!w);
628
+ }, onDragLeave: (t) => {
629
+ B(t), E(!1);
630
+ }, onDropCapture: (t) => {
631
+ var d;
632
+ const a = (d = t.dataTransfer) == null ? void 0 : d.files;
633
+ a != null && a.length && (B(t), (w || b) && W([..._, ...Array.from(a)]), E(!1));
634
+ }, onDrop: (t) => {
635
+ t.preventDefault(), E(!1);
594
636
  }, "data-component": "editor", children: [
595
- $ === "top" && !h && /* @__PURE__ */ n(ze, { editableRef: D }),
596
- /* @__PURE__ */ n("div", { className: lt(m.editor, h && m["fill-editor"], $ === !0 && !h && m.resizable, $ && !h && ut && m.resized, C && m.invalid, k.length > 0 && m["has-files"]), style: {
597
- "--editor-max-height": `calc(${F * 1.25}em + (2 * var(--scale-8)))`,
598
- "--editor-min-height": `calc(${N * 1.25}em + (2 * var(--scale-8)))`
599
- }, children: /* @__PURE__ */ B(qt, { contentEditable: null, extension: Fe, children: [
600
- !o && /* @__PURE__ */ n(Be, { onInlineImageRemove: ht, onFilesSelected: p || A ? (i) => {
601
- v([...k, ...Array.from(i)]);
637
+ U === "top" && !m && /* @__PURE__ */ o(Ue, { editableRef: q }),
638
+ /* @__PURE__ */ o("div", { className: nt(h.editor, m && h["fill-editor"], U === !0 && !m && h.resizable, U && !m && at && h.resized, f && h.invalid, _.length > 0 && h["has-files"]), style: {
639
+ "--editor-max-height": `calc(${A * 1.25}em + (2 * var(--scale-8)))`,
640
+ "--editor-min-height": `calc(${L * 1.25}em + (2 * var(--scale-8)))`
641
+ }, children: /* @__PURE__ */ O(Vt, { contentEditable: null, extension: Be, children: [
642
+ !n && /* @__PURE__ */ o(ze, { onInlineImageRemove: Y, onFilesSelected: b || w ? (t) => {
643
+ W([..._, ...Array.from(t)]);
602
644
  } : void 0 }),
603
- /* @__PURE__ */ n("div", { className: lt(m.content, dt && m.dragging), children: /* @__PURE__ */ n(Qt, { contentEditable: /* @__PURE__ */ n(Gt, { ref: D, "aria-placeholder": G ?? "", ariaErrorMessage: C && _ ? q : void 0, ariaInvalid: C || void 0, ariaRequired: Z || void 0, placeholder: () => G ? /* @__PURE__ */ n("div", { className: m.placeholder, children: G }) : null }), ErrorBoundary: Zt }) }),
604
- !o && P && /* @__PURE__ */ n("div", { className: m.submit, children: /* @__PURE__ */ n(L, { "aria-label": ct, "data-cy": "toolbar-submit-button", disabled: l, icon: "PaperPlaneTilt", isLoading: Q, onClick: () => void nt(), variant: "primary", children: /* @__PURE__ */ n("span", { children: ct }) }) }),
605
- k.length > 0 && /* @__PURE__ */ n("div", { "aria-label": "Files to upload", className: m.files, role: "region", children: k.map((i, a) => /* @__PURE__ */ n(me, { deleteAccessibleLabel: `Remove ${i.name} from upload queue`, name: i.name, onDelete: () => v(k.filter((u, t) => t !== a)) }, `${i.name}-${i.size}-${i.lastModified}-${a}`)) }),
606
- s && /* @__PURE__ */ n(Kt, {}),
607
- r && /* @__PURE__ */ n(jt, { matchers: be }),
608
- /* @__PURE__ */ n(Yt, {}),
609
- x && /* @__PURE__ */ n(ge, { createImages: mt }),
610
- e !== void 0 && /* @__PURE__ */ n(We, { autofocus: s, content: e, lastEmittedContentRef: R }),
611
- /* @__PURE__ */ n(Vt, { validateUrl: Ct }),
612
- /* @__PURE__ */ n(Jt, {}),
613
- tt && /* @__PURE__ */ n(Xt, { onChange: (i, a) => {
614
- i.read(() => {
615
- const u = $t(a, null), t = wt(u, {
645
+ /* @__PURE__ */ o("div", { className: nt(h.content, T && h.dragging), children: /* @__PURE__ */ o(te, { contentEditable: /* @__PURE__ */ o(Zt, { ref: q, "aria-placeholder": G ?? "", ariaErrorMessage: f && g ? M : void 0, ariaInvalid: f || void 0, ariaRequired: Z || void 0, placeholder: () => G ? /* @__PURE__ */ o("div", { className: h.placeholder, children: G }) : null }), ErrorBoundary: qt }) }),
646
+ !n && l && /* @__PURE__ */ o("div", { className: h.submit, children: /* @__PURE__ */ o(N, { "aria-label": z, "data-cy": "toolbar-submit-button", disabled: c, icon: "PaperPlaneTilt", isLoading: $, onClick: () => void gt(), variant: "primary", children: /* @__PURE__ */ o("span", { children: z }) }) }),
647
+ _.length > 0 && /* @__PURE__ */ o("div", { "aria-label": "Files to upload", className: h.files, role: "region", children: _.map((t, a) => /* @__PURE__ */ o(ue, { deleteAccessibleLabel: `Remove ${t.name} from upload queue`, name: t.name, onDelete: () => W(_.filter((d, D) => D !== a)) }, `${t.name}-${t.size}-${t.lastModified}-${a}`)) }),
648
+ s && /* @__PURE__ */ o(jt, {}),
649
+ r && /* @__PURE__ */ o(Gt, { matchers: $e }),
650
+ /* @__PURE__ */ o(Xt, {}),
651
+ i && /* @__PURE__ */ o(Te, { createImages: et, onRemove: Y }),
652
+ e !== void 0 && /* @__PURE__ */ o(He, { autofocus: s, content: e, lastEmittedContentRef: Q }),
653
+ /* @__PURE__ */ o(Yt, { validateUrl: It }),
654
+ /* @__PURE__ */ o(Jt, {}),
655
+ S && /* @__PURE__ */ o(Qt, { onChange: (t, a) => {
656
+ t.read(() => {
657
+ const d = $t(a, null), D = vt(d, {
616
658
  allowedAttributes: {
617
- ...wt.defaults.allowedAttributes,
618
- img: [...wt.defaults.allowedAttributes.img ?? [], "data-solibo-document-id", "data-solibo-document-slot"]
659
+ ...vt.defaults.allowedAttributes,
660
+ img: [...vt.defaults.allowedAttributes.img ?? [], "data-solibo-document-id", "data-solibo-document-slot"]
619
661
  },
620
662
  allowedTags: ["a", "b", "br", "i", "img", "li", "ol", "p", "u", "ul"]
621
663
  });
622
- R.current = t, tt(t);
664
+ Q.current = D, S(D);
623
665
  });
624
666
  } })
625
667
  ] }) }),
626
- C && _ && /* @__PURE__ */ n("div", { className: m.error, id: q, children: _ })
668
+ f && g && /* @__PURE__ */ o("div", { className: h.error, id: M, children: g })
627
669
  ] });
628
670
  };
629
671
  export {
630
- fr as Editor
672
+ gr as Editor
631
673
  };