@solibo/solibo-ui 2.2.8 → 2.2.10

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