@alixpartners/ui-components 2.5.6 → 2.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -97
- package/dist/RichTextEditor-kTQEDSL0.js +477 -0
- package/dist/components/RichTextEditor/RichTextEditor.js +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.test.js +1 -1
- package/dist/main.js +1 -1
- package/dist/web.config +8 -8
- package/package.json +94 -94
- package/dist/RichTextEditor-cvtLFe4t.js +0 -443
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
import { jsxs as c, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { c as b } from "./clsx-OuTLNxxd.js";
|
|
3
|
-
import { useMemo as Ee, useId as ze, useRef as M, useState as u, useEffect as H } from "react";
|
|
4
|
-
import qe from "./components/Dialog/Dialog.js";
|
|
5
|
-
import U from "./components/Icon/Icon.js";
|
|
6
|
-
import ve from "./components/Input/Input.js";
|
|
7
|
-
import G from "./components/Tooltip/Tooltip.js";
|
|
8
|
-
import { R as $e, T as We, P as Ke, C as Ve } from "./index-CCFDXH-J.js";
|
|
9
|
-
import './assets/RichTextEditor.css';const Je = "RichTextEditor-module__container___AplP0", Ze = "RichTextEditor-module__label___vjzs-", Ge = "RichTextEditor-module__required___7duke", Ye = "RichTextEditor-module__frame___7OSyf", Xe = "RichTextEditor-module__frameFocused___GtJ2x", Qe = "RichTextEditor-module__frameDisabled___LubtU", et = "RichTextEditor-module__frameError___sPTiY", tt = "RichTextEditor-module__errorMessage___4VdKj", nt = "RichTextEditor-module__helpers___cpuz6", ot = "RichTextEditor-module__helperText___rFoU0", rt = "RichTextEditor-module__helpLink___7gYcv", it = "RichTextEditor-module__containerDisabled___6h9dd", at = "RichTextEditor-module__containerFullWidth___pOoeL", lt = "RichTextEditor-module__toolbarContent___YXKHD", ct = "RichTextEditor-module__toolbarPanel___OVGHO", st = "RichTextEditor-module__toolbarRow___f0xJR", dt = "RichTextEditor-module__editorBody___f8jPI", ut = "RichTextEditor-module__toolbar___m9-M-", mt = "RichTextEditor-module__toolbarStacked___6rB10", ht = "RichTextEditor-module__actions___ZAK9J", ft = "RichTextEditor-module__toolButton___IT2Kg", _t = "RichTextEditor-module__toolButtonActive___-HvZQ", pt = "RichTextEditor-module__toolIcon___Wndhd", gt = "RichTextEditor-module__formatControl___w4WcA", Tt = "RichTextEditor-module__toolbarLinkSlot___Gu-9l", bt = "RichTextEditor-module__selectTrigger___frv3x", xt = "RichTextEditor-module__selectIconBox___SYdTE", Rt = "RichTextEditor-module__selectTriggerOpen___tk2Pb", Et = "RichTextEditor-module__selectTriggerLabel___FkEv0", vt = "RichTextEditor-module__selectIcon___aJWUk", kt = "RichTextEditor-module__formatMenu___y-uBL", Mt = "RichTextEditor-module__formatMenuOptions___zcdlo", yt = "RichTextEditor-module__formatMenuOption___3ppTs", Ct = "RichTextEditor-module__formatMenuOptionSelected___bq9J9", Lt = "RichTextEditor-module__formatMenuOptionParagraph___4BLds", Ot = "RichTextEditor-module__formatMenuOptionHeading1___H1cKX", Nt = "RichTextEditor-module__formatMenuOptionHeading2___JdixR", Ht = "RichTextEditor-module__formatMenuOptionHeading3___NcwLr", wt = "RichTextEditor-module__formatMenuOptionHeading4___4mLbG", Bt = "RichTextEditor-module__formatMenuOptionPreformatted___cB0Ix", St = "RichTextEditor-module__editor___M32R7", Dt = "RichTextEditor-module__characterCount___gmUzj", It = "RichTextEditor-module__characterCountExceeded___vjIpc", Ft = "RichTextEditor-module__linkDialogForm___vOLO1", t = {
|
|
10
|
-
container: Je,
|
|
11
|
-
label: Ze,
|
|
12
|
-
required: Ge,
|
|
13
|
-
frame: Ye,
|
|
14
|
-
frameFocused: Xe,
|
|
15
|
-
frameDisabled: Qe,
|
|
16
|
-
frameError: et,
|
|
17
|
-
errorMessage: tt,
|
|
18
|
-
helpers: nt,
|
|
19
|
-
helperText: ot,
|
|
20
|
-
helpLink: rt,
|
|
21
|
-
containerDisabled: it,
|
|
22
|
-
containerFullWidth: at,
|
|
23
|
-
toolbarContent: lt,
|
|
24
|
-
toolbarPanel: ct,
|
|
25
|
-
toolbarRow: st,
|
|
26
|
-
editorBody: dt,
|
|
27
|
-
toolbar: ut,
|
|
28
|
-
toolbarStacked: mt,
|
|
29
|
-
actions: ht,
|
|
30
|
-
toolButton: ft,
|
|
31
|
-
toolButtonActive: _t,
|
|
32
|
-
toolIcon: pt,
|
|
33
|
-
formatControl: gt,
|
|
34
|
-
toolbarLinkSlot: Tt,
|
|
35
|
-
selectTrigger: bt,
|
|
36
|
-
selectIconBox: xt,
|
|
37
|
-
selectTriggerOpen: Rt,
|
|
38
|
-
selectTriggerLabel: Et,
|
|
39
|
-
selectIcon: vt,
|
|
40
|
-
formatMenu: kt,
|
|
41
|
-
formatMenuOptions: Mt,
|
|
42
|
-
formatMenuOption: yt,
|
|
43
|
-
formatMenuOptionSelected: Ct,
|
|
44
|
-
formatMenuOptionParagraph: Lt,
|
|
45
|
-
formatMenuOptionHeading1: Ot,
|
|
46
|
-
formatMenuOptionHeading2: Nt,
|
|
47
|
-
formatMenuOptionHeading3: Ht,
|
|
48
|
-
formatMenuOptionHeading4: wt,
|
|
49
|
-
formatMenuOptionPreformatted: Bt,
|
|
50
|
-
editor: St,
|
|
51
|
-
characterCount: Dt,
|
|
52
|
-
characterCountExceeded: It,
|
|
53
|
-
linkDialogForm: Ft
|
|
54
|
-
}, At = {
|
|
55
|
-
paragraph: "p",
|
|
56
|
-
heading1: "h1",
|
|
57
|
-
heading2: "h2",
|
|
58
|
-
heading3: "h3",
|
|
59
|
-
heading4: "h4",
|
|
60
|
-
preformatted: "pre",
|
|
61
|
-
"unordered-list": "ul",
|
|
62
|
-
"ordered-list": "ol"
|
|
63
|
-
};
|
|
64
|
-
function Me(r) {
|
|
65
|
-
return r.trim().length > 0 ? r : "<br>";
|
|
66
|
-
}
|
|
67
|
-
function Pt(r) {
|
|
68
|
-
switch (r.toLowerCase()) {
|
|
69
|
-
case "h1":
|
|
70
|
-
return "heading1";
|
|
71
|
-
case "h2":
|
|
72
|
-
return "heading2";
|
|
73
|
-
case "h3":
|
|
74
|
-
return "heading3";
|
|
75
|
-
case "h4":
|
|
76
|
-
return "heading4";
|
|
77
|
-
case "pre":
|
|
78
|
-
return "preformatted";
|
|
79
|
-
case "ul":
|
|
80
|
-
return "unordered-list";
|
|
81
|
-
case "ol":
|
|
82
|
-
return "ordered-list";
|
|
83
|
-
case "p":
|
|
84
|
-
default:
|
|
85
|
-
return "paragraph";
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function Y(r) {
|
|
89
|
-
if (!r.trim())
|
|
90
|
-
return {
|
|
91
|
-
blocks: [{
|
|
92
|
-
type: "paragraph",
|
|
93
|
-
html: "<br>"
|
|
94
|
-
}]
|
|
95
|
-
};
|
|
96
|
-
const f = new DOMParser().parseFromString(r, "text/html"), p = Array.from(f.body.childNodes), x = [];
|
|
97
|
-
return p.forEach((a) => {
|
|
98
|
-
var E;
|
|
99
|
-
if (a.nodeType === Node.TEXT_NODE) {
|
|
100
|
-
const y = (E = a.textContent) == null ? void 0 : E.trim();
|
|
101
|
-
y && x.push({
|
|
102
|
-
type: "paragraph",
|
|
103
|
-
html: y
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (a.nodeType !== Node.ELEMENT_NODE)
|
|
108
|
-
return;
|
|
109
|
-
const m = a, R = m.style.textAlign;
|
|
110
|
-
x.push({
|
|
111
|
-
type: Pt(m.tagName),
|
|
112
|
-
html: Me(m.innerHTML),
|
|
113
|
-
align: R || void 0
|
|
114
|
-
});
|
|
115
|
-
}), {
|
|
116
|
-
blocks: x.length > 0 ? x : [{
|
|
117
|
-
type: "paragraph",
|
|
118
|
-
html: "<br>"
|
|
119
|
-
}]
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function ke(r) {
|
|
123
|
-
return r.blocks.length ? r.blocks.map((s) => {
|
|
124
|
-
const f = At[s.type], p = s.align ? ` style="text-align:${s.align}"` : "";
|
|
125
|
-
return `<${f}${p}>${Me(s.html)}</${f}>`;
|
|
126
|
-
}).join("") : "<p><br></p>";
|
|
127
|
-
}
|
|
128
|
-
function Ut(r) {
|
|
129
|
-
return r.blocks.map((f) => f.html.replace(/<[^>]+>/g, "")).join("").length;
|
|
130
|
-
}
|
|
131
|
-
const jt = ["bold", "italic", "underline", "align-left", "align-center", "align-right", "bulleted", "link", "format"], zt = [{
|
|
132
|
-
label: "Paragraph",
|
|
133
|
-
value: "paragraph"
|
|
134
|
-
}, {
|
|
135
|
-
label: "Heading 1",
|
|
136
|
-
value: "heading1"
|
|
137
|
-
}, {
|
|
138
|
-
label: "Heading 2",
|
|
139
|
-
value: "heading2"
|
|
140
|
-
}, {
|
|
141
|
-
label: "Heading 3",
|
|
142
|
-
value: "heading3"
|
|
143
|
-
}, {
|
|
144
|
-
label: "Heading 4",
|
|
145
|
-
value: "heading4"
|
|
146
|
-
}, {
|
|
147
|
-
label: "Preformatted",
|
|
148
|
-
value: "preformatted"
|
|
149
|
-
}], qt = {
|
|
150
|
-
paragraph: "P",
|
|
151
|
-
heading1: "H1",
|
|
152
|
-
heading2: "H2",
|
|
153
|
-
heading3: "H3",
|
|
154
|
-
heading4: "H4",
|
|
155
|
-
preformatted: "PRE",
|
|
156
|
-
"unordered-list": "UL",
|
|
157
|
-
"ordered-list": "OL"
|
|
158
|
-
};
|
|
159
|
-
function X() {
|
|
160
|
-
return "<p><br></p>";
|
|
161
|
-
}
|
|
162
|
-
function $t(r) {
|
|
163
|
-
return r.trim().length > 0 ? r : X();
|
|
164
|
-
}
|
|
165
|
-
function Wt() {
|
|
166
|
-
const r = document.queryCommandValue("formatBlock");
|
|
167
|
-
switch (String(r || "").replace(/[<>]/g, "").toUpperCase()) {
|
|
168
|
-
case "H1":
|
|
169
|
-
return "heading1";
|
|
170
|
-
case "H2":
|
|
171
|
-
return "heading2";
|
|
172
|
-
case "H3":
|
|
173
|
-
return "heading3";
|
|
174
|
-
case "H4":
|
|
175
|
-
return "heading4";
|
|
176
|
-
case "PRE":
|
|
177
|
-
return "preformatted";
|
|
178
|
-
default:
|
|
179
|
-
return "paragraph";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function Kt(r) {
|
|
183
|
-
switch (r) {
|
|
184
|
-
case "heading1":
|
|
185
|
-
return t.formatMenuOptionHeading1;
|
|
186
|
-
case "heading2":
|
|
187
|
-
return t.formatMenuOptionHeading2;
|
|
188
|
-
case "heading3":
|
|
189
|
-
return t.formatMenuOptionHeading3;
|
|
190
|
-
case "heading4":
|
|
191
|
-
return t.formatMenuOptionHeading4;
|
|
192
|
-
case "preformatted":
|
|
193
|
-
return t.formatMenuOptionPreformatted;
|
|
194
|
-
default:
|
|
195
|
-
return t.formatMenuOptionParagraph;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function tn({
|
|
199
|
-
className: r,
|
|
200
|
-
label: s,
|
|
201
|
-
required: f = !1,
|
|
202
|
-
value: p,
|
|
203
|
-
placeholder: x = "Content",
|
|
204
|
-
disabled: a = !1,
|
|
205
|
-
errorMessage: m,
|
|
206
|
-
helpText: R,
|
|
207
|
-
helpLink: E,
|
|
208
|
-
helpLinkText: y,
|
|
209
|
-
toolbarLayout: j = "inline",
|
|
210
|
-
showToolbar: z = !0,
|
|
211
|
-
showCharacterCount: ye = !0,
|
|
212
|
-
maxCharacters: g,
|
|
213
|
-
resizable: Ce = !0,
|
|
214
|
-
rows: Le = 8,
|
|
215
|
-
fullWidth: q = !1,
|
|
216
|
-
tooltipEnabled: w = !0,
|
|
217
|
-
formatOptions: Q = zt,
|
|
218
|
-
toolbarOptions: ee = jt,
|
|
219
|
-
onChange: $,
|
|
220
|
-
onModelChange: W
|
|
221
|
-
}) {
|
|
222
|
-
const Oe = Ee(() => new Set(ee), [ee]), C = (e) => Oe.has(e), te = ze(), d = M(null), ne = M(null), oe = M(null), L = M(null), B = M(!1), [Ne, re] = u(!1), [S, ie] = u(!1), [He, we] = u(0), [ae, le] = u(null), [Be, ce] = u(!1), [se, de] = u(""), [ue, me] = u(""), [he, O] = u(""), [D, fe] = u(() => Y(p || X())), [_e, Se] = u("paragraph"), [T, De] = u({
|
|
223
|
-
bold: !1,
|
|
224
|
-
italic: !1,
|
|
225
|
-
underline: !1,
|
|
226
|
-
justifyLeft: !1,
|
|
227
|
-
justifyCenter: !1,
|
|
228
|
-
justifyRight: !1,
|
|
229
|
-
insertUnorderedList: !1
|
|
230
|
-
}), N = Ee(() => Ut(D), [D]), pe = M(N);
|
|
231
|
-
pe.current = N;
|
|
232
|
-
const K = () => {
|
|
233
|
-
if (!d.current) return;
|
|
234
|
-
const e = Y(d.current.innerHTML);
|
|
235
|
-
fe(e), W == null || W(e), $ == null || $(ke(e));
|
|
236
|
-
}, I = () => {
|
|
237
|
-
Se(Wt()), De({
|
|
238
|
-
bold: document.queryCommandState("bold"),
|
|
239
|
-
italic: document.queryCommandState("italic"),
|
|
240
|
-
underline: document.queryCommandState("underline"),
|
|
241
|
-
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
242
|
-
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
243
|
-
justifyRight: document.queryCommandState("justifyRight"),
|
|
244
|
-
insertUnorderedList: document.queryCommandState("insertUnorderedList")
|
|
245
|
-
});
|
|
246
|
-
}, V = () => {
|
|
247
|
-
var e;
|
|
248
|
-
a || (e = d.current) == null || e.focus();
|
|
249
|
-
}, ge = (e, n) => {
|
|
250
|
-
a || (V(), document.execCommand(e, !1, n), K(), I());
|
|
251
|
-
}, Ie = (e) => {
|
|
252
|
-
ge("formatBlock", qt[e]);
|
|
253
|
-
}, Te = () => {
|
|
254
|
-
var l, k;
|
|
255
|
-
if (a) return;
|
|
256
|
-
V();
|
|
257
|
-
const e = window.getSelection();
|
|
258
|
-
let n = "", i = "";
|
|
259
|
-
if (e && e.rangeCount > 0) {
|
|
260
|
-
const h = e.getRangeAt(0);
|
|
261
|
-
L.current = h.cloneRange(), n = e.toString();
|
|
262
|
-
const _ = ((l = h.startContainer.parentElement) == null ? void 0 : l.closest("a")) ?? ((k = h.endContainer.parentElement) == null ? void 0 : k.closest("a"));
|
|
263
|
-
_ instanceof HTMLAnchorElement && (n = _.textContent ?? n, i = _.getAttribute("href") ?? "");
|
|
264
|
-
} else
|
|
265
|
-
L.current = null;
|
|
266
|
-
de(n), me(i), O(""), ce(!0);
|
|
267
|
-
}, J = () => {
|
|
268
|
-
if (B.current) {
|
|
269
|
-
B.current = !1;
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
ce(!1), O(""), L.current = null;
|
|
273
|
-
}, Fe = (e) => {
|
|
274
|
-
me(e), he && O("");
|
|
275
|
-
}, Ae = (e) => {
|
|
276
|
-
const n = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
277
|
-
try {
|
|
278
|
-
const i = /^https?:\/\//i.test(e), l = new URL(i ? e : `https://${e}`);
|
|
279
|
-
return l.protocol !== "http:" && l.protocol !== "https:" ? !1 : n.test(l.hostname);
|
|
280
|
-
} catch {
|
|
281
|
-
return !1;
|
|
282
|
-
}
|
|
283
|
-
}, Pe = (e) => /^https?:\/\//i.test(e) ? e : `https://${/^www\./i.test(e) ? e : `www.${e}`}`, Ue = () => {
|
|
284
|
-
const e = ue.trim();
|
|
285
|
-
if (!e) {
|
|
286
|
-
O("This field is required"), B.current = !0;
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
if (!Ae(e)) {
|
|
290
|
-
O("Invalid link"), B.current = !0;
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const n = Pe(e), i = se.trim() || e, l = (_) => _.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), k = `<a href="${l(n)}" target="_blank" rel="noopener noreferrer">${l(i)}</a>`;
|
|
294
|
-
V();
|
|
295
|
-
const h = window.getSelection();
|
|
296
|
-
h && L.current && (h.removeAllRanges(), h.addRange(L.current)), document.execCommand("insertHTML", !1, k), K(), I(), J();
|
|
297
|
-
}, je = (e) => {
|
|
298
|
-
if (!e.ctrlKey && !e.metaKey) return;
|
|
299
|
-
const n = e.target, i = n == null ? void 0 : n.closest("a");
|
|
300
|
-
i instanceof HTMLAnchorElement && i.href && (e.preventDefault(), window.open(i.href, "_blank", "noopener,noreferrer"));
|
|
301
|
-
};
|
|
302
|
-
H(() => {
|
|
303
|
-
const e = $t(p || X()), n = Y(e);
|
|
304
|
-
fe(n), d.current && d.current.innerHTML !== e && (d.current.innerHTML = e);
|
|
305
|
-
}, [p]), H(() => {
|
|
306
|
-
d.current && (d.current.innerHTML.trim() || (d.current.innerHTML = ke(D)));
|
|
307
|
-
}, [D]), H(() => {
|
|
308
|
-
const e = d.current;
|
|
309
|
-
if (!e || !g) return;
|
|
310
|
-
const n = (i) => {
|
|
311
|
-
var _;
|
|
312
|
-
if (!i.inputType.startsWith("insert")) return;
|
|
313
|
-
const l = window.getSelection(), k = l && !l.isCollapsed ? l.toString().length : 0, h = i.data ? i.data.length : ((_ = i.dataTransfer) == null ? void 0 : _.getData("text").length) ?? 0;
|
|
314
|
-
pe.current - k + h > g && i.preventDefault();
|
|
315
|
-
};
|
|
316
|
-
return e.addEventListener("beforeinput", n), () => e.removeEventListener("beforeinput", n);
|
|
317
|
-
}, [g]), H(() => {
|
|
318
|
-
var n;
|
|
319
|
-
const e = (n = ne.current) == null ? void 0 : n.getBoundingClientRect().width;
|
|
320
|
-
e && we(e);
|
|
321
|
-
}, [S]), H(() => {
|
|
322
|
-
if (!z || q) {
|
|
323
|
-
le(null);
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
const e = oe.current;
|
|
327
|
-
if (!e) return;
|
|
328
|
-
const n = () => {
|
|
329
|
-
const l = e.getBoundingClientRect().width;
|
|
330
|
-
l > 0 && le(l);
|
|
331
|
-
};
|
|
332
|
-
n();
|
|
333
|
-
const i = new ResizeObserver(() => {
|
|
334
|
-
n();
|
|
335
|
-
});
|
|
336
|
-
return i.observe(e), window.addEventListener("resize", n), () => {
|
|
337
|
-
i.disconnect(), window.removeEventListener("resize", n);
|
|
338
|
-
};
|
|
339
|
-
}, [z, j, a, w, q]);
|
|
340
|
-
const v = (e) => /* @__PURE__ */ o(G, { content: e.tooltip, size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: b(t.toolButton, e.active && t.toolButtonActive), onMouseDown: (n) => n.preventDefault(), onClick: () => ge(e.command, e.value), "aria-label": e.tooltip, disabled: a, children: /* @__PURE__ */ o(U, { icon: e.icon, className: t.toolIcon }) }) }, e.id), Z = [{
|
|
341
|
-
id: "bold",
|
|
342
|
-
icon: "ap-icon-bold",
|
|
343
|
-
command: "bold",
|
|
344
|
-
tooltip: "Bold (CTRL + B)",
|
|
345
|
-
active: T.bold
|
|
346
|
-
}, {
|
|
347
|
-
id: "italic",
|
|
348
|
-
icon: "ap-icon-italic",
|
|
349
|
-
command: "italic",
|
|
350
|
-
tooltip: "Italic (CTRL + I)",
|
|
351
|
-
active: T.italic
|
|
352
|
-
}, {
|
|
353
|
-
id: "underline",
|
|
354
|
-
icon: "ap-icon-underline",
|
|
355
|
-
command: "underline",
|
|
356
|
-
tooltip: "Underline (CTRL + U)",
|
|
357
|
-
active: T.underline
|
|
358
|
-
}, {
|
|
359
|
-
id: "align-left",
|
|
360
|
-
icon: "ap-icon-align-left",
|
|
361
|
-
command: "justifyLeft",
|
|
362
|
-
tooltip: "Align left",
|
|
363
|
-
active: T.justifyLeft
|
|
364
|
-
}, {
|
|
365
|
-
id: "align-center",
|
|
366
|
-
icon: "ap-icon-align-center",
|
|
367
|
-
command: "justifyCenter",
|
|
368
|
-
tooltip: "Align center",
|
|
369
|
-
active: T.justifyCenter
|
|
370
|
-
}, {
|
|
371
|
-
id: "align-right",
|
|
372
|
-
icon: "ap-icon-align-right",
|
|
373
|
-
command: "justifyRight",
|
|
374
|
-
tooltip: "Align right",
|
|
375
|
-
active: T.justifyRight
|
|
376
|
-
}, {
|
|
377
|
-
id: "bulleted",
|
|
378
|
-
icon: "ap-icon-list",
|
|
379
|
-
command: "insertUnorderedList",
|
|
380
|
-
tooltip: "Bulleted list",
|
|
381
|
-
active: T.insertUnorderedList
|
|
382
|
-
}], F = Z.filter((e) => ["bold", "italic", "underline"].includes(e.id) && C(e.id)), A = Z.filter((e) => ["align-left", "align-center", "align-right"].includes(e.id) && C(e.id)), P = Z.filter((e) => ["bulleted"].includes(e.id) && C(e.id)), be = C("link"), xe = C("format"), Re = () => {
|
|
383
|
-
var e;
|
|
384
|
-
return /* @__PURE__ */ o("div", { className: t.formatControl, children: /* @__PURE__ */ c($e, { open: S, onOpenChange: ie, children: [
|
|
385
|
-
/* @__PURE__ */ c(We, { ref: ne, disabled: a, className: b(t.selectTrigger, S && t.selectTriggerOpen), children: [
|
|
386
|
-
/* @__PURE__ */ o("span", { className: t.selectTriggerLabel, children: ((e = Q.find((n) => n.value === _e)) == null ? void 0 : e.label) || "Paragraph" }),
|
|
387
|
-
/* @__PURE__ */ o("span", { className: t.selectIconBox, children: /* @__PURE__ */ o(U, { icon: S ? "ap-icon-expand-less" : "ap-icon-expand-more", className: t.selectIcon }) })
|
|
388
|
-
] }),
|
|
389
|
-
/* @__PURE__ */ o(Ke, { children: /* @__PURE__ */ o(Ve, { align: "end", side: "bottom", sideOffset: 6, collisionPadding: 8, className: t.formatMenu, style: {
|
|
390
|
-
minWidth: He || 180,
|
|
391
|
-
zIndex: 9999
|
|
392
|
-
}, children: /* @__PURE__ */ o("div", { className: t.formatMenuOptions, children: Q.map((n) => /* @__PURE__ */ o("button", { type: "button", className: b(t.formatMenuOption, Kt(n.value), n.value === _e && t.formatMenuOptionSelected), onMouseDown: (i) => i.preventDefault(), onClick: () => {
|
|
393
|
-
Ie(n.value), ie(!1);
|
|
394
|
-
}, children: n.label }, n.value)) }) }) })
|
|
395
|
-
] }) });
|
|
396
|
-
};
|
|
397
|
-
return /* @__PURE__ */ c("div", { className: b(t.container, a && t.containerDisabled, q && t.containerFullWidth, r), children: [
|
|
398
|
-
s && /* @__PURE__ */ c("label", { className: t.label, htmlFor: te, children: [
|
|
399
|
-
s,
|
|
400
|
-
f && /* @__PURE__ */ o("span", { className: t.required, children: "*" })
|
|
401
|
-
] }),
|
|
402
|
-
/* @__PURE__ */ c("div", { className: b(t.frame, Ne && t.frameFocused, a && t.frameDisabled, m && t.frameError), style: {
|
|
403
|
-
width: ae ? `${ae}px` : void 0
|
|
404
|
-
}, children: [
|
|
405
|
-
z && /* @__PURE__ */ o("div", { className: b(t.toolbar, j === "stacked" && t.toolbarStacked), children: /* @__PURE__ */ o("div", { ref: oe, className: t.toolbarContent, children: j === "stacked" ? /* @__PURE__ */ c("div", { className: t.toolbarPanel, children: [
|
|
406
|
-
/* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
407
|
-
F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
|
|
408
|
-
A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) })
|
|
409
|
-
] }),
|
|
410
|
-
/* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
411
|
-
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
|
|
412
|
-
be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
413
|
-
xe && Re()
|
|
414
|
-
] })
|
|
415
|
-
] }) : /* @__PURE__ */ o("div", { className: t.toolbarPanel, children: /* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
416
|
-
F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
|
|
417
|
-
A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) }),
|
|
418
|
-
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
|
|
419
|
-
be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
420
|
-
xe && Re()
|
|
421
|
-
] }) }) }) }),
|
|
422
|
-
/* @__PURE__ */ c("div", { className: t.editorBody, style: {
|
|
423
|
-
minHeight: `${Le * 20}px`,
|
|
424
|
-
resize: Ce && !a ? "vertical" : "none"
|
|
425
|
-
}, children: [
|
|
426
|
-
/* @__PURE__ */ o("div", { id: te, ref: d, className: t.editor, contentEditable: !a, suppressContentEditableWarning: !0, role: "textbox", "aria-multiline": "true", "aria-label": s || "Rich text editor", "data-placeholder": x, onInput: K, onFocus: () => re(!0), onBlur: () => re(!1), onKeyUp: I, onMouseUp: I, onClick: je }),
|
|
427
|
-
ye && /* @__PURE__ */ o("div", { className: b(t.characterCount, g && N > g && t.characterCountExceeded), children: g ? `${N}/${g}` : N })
|
|
428
|
-
] })
|
|
429
|
-
] }),
|
|
430
|
-
(m || R || E) && /* @__PURE__ */ c("div", { className: t.helpers, children: [
|
|
431
|
-
m ? /* @__PURE__ */ o("span", { title: m, className: t.errorMessage, children: m }) : R && /* @__PURE__ */ o("span", { title: R, className: t.helperText, children: R }),
|
|
432
|
-
E && y && /* @__PURE__ */ o("a", { href: E, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", children: y })
|
|
433
|
-
] }),
|
|
434
|
-
/* @__PURE__ */ o(qe, { isOpen: Be, onClose: J, title: "Attach link", cancelButtonText: "Cancel", cancelButtonType: "primary", cancelButtonVariant: "cancel", confirmButtonText: "Attach", confirmButtonType: "primary", onCancel: J, onConfirm: Ue, description: /* @__PURE__ */ c("div", { className: t.linkDialogForm, children: [
|
|
435
|
-
/* @__PURE__ */ o(ve, { type: "text", label: "Displayed text", value: se, onChange: de, autofocus: !0 }),
|
|
436
|
-
/* @__PURE__ */ o(ve, { type: "text", label: "Link", value: ue, placeholder: "https://example.com/", required: !0, errorMessage: he || void 0, onChange: Fe })
|
|
437
|
-
] }) })
|
|
438
|
-
] });
|
|
439
|
-
}
|
|
440
|
-
export {
|
|
441
|
-
tn as R,
|
|
442
|
-
t as s
|
|
443
|
-
};
|