@superdoc-dev/template-builder 0.3.0 → 0.5.0
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/LICENSE +661 -0
- package/README.md +24 -26
- package/dist/defaults/FieldList.d.ts.map +1 -1
- package/dist/defaults/FieldMenu.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +394 -430
- package/dist/types.d.ts +10 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -7
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { jsxs as o, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as I, useEffect as
|
|
3
|
-
const
|
|
2
|
+
import { useState as I, useEffect as oe, useMemo as Fe, forwardRef as ze, useRef as J, useCallback as S, useImperativeHandle as Be } from "react";
|
|
3
|
+
const We = ({
|
|
4
4
|
isVisible: n,
|
|
5
|
-
position:
|
|
6
|
-
availableFields:
|
|
7
|
-
filteredFields:
|
|
8
|
-
filterQuery:
|
|
9
|
-
allowCreate:
|
|
10
|
-
onSelect:
|
|
5
|
+
position: d,
|
|
6
|
+
availableFields: g,
|
|
7
|
+
filteredFields: l,
|
|
8
|
+
filterQuery: u,
|
|
9
|
+
allowCreate: a,
|
|
10
|
+
onSelect: N,
|
|
11
11
|
onClose: P,
|
|
12
12
|
onCreateField: G,
|
|
13
|
-
existingFields:
|
|
13
|
+
existingFields: f = [],
|
|
14
14
|
onSelectExisting: T
|
|
15
15
|
}) => {
|
|
16
|
-
const [x, y] = I(!1), [
|
|
17
|
-
|
|
18
|
-
n || (y(!1),
|
|
16
|
+
const [x, y] = I(!1), [w, R] = I(""), [q, A] = I("inline"), [X, ie] = I(!0), [p, z] = I(!0);
|
|
17
|
+
oe(() => {
|
|
18
|
+
n || (y(!1), R(""), A("inline"));
|
|
19
19
|
}, [n]);
|
|
20
|
-
const
|
|
20
|
+
const V = Fe(() => ({
|
|
21
21
|
position: "absolute",
|
|
22
|
-
left:
|
|
23
|
-
top:
|
|
22
|
+
left: d?.left,
|
|
23
|
+
top: d?.top,
|
|
24
24
|
zIndex: 1e3,
|
|
25
25
|
background: "white",
|
|
26
26
|
border: "1px solid #ddd",
|
|
@@ -28,30 +28,30 @@ const ze = ({
|
|
|
28
28
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
29
29
|
padding: "8px 0",
|
|
30
30
|
width: "280px"
|
|
31
|
-
}), [
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
31
|
+
}), [d]), O = l ?? g, j = !!u;
|
|
32
|
+
if (oe(() => {
|
|
33
|
+
j && z(!0);
|
|
34
|
+
}, [j]), !n) return null;
|
|
35
|
+
const D = async () => {
|
|
36
|
+
const m = w.trim();
|
|
37
|
+
if (!m) return;
|
|
38
|
+
const B = {
|
|
39
39
|
id: `custom_${Date.now()}`,
|
|
40
|
-
label:
|
|
41
|
-
|
|
40
|
+
label: m,
|
|
41
|
+
mode: q
|
|
42
42
|
};
|
|
43
43
|
try {
|
|
44
44
|
if (G) {
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const h = await G(B);
|
|
46
|
+
N(h || B);
|
|
47
47
|
} else
|
|
48
|
-
B
|
|
48
|
+
N(B);
|
|
49
49
|
} finally {
|
|
50
|
-
y(!1),
|
|
50
|
+
y(!1), R(""), A("inline");
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
return /* @__PURE__ */ o("div", { className: "superdoc-field-menu", style:
|
|
54
|
-
|
|
53
|
+
return /* @__PURE__ */ o("div", { className: "superdoc-field-menu", style: V, children: [
|
|
54
|
+
j && /* @__PURE__ */ r(
|
|
55
55
|
"div",
|
|
56
56
|
{
|
|
57
57
|
style: {
|
|
@@ -61,17 +61,11 @@ const ze = ({
|
|
|
61
61
|
},
|
|
62
62
|
children: /* @__PURE__ */ o("div", { style: { fontSize: "12px", color: "#6b7280" }, children: [
|
|
63
63
|
"Filtering results for",
|
|
64
|
-
/* @__PURE__ */ r(
|
|
65
|
-
"span",
|
|
66
|
-
{
|
|
67
|
-
style: { fontWeight: 600, color: "#111827", marginLeft: "4px" },
|
|
68
|
-
children: a
|
|
69
|
-
}
|
|
70
|
-
)
|
|
64
|
+
/* @__PURE__ */ r("span", { style: { fontWeight: 600, color: "#111827", marginLeft: "4px" }, children: u })
|
|
71
65
|
] })
|
|
72
66
|
}
|
|
73
67
|
),
|
|
74
|
-
|
|
68
|
+
a && !x && /* @__PURE__ */ r(
|
|
75
69
|
"div",
|
|
76
70
|
{
|
|
77
71
|
className: "field-menu-item",
|
|
@@ -85,16 +79,16 @@ const ze = ({
|
|
|
85
79
|
children: "+ Create New Field"
|
|
86
80
|
}
|
|
87
81
|
),
|
|
88
|
-
|
|
82
|
+
a && x && /* @__PURE__ */ o("div", { style: { padding: "8px 16px" }, children: [
|
|
89
83
|
/* @__PURE__ */ r(
|
|
90
84
|
"input",
|
|
91
85
|
{
|
|
92
86
|
type: "text",
|
|
93
|
-
value:
|
|
87
|
+
value: w,
|
|
94
88
|
placeholder: "Field name...",
|
|
95
|
-
onChange: (
|
|
96
|
-
onKeyDown: (
|
|
97
|
-
|
|
89
|
+
onChange: (m) => R(m.target.value),
|
|
90
|
+
onKeyDown: (m) => {
|
|
91
|
+
m.key === "Enter" && D(), m.key === "Escape" && (y(!1), R(""), A("inline"));
|
|
98
92
|
},
|
|
99
93
|
autoFocus: !0,
|
|
100
94
|
style: {
|
|
@@ -176,15 +170,15 @@ const ze = ({
|
|
|
176
170
|
/* @__PURE__ */ r(
|
|
177
171
|
"button",
|
|
178
172
|
{
|
|
179
|
-
onClick:
|
|
180
|
-
disabled: !
|
|
173
|
+
onClick: D,
|
|
174
|
+
disabled: !w.trim(),
|
|
181
175
|
style: {
|
|
182
176
|
padding: "4px 12px",
|
|
183
|
-
background:
|
|
177
|
+
background: w.trim() ? "#0066cc" : "#ccc",
|
|
184
178
|
color: "white",
|
|
185
179
|
border: "none",
|
|
186
180
|
borderRadius: "3px",
|
|
187
|
-
cursor:
|
|
181
|
+
cursor: w.trim() ? "pointer" : "not-allowed"
|
|
188
182
|
},
|
|
189
183
|
children: "Create"
|
|
190
184
|
}
|
|
@@ -193,7 +187,7 @@ const ze = ({
|
|
|
193
187
|
"button",
|
|
194
188
|
{
|
|
195
189
|
onClick: () => {
|
|
196
|
-
y(!1),
|
|
190
|
+
y(!1), R(""), A("inline");
|
|
197
191
|
},
|
|
198
192
|
style: {
|
|
199
193
|
padding: "4px 12px",
|
|
@@ -209,7 +203,7 @@ const ze = ({
|
|
|
209
203
|
}
|
|
210
204
|
)
|
|
211
205
|
] }),
|
|
212
|
-
|
|
206
|
+
a && g.length > 0 && /* @__PURE__ */ r(
|
|
213
207
|
"div",
|
|
214
208
|
{
|
|
215
209
|
style: {
|
|
@@ -218,22 +212,22 @@ const ze = ({
|
|
|
218
212
|
}
|
|
219
213
|
}
|
|
220
214
|
),
|
|
221
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
215
|
+
f.length > 0 && (() => {
|
|
216
|
+
const m = /* @__PURE__ */ new Map();
|
|
217
|
+
f.forEach((h) => {
|
|
218
|
+
const Y = h.group || `individual-${h.id}`, ee = m.get(Y) || [];
|
|
219
|
+
ee.push(h), m.set(Y, ee);
|
|
226
220
|
});
|
|
227
|
-
const
|
|
228
|
-
...
|
|
229
|
-
count:
|
|
221
|
+
const B = Array.from(m.values()).map((h) => ({
|
|
222
|
+
...h[0],
|
|
223
|
+
count: h.length
|
|
230
224
|
}));
|
|
231
225
|
return /* @__PURE__ */ o("div", { style: { borderBottom: "1px solid #f0f0f0" }, children: [
|
|
232
226
|
/* @__PURE__ */ o(
|
|
233
227
|
"button",
|
|
234
228
|
{
|
|
235
229
|
type: "button",
|
|
236
|
-
onClick: () =>
|
|
230
|
+
onClick: () => ie(!X),
|
|
237
231
|
style: {
|
|
238
232
|
width: "100%",
|
|
239
233
|
display: "flex",
|
|
@@ -251,7 +245,7 @@ const ze = ({
|
|
|
251
245
|
children: [
|
|
252
246
|
/* @__PURE__ */ o("span", { children: [
|
|
253
247
|
"Existing Fields (",
|
|
254
|
-
|
|
248
|
+
B.length,
|
|
255
249
|
")"
|
|
256
250
|
] }),
|
|
257
251
|
/* @__PURE__ */ r(
|
|
@@ -264,7 +258,7 @@ const ze = ({
|
|
|
264
258
|
height: "8px",
|
|
265
259
|
borderRight: "2px solid #666",
|
|
266
260
|
borderBottom: "2px solid #666",
|
|
267
|
-
transform:
|
|
261
|
+
transform: X ? "rotate(45deg)" : "rotate(-45deg)",
|
|
268
262
|
transition: "transform 0.2s ease"
|
|
269
263
|
}
|
|
270
264
|
}
|
|
@@ -272,11 +266,11 @@ const ze = ({
|
|
|
272
266
|
]
|
|
273
267
|
}
|
|
274
268
|
),
|
|
275
|
-
|
|
269
|
+
X && /* @__PURE__ */ r("div", { style: { maxHeight: "300px", overflowY: "auto" }, children: B.map((h) => /* @__PURE__ */ o(
|
|
276
270
|
"div",
|
|
277
271
|
{
|
|
278
272
|
className: "field-menu-item",
|
|
279
|
-
onClick: () => T?.(
|
|
273
|
+
onClick: () => T?.(h),
|
|
280
274
|
style: {
|
|
281
275
|
padding: "8px 16px",
|
|
282
276
|
cursor: "pointer",
|
|
@@ -287,7 +281,7 @@ const ze = ({
|
|
|
287
281
|
},
|
|
288
282
|
children: [
|
|
289
283
|
/* @__PURE__ */ o("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
290
|
-
/* @__PURE__ */ r("div", { style: { fontWeight: 500, fontSize: "13px" }, children:
|
|
284
|
+
/* @__PURE__ */ r("div", { style: { fontWeight: 500, fontSize: "13px" }, children: h.alias || h.id }),
|
|
291
285
|
/* @__PURE__ */ r(
|
|
292
286
|
"div",
|
|
293
287
|
{
|
|
@@ -296,7 +290,7 @@ const ze = ({
|
|
|
296
290
|
color: "#9ca3af",
|
|
297
291
|
marginTop: "2px"
|
|
298
292
|
},
|
|
299
|
-
children:
|
|
293
|
+
children: h.group ? `group (${h.count} fields)` : `ID: ${h.id}`
|
|
300
294
|
}
|
|
301
295
|
)
|
|
302
296
|
] }),
|
|
@@ -312,16 +306,16 @@ const ze = ({
|
|
|
312
306
|
textTransform: "capitalize",
|
|
313
307
|
flexShrink: 0
|
|
314
308
|
},
|
|
315
|
-
children:
|
|
309
|
+
children: h.mode || "inline"
|
|
316
310
|
}
|
|
317
311
|
)
|
|
318
312
|
]
|
|
319
313
|
},
|
|
320
|
-
|
|
314
|
+
h.group || h.id
|
|
321
315
|
)) })
|
|
322
316
|
] });
|
|
323
317
|
})(),
|
|
324
|
-
|
|
318
|
+
O.length === 0 ? /* @__PURE__ */ r(
|
|
325
319
|
"div",
|
|
326
320
|
{
|
|
327
321
|
style: {
|
|
@@ -337,7 +331,7 @@ const ze = ({
|
|
|
337
331
|
"button",
|
|
338
332
|
{
|
|
339
333
|
type: "button",
|
|
340
|
-
onClick: () =>
|
|
334
|
+
onClick: () => z(!p),
|
|
341
335
|
style: {
|
|
342
336
|
width: "100%",
|
|
343
337
|
display: "flex",
|
|
@@ -355,7 +349,7 @@ const ze = ({
|
|
|
355
349
|
children: [
|
|
356
350
|
/* @__PURE__ */ o("span", { children: [
|
|
357
351
|
"Available Fields (",
|
|
358
|
-
|
|
352
|
+
O.length,
|
|
359
353
|
")"
|
|
360
354
|
] }),
|
|
361
355
|
/* @__PURE__ */ r(
|
|
@@ -368,7 +362,7 @@ const ze = ({
|
|
|
368
362
|
height: "8px",
|
|
369
363
|
borderRight: "2px solid #666",
|
|
370
364
|
borderBottom: "2px solid #666",
|
|
371
|
-
transform:
|
|
365
|
+
transform: p ? "rotate(45deg)" : "rotate(-45deg)",
|
|
372
366
|
transition: "transform 0.2s ease"
|
|
373
367
|
}
|
|
374
368
|
}
|
|
@@ -376,11 +370,11 @@ const ze = ({
|
|
|
376
370
|
]
|
|
377
371
|
}
|
|
378
372
|
),
|
|
379
|
-
|
|
373
|
+
p && /* @__PURE__ */ r("div", { style: { maxHeight: "300px", overflowY: "auto" }, children: O.map((m) => /* @__PURE__ */ o(
|
|
380
374
|
"div",
|
|
381
375
|
{
|
|
382
376
|
className: "field-menu-item",
|
|
383
|
-
onClick: () =>
|
|
377
|
+
onClick: () => N(m),
|
|
384
378
|
style: {
|
|
385
379
|
padding: "8px 16px",
|
|
386
380
|
cursor: "pointer",
|
|
@@ -391,7 +385,7 @@ const ze = ({
|
|
|
391
385
|
},
|
|
392
386
|
children: [
|
|
393
387
|
/* @__PURE__ */ o("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
394
|
-
/* @__PURE__ */ r("div", { style: { fontWeight: 500, fontSize: "13px" }, children:
|
|
388
|
+
/* @__PURE__ */ r("div", { style: { fontWeight: 500, fontSize: "13px" }, children: m.label || m.id }),
|
|
395
389
|
/* @__PURE__ */ o(
|
|
396
390
|
"div",
|
|
397
391
|
{
|
|
@@ -402,7 +396,7 @@ const ze = ({
|
|
|
402
396
|
},
|
|
403
397
|
children: [
|
|
404
398
|
"ID: ",
|
|
405
|
-
|
|
399
|
+
m.id
|
|
406
400
|
]
|
|
407
401
|
}
|
|
408
402
|
)
|
|
@@ -419,12 +413,12 @@ const ze = ({
|
|
|
419
413
|
textTransform: "capitalize",
|
|
420
414
|
flexShrink: 0
|
|
421
415
|
},
|
|
422
|
-
children:
|
|
416
|
+
children: m.mode || "inline"
|
|
423
417
|
}
|
|
424
418
|
)
|
|
425
419
|
]
|
|
426
420
|
},
|
|
427
|
-
|
|
421
|
+
m.id
|
|
428
422
|
)) })
|
|
429
423
|
] }),
|
|
430
424
|
/* @__PURE__ */ r(
|
|
@@ -452,36 +446,36 @@ const ze = ({
|
|
|
452
446
|
}
|
|
453
447
|
)
|
|
454
448
|
] });
|
|
455
|
-
},
|
|
456
|
-
const
|
|
457
|
-
return
|
|
458
|
-
},
|
|
449
|
+
}, He = (n) => {
|
|
450
|
+
const d = n.split("-");
|
|
451
|
+
return d.length > 2 ? d[d.length - 1].substring(0, 6) : n.substring(0, 6);
|
|
452
|
+
}, ye = ({ field: n, onSelect: d, onDelete: g, isSelected: l, isGrouped: u = !1 }) => /* @__PURE__ */ o(
|
|
459
453
|
"div",
|
|
460
454
|
{
|
|
461
|
-
onClick: () =>
|
|
455
|
+
onClick: () => d(n),
|
|
462
456
|
style: {
|
|
463
457
|
position: "relative",
|
|
464
458
|
padding: "10px 12px",
|
|
465
|
-
background:
|
|
466
|
-
border:
|
|
459
|
+
background: l ? "#eff6ff" : "#f9fafb",
|
|
460
|
+
border: l ? "1px solid #3b82f6" : "1px solid #e5e7eb",
|
|
467
461
|
borderRadius: "6px",
|
|
468
462
|
cursor: "pointer",
|
|
469
463
|
transition: "all 0.2s",
|
|
470
|
-
fontSize:
|
|
464
|
+
fontSize: u ? "13px" : "14px"
|
|
471
465
|
},
|
|
472
|
-
onMouseEnter: (
|
|
473
|
-
|
|
466
|
+
onMouseEnter: (a) => {
|
|
467
|
+
l || (a.currentTarget.style.background = "#f3f4f6");
|
|
474
468
|
},
|
|
475
|
-
onMouseLeave: (
|
|
476
|
-
|
|
469
|
+
onMouseLeave: (a) => {
|
|
470
|
+
l || (a.currentTarget.style.background = "#f9fafb");
|
|
477
471
|
},
|
|
478
472
|
title: n.alias,
|
|
479
473
|
children: [
|
|
480
474
|
/* @__PURE__ */ r(
|
|
481
475
|
"button",
|
|
482
476
|
{
|
|
483
|
-
onClick: (
|
|
484
|
-
|
|
477
|
+
onClick: (a) => {
|
|
478
|
+
a.stopPropagation(), g(n.id);
|
|
485
479
|
},
|
|
486
480
|
style: {
|
|
487
481
|
position: "absolute",
|
|
@@ -497,11 +491,11 @@ const ze = ({
|
|
|
497
491
|
alignItems: "center",
|
|
498
492
|
justifyContent: "center"
|
|
499
493
|
},
|
|
500
|
-
onMouseEnter: (
|
|
501
|
-
|
|
494
|
+
onMouseEnter: (a) => {
|
|
495
|
+
a.currentTarget.style.color = "#ef4444";
|
|
502
496
|
},
|
|
503
|
-
onMouseLeave: (
|
|
504
|
-
|
|
497
|
+
onMouseLeave: (a) => {
|
|
498
|
+
a.currentTarget.style.color = "#9ca3af";
|
|
505
499
|
},
|
|
506
500
|
title: "Delete field",
|
|
507
501
|
children: /* @__PURE__ */ r(
|
|
@@ -532,8 +526,8 @@ const ze = ({
|
|
|
532
526
|
{
|
|
533
527
|
style: {
|
|
534
528
|
fontWeight: "500",
|
|
535
|
-
fontSize:
|
|
536
|
-
color:
|
|
529
|
+
fontSize: u ? "12px" : "14px",
|
|
530
|
+
color: u ? "#6b7280" : "#111827"
|
|
537
531
|
},
|
|
538
532
|
children: n.alias || n.id
|
|
539
533
|
}
|
|
@@ -574,21 +568,21 @@ const ze = ({
|
|
|
574
568
|
] })
|
|
575
569
|
]
|
|
576
570
|
}
|
|
577
|
-
),
|
|
571
|
+
), Le = ({
|
|
578
572
|
fields: n,
|
|
579
|
-
onSelect:
|
|
580
|
-
onDelete:
|
|
581
|
-
selectedFieldId:
|
|
573
|
+
onSelect: d,
|
|
574
|
+
onDelete: g,
|
|
575
|
+
selectedFieldId: l
|
|
582
576
|
}) => {
|
|
583
|
-
const [
|
|
584
|
-
const
|
|
577
|
+
const [u, a] = I(/* @__PURE__ */ new Set()), { groupedFields: N, ungroupedFields: P } = Fe(() => {
|
|
578
|
+
const f = {}, T = [];
|
|
585
579
|
return n.forEach((x) => {
|
|
586
|
-
x.group ? (
|
|
587
|
-
}), { groupedFields:
|
|
588
|
-
}, [n]), G = (
|
|
589
|
-
|
|
580
|
+
x.group ? (f[x.group] || (f[x.group] = []), f[x.group].push(x)) : T.push(x);
|
|
581
|
+
}), { groupedFields: f, ungroupedFields: T };
|
|
582
|
+
}, [n]), G = (f) => {
|
|
583
|
+
a((T) => {
|
|
590
584
|
const x = new Set(T);
|
|
591
|
-
return x.has(
|
|
585
|
+
return x.has(f) ? x.delete(f) : x.add(f), x;
|
|
592
586
|
});
|
|
593
587
|
};
|
|
594
588
|
return /* @__PURE__ */ o(
|
|
@@ -624,18 +618,18 @@ const ze = ({
|
|
|
624
618
|
]
|
|
625
619
|
}
|
|
626
620
|
) : /* @__PURE__ */ o("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
|
|
627
|
-
P.map((
|
|
628
|
-
|
|
621
|
+
P.map((f) => /* @__PURE__ */ r(
|
|
622
|
+
ye,
|
|
629
623
|
{
|
|
630
|
-
field:
|
|
631
|
-
onSelect:
|
|
632
|
-
onDelete:
|
|
633
|
-
isSelected:
|
|
624
|
+
field: f,
|
|
625
|
+
onSelect: d,
|
|
626
|
+
onDelete: g,
|
|
627
|
+
isSelected: l === f.id
|
|
634
628
|
},
|
|
635
|
-
|
|
629
|
+
f.id
|
|
636
630
|
)),
|
|
637
|
-
Object.entries(
|
|
638
|
-
const x =
|
|
631
|
+
Object.entries(N).map(([f, T]) => {
|
|
632
|
+
const x = u.has(f), y = T[0];
|
|
639
633
|
return /* @__PURE__ */ o("div", { children: [
|
|
640
634
|
/* @__PURE__ */ r(
|
|
641
635
|
"div",
|
|
@@ -649,12 +643,12 @@ const ze = ({
|
|
|
649
643
|
cursor: "pointer",
|
|
650
644
|
transition: "all 0.2s"
|
|
651
645
|
},
|
|
652
|
-
onClick: () => G(
|
|
653
|
-
onMouseEnter: (
|
|
654
|
-
|
|
646
|
+
onClick: () => G(f),
|
|
647
|
+
onMouseEnter: (w) => {
|
|
648
|
+
w.currentTarget.style.background = "#f3f4f6";
|
|
655
649
|
},
|
|
656
|
-
onMouseLeave: (
|
|
657
|
-
|
|
650
|
+
onMouseLeave: (w) => {
|
|
651
|
+
w.currentTarget.style.background = "#f9fafb";
|
|
658
652
|
},
|
|
659
653
|
children: /* @__PURE__ */ o("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
660
654
|
/* @__PURE__ */ r("span", { style: { fontSize: "12px", color: "#6b7280" }, children: x ? "▼" : "▶" }),
|
|
@@ -670,7 +664,7 @@ const ze = ({
|
|
|
670
664
|
},
|
|
671
665
|
children: [
|
|
672
666
|
"group: ",
|
|
673
|
-
|
|
667
|
+
He(f),
|
|
674
668
|
" (",
|
|
675
669
|
T.length,
|
|
676
670
|
" fields)"
|
|
@@ -691,47 +685,47 @@ const ze = ({
|
|
|
691
685
|
flexDirection: "column",
|
|
692
686
|
gap: "4px"
|
|
693
687
|
},
|
|
694
|
-
children: T.map((
|
|
695
|
-
|
|
688
|
+
children: T.map((w) => /* @__PURE__ */ r(
|
|
689
|
+
ye,
|
|
696
690
|
{
|
|
697
|
-
field:
|
|
698
|
-
onSelect:
|
|
699
|
-
onDelete:
|
|
700
|
-
isSelected:
|
|
691
|
+
field: w,
|
|
692
|
+
onSelect: d,
|
|
693
|
+
onDelete: g,
|
|
694
|
+
isSelected: l === w.id,
|
|
701
695
|
isGrouped: !0
|
|
702
696
|
},
|
|
703
|
-
|
|
697
|
+
w.id
|
|
704
698
|
))
|
|
705
699
|
}
|
|
706
700
|
)
|
|
707
|
-
] },
|
|
701
|
+
] }, f);
|
|
708
702
|
})
|
|
709
703
|
] })
|
|
710
704
|
]
|
|
711
705
|
}
|
|
712
706
|
);
|
|
713
|
-
},
|
|
714
|
-
const
|
|
715
|
-
return
|
|
716
|
-
const
|
|
707
|
+
}, Q = (n) => {
|
|
708
|
+
const d = n.helpers?.structuredContentCommands;
|
|
709
|
+
return d?.getStructuredContentTags ? (d.getStructuredContentTags(n.state) || []).map((l) => {
|
|
710
|
+
const u = l?.node ?? l, a = u?.attrs ?? {}, P = (u?.type?.name || "").includes("Block") ? "block" : "inline";
|
|
717
711
|
return {
|
|
718
|
-
id:
|
|
719
|
-
alias:
|
|
720
|
-
tag:
|
|
712
|
+
id: a.id,
|
|
713
|
+
alias: a.alias || a.label || "",
|
|
714
|
+
tag: a.tag,
|
|
721
715
|
mode: P,
|
|
722
|
-
group:
|
|
716
|
+
group: d.getGroup?.(a.tag) ?? void 0
|
|
723
717
|
};
|
|
724
718
|
}) : [];
|
|
725
|
-
},
|
|
726
|
-
if (n ===
|
|
727
|
-
if (n.length !==
|
|
728
|
-
for (let
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
719
|
+
}, ve = (n, d) => {
|
|
720
|
+
if (n === d) return !0;
|
|
721
|
+
if (n.length !== d.length) return !1;
|
|
722
|
+
for (let g = 0; g < n.length; g += 1) {
|
|
723
|
+
const l = n[g], u = d[g];
|
|
724
|
+
if (!u || l.id !== u.id || l.alias !== u.alias || l.tag !== u.tag || l.position !== u.position || l.mode !== u.mode || l.group !== u.group)
|
|
731
725
|
return !1;
|
|
732
726
|
}
|
|
733
727
|
return !0;
|
|
734
|
-
},
|
|
728
|
+
}, Pe = (n) => {
|
|
735
729
|
if (!n) return null;
|
|
736
730
|
if (n === !0)
|
|
737
731
|
return {
|
|
@@ -745,47 +739,48 @@ const ze = ({
|
|
|
745
739
|
config: {},
|
|
746
740
|
renderDefaultContainer: !1
|
|
747
741
|
};
|
|
748
|
-
const { selector:
|
|
742
|
+
const { selector: d, ...g } = n;
|
|
749
743
|
return {
|
|
750
|
-
selector:
|
|
751
|
-
config:
|
|
752
|
-
renderDefaultContainer:
|
|
744
|
+
selector: d || "#superdoc-toolbar",
|
|
745
|
+
config: g,
|
|
746
|
+
renderDefaultContainer: d === void 0
|
|
753
747
|
};
|
|
754
|
-
},
|
|
755
|
-
const
|
|
748
|
+
}, re = 10, Ae = 250, Ve = 300, Ce = (n) => {
|
|
749
|
+
const d = window.innerWidth - Ae - re, g = window.innerHeight - Ve - re, l = Math.min(n.left, d), u = Math.min(n.top, g);
|
|
756
750
|
return new DOMRect(
|
|
757
|
-
Math.max(
|
|
758
|
-
Math.max(
|
|
751
|
+
Math.max(l, re),
|
|
752
|
+
Math.max(u, re),
|
|
759
753
|
n.width,
|
|
760
754
|
n.height
|
|
761
755
|
);
|
|
762
|
-
},
|
|
756
|
+
}, je = ze((n, d) => {
|
|
763
757
|
const {
|
|
764
|
-
document:
|
|
765
|
-
fields:
|
|
766
|
-
menu:
|
|
767
|
-
list:
|
|
768
|
-
toolbar:
|
|
758
|
+
document: g,
|
|
759
|
+
fields: l = {},
|
|
760
|
+
menu: u = {},
|
|
761
|
+
list: a = {},
|
|
762
|
+
toolbar: N,
|
|
769
763
|
onReady: P,
|
|
770
764
|
onTrigger: G,
|
|
771
|
-
onFieldInsert:
|
|
765
|
+
onFieldInsert: f,
|
|
772
766
|
onFieldUpdate: T,
|
|
773
767
|
onFieldDelete: x,
|
|
774
768
|
onFieldsChange: y,
|
|
775
|
-
onFieldSelect:
|
|
776
|
-
onFieldCreate:
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
769
|
+
onFieldSelect: w,
|
|
770
|
+
onFieldCreate: R,
|
|
771
|
+
onExport: q,
|
|
772
|
+
className: A,
|
|
773
|
+
style: X,
|
|
774
|
+
documentHeight: ie = "600px"
|
|
775
|
+
} = n, [p, z] = I(l.initial || []), [V, O] = I(null), [j, D] = I(!1), [m, B] = I(), [h, Y] = I(""), [ee, we] = I(
|
|
776
|
+
() => l.available || []
|
|
777
|
+
), se = J(null), F = J(null), M = J(null), pe = J(l);
|
|
778
|
+
pe.current = l;
|
|
779
|
+
const W = J(null), fe = J(j);
|
|
780
|
+
oe(() => {
|
|
781
|
+
fe.current = j;
|
|
782
|
+
}, [j]);
|
|
783
|
+
const te = u.trigger || "{{", le = pe.current.available || [], ge = S(
|
|
789
784
|
(e) => {
|
|
790
785
|
const t = e.trim().toLowerCase();
|
|
791
786
|
return t ? le.filter((i) => i.label.toLowerCase().includes(t)) : le;
|
|
@@ -793,15 +788,15 @@ const ze = ({
|
|
|
793
788
|
[le]
|
|
794
789
|
), de = S(
|
|
795
790
|
(e) => {
|
|
796
|
-
|
|
791
|
+
Y(e), we(ge(e));
|
|
797
792
|
},
|
|
798
|
-
[
|
|
799
|
-
),
|
|
793
|
+
[ge]
|
|
794
|
+
), H = S(() => {
|
|
800
795
|
de("");
|
|
801
|
-
}, [de]),
|
|
796
|
+
}, [de]), K = S(
|
|
802
797
|
(e, t) => {
|
|
803
|
-
if (!
|
|
804
|
-
const i =
|
|
798
|
+
if (!F.current?.activeEditor) return !1;
|
|
799
|
+
const i = F.current.activeEditor, v = p, b = e === "inline" ? i.commands.insertStructuredContentInline?.({
|
|
805
800
|
attrs: {
|
|
806
801
|
alias: t.alias,
|
|
807
802
|
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
@@ -814,335 +809,304 @@ const ze = ({
|
|
|
814
809
|
},
|
|
815
810
|
text: t.defaultValue || t.alias
|
|
816
811
|
});
|
|
817
|
-
if (
|
|
818
|
-
const
|
|
819
|
-
z(
|
|
820
|
-
const E =
|
|
821
|
-
(
|
|
812
|
+
if (b) {
|
|
813
|
+
const c = Q(i);
|
|
814
|
+
z(c), y?.(c);
|
|
815
|
+
const E = c.find(
|
|
816
|
+
(C) => !v.some((s) => s.id === C.id)
|
|
822
817
|
);
|
|
823
|
-
E &&
|
|
818
|
+
E && f?.(E);
|
|
824
819
|
}
|
|
825
|
-
return
|
|
820
|
+
return b;
|
|
826
821
|
},
|
|
827
|
-
[
|
|
828
|
-
),
|
|
822
|
+
[f, y, p]
|
|
823
|
+
), Z = S(
|
|
829
824
|
(e, t) => {
|
|
830
|
-
if (!
|
|
831
|
-
const v =
|
|
825
|
+
if (!F.current?.activeEditor) return !1;
|
|
826
|
+
const v = F.current.activeEditor.commands.updateStructuredContentById?.(e, {
|
|
832
827
|
attrs: t
|
|
833
828
|
});
|
|
834
|
-
return v && z((
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
);
|
|
838
|
-
|
|
839
|
-
const E = m.find((c) => c.id === e);
|
|
840
|
-
return E && T?.(E), m;
|
|
829
|
+
return v && z((b) => {
|
|
830
|
+
const c = b.map((C) => C.id === e ? { ...C, ...t } : C);
|
|
831
|
+
y?.(c);
|
|
832
|
+
const E = c.find((C) => C.id === e);
|
|
833
|
+
return E && T?.(E), c;
|
|
841
834
|
}), v;
|
|
842
835
|
},
|
|
843
836
|
[T, y]
|
|
844
837
|
), ae = S(
|
|
845
838
|
(e) => {
|
|
846
|
-
const t =
|
|
839
|
+
const t = F.current?.activeEditor;
|
|
847
840
|
if (!t) {
|
|
848
|
-
let
|
|
841
|
+
let s = !1;
|
|
849
842
|
return z((k) => {
|
|
850
|
-
if (!k.some((
|
|
851
|
-
const
|
|
852
|
-
return
|
|
853
|
-
}),
|
|
843
|
+
if (!k.some((L) => L.id === e)) return k;
|
|
844
|
+
const U = k.filter((L) => L.id !== e);
|
|
845
|
+
return s = !0, y?.(U), U;
|
|
846
|
+
}), s && (x?.(e), O((k) => k === e ? null : k)), s;
|
|
854
847
|
}
|
|
855
|
-
const v =
|
|
856
|
-
let
|
|
848
|
+
const v = p.find((s) => s.id === e)?.group;
|
|
849
|
+
let b = !1;
|
|
857
850
|
try {
|
|
858
|
-
|
|
851
|
+
b = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
859
852
|
} catch {
|
|
860
|
-
|
|
853
|
+
b = !1;
|
|
861
854
|
}
|
|
862
|
-
let
|
|
863
|
-
const E =
|
|
864
|
-
if (!
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
if (f.length === 1) {
|
|
869
|
-
const k = f[0];
|
|
855
|
+
let c = Q(t);
|
|
856
|
+
const E = c.some((s) => s.id === e);
|
|
857
|
+
if (!b && E && (c = c.filter((s) => s.id !== e)), v) {
|
|
858
|
+
const s = c.filter((k) => k.group === v);
|
|
859
|
+
if (s.length === 1) {
|
|
860
|
+
const k = s[0];
|
|
870
861
|
t.commands.updateStructuredContentById?.(k.id, {
|
|
871
862
|
attrs: { tag: void 0 }
|
|
872
|
-
}),
|
|
863
|
+
}), c = Q(t);
|
|
873
864
|
}
|
|
874
865
|
}
|
|
875
|
-
let
|
|
876
|
-
return z((
|
|
877
|
-
if (
|
|
878
|
-
return
|
|
879
|
-
const k =
|
|
880
|
-
return k &&
|
|
881
|
-
}),
|
|
866
|
+
let C = !1;
|
|
867
|
+
return z((s) => {
|
|
868
|
+
if (ve(s, c))
|
|
869
|
+
return s;
|
|
870
|
+
const k = s.some((L) => L.id === e), U = c.some((L) => L.id === e);
|
|
871
|
+
return k && !U && (C = !0), y?.(c), c;
|
|
872
|
+
}), C && (x?.(e), O((s) => s === e ? null : s)), b || C;
|
|
882
873
|
},
|
|
883
|
-
[x, y,
|
|
884
|
-
),
|
|
874
|
+
[x, y, p]
|
|
875
|
+
), _ = S(
|
|
885
876
|
(e) => {
|
|
886
|
-
if (!
|
|
887
|
-
|
|
888
|
-
const i =
|
|
889
|
-
i &&
|
|
877
|
+
if (!F.current?.activeEditor) return;
|
|
878
|
+
F.current.activeEditor.commands.selectStructuredContentById?.(e), O(e);
|
|
879
|
+
const i = p.find((v) => v.id === e);
|
|
880
|
+
i && w?.(i);
|
|
890
881
|
},
|
|
891
|
-
[
|
|
882
|
+
[p, w]
|
|
892
883
|
), ce = S(
|
|
893
884
|
(e) => {
|
|
894
885
|
if (!e) return;
|
|
895
|
-
const t =
|
|
896
|
-
z((i) =>
|
|
886
|
+
const t = Q(e);
|
|
887
|
+
z((i) => ve(i, t) ? i : (y?.(t), t));
|
|
897
888
|
},
|
|
898
889
|
[y]
|
|
899
890
|
);
|
|
900
|
-
|
|
891
|
+
oe(() => se.current ? ((async () => {
|
|
901
892
|
const { SuperDoc: t } = await import("superdoc"), i = {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const { state: E } = m, { from: c } = E.selection;
|
|
910
|
-
if (c >= re.length) {
|
|
911
|
-
const R = c - re.length;
|
|
912
|
-
if (E.doc.textBetween(R, c) === re) {
|
|
913
|
-
const me = m.view.coordsAtPos(c), xe = ve(
|
|
914
|
-
new DOMRect(me.left, me.top, 0, 0)
|
|
915
|
-
), he = () => {
|
|
916
|
-
const oe = w.current?.activeEditor;
|
|
917
|
-
if (!oe) return;
|
|
918
|
-
const Me = oe.state.selection.from, De = oe.state.tr.delete(R, Me);
|
|
919
|
-
oe.view.dispatch(De);
|
|
920
|
-
};
|
|
921
|
-
D.current = he, H.current = c, h(xe), M(!0), L(), G?.({
|
|
922
|
-
position: { from: R, to: c },
|
|
923
|
-
bounds: xe,
|
|
924
|
-
cleanup: he
|
|
925
|
-
});
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
if (!pe.current)
|
|
930
|
-
return;
|
|
931
|
-
if (H.current == null) {
|
|
932
|
-
M(!1), L();
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
if (c < H.current) {
|
|
936
|
-
M(!1), H.current = null, L();
|
|
937
|
-
return;
|
|
938
|
-
}
|
|
939
|
-
const f = E.doc.textBetween(
|
|
940
|
-
H.current,
|
|
941
|
-
c
|
|
942
|
-
);
|
|
943
|
-
de(f);
|
|
944
|
-
const k = m.view.coordsAtPos(c), $ = ve(
|
|
945
|
-
new DOMRect(k.left, k.top, 0, 0)
|
|
946
|
-
);
|
|
947
|
-
h($);
|
|
948
|
-
}), C.on("update", () => {
|
|
949
|
-
ce(C);
|
|
950
|
-
}), ce(C);
|
|
893
|
+
comments: !1,
|
|
894
|
+
...$ && {
|
|
895
|
+
toolbar: {
|
|
896
|
+
selector: $.selector,
|
|
897
|
+
toolbarGroups: $.config.toolbarGroups || ["center"],
|
|
898
|
+
excludeItems: $.config.excludeItems || [],
|
|
899
|
+
...$.config
|
|
951
900
|
}
|
|
952
|
-
P?.();
|
|
953
901
|
}
|
|
954
|
-
}, v =
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
902
|
+
}, v = () => {
|
|
903
|
+
if (b.activeEditor) {
|
|
904
|
+
const c = b.activeEditor;
|
|
905
|
+
c.on("update", ({ editor: E }) => {
|
|
906
|
+
const { state: C } = E, { from: s } = C.selection;
|
|
907
|
+
if (s >= te.length) {
|
|
908
|
+
const ue = s - te.length;
|
|
909
|
+
if (C.doc.textBetween(ue, s) === te) {
|
|
910
|
+
const me = E.view.coordsAtPos(s), he = Ce(new DOMRect(me.left, me.top, 0, 0)), be = () => {
|
|
911
|
+
const ne = F.current?.activeEditor;
|
|
912
|
+
if (!ne) return;
|
|
913
|
+
const De = ne.state.selection.from, Ne = ne.state.tr.delete(ue, De);
|
|
914
|
+
ne.view.dispatch(Ne);
|
|
915
|
+
};
|
|
916
|
+
M.current = be, W.current = s, B(he), D(!0), H(), G?.({
|
|
917
|
+
position: { from: ue, to: s },
|
|
918
|
+
bounds: he,
|
|
919
|
+
cleanup: be
|
|
920
|
+
});
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
966
923
|
}
|
|
967
|
-
|
|
924
|
+
if (!fe.current)
|
|
925
|
+
return;
|
|
926
|
+
if (W.current == null) {
|
|
927
|
+
D(!1), H();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
if (s < W.current) {
|
|
931
|
+
D(!1), W.current = null, H();
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const k = C.doc.textBetween(W.current, s);
|
|
935
|
+
de(k);
|
|
936
|
+
const U = E.view.coordsAtPos(s), L = Ce(new DOMRect(U.left, U.top, 0, 0));
|
|
937
|
+
B(L);
|
|
938
|
+
}), c.on("update", () => {
|
|
939
|
+
ce(c);
|
|
940
|
+
}), ce(c);
|
|
968
941
|
}
|
|
942
|
+
P?.();
|
|
943
|
+
}, b = new t({
|
|
944
|
+
selector: se.current,
|
|
945
|
+
document: g?.source,
|
|
946
|
+
documentMode: g?.mode || "editing",
|
|
947
|
+
modules: i,
|
|
948
|
+
toolbar: $?.selector,
|
|
949
|
+
onReady: v
|
|
969
950
|
});
|
|
970
|
-
|
|
951
|
+
F.current = b;
|
|
971
952
|
})(), () => {
|
|
972
|
-
|
|
973
|
-
const t =
|
|
974
|
-
t && typeof t.destroy == "function" && t.destroy(),
|
|
975
|
-
}) : void 0, [
|
|
976
|
-
|
|
977
|
-
u?.mode,
|
|
978
|
-
re,
|
|
979
|
-
ce,
|
|
980
|
-
P,
|
|
981
|
-
G,
|
|
982
|
-
B
|
|
983
|
-
]);
|
|
984
|
-
const Fe = S(
|
|
953
|
+
M.current = null, W.current = null;
|
|
954
|
+
const t = F.current;
|
|
955
|
+
t && typeof t.destroy == "function" && t.destroy(), F.current = null;
|
|
956
|
+
}) : void 0, [g?.source, g?.mode, te, ce, P, G, N]);
|
|
957
|
+
const ke = S(
|
|
985
958
|
async (e) => {
|
|
986
|
-
|
|
987
|
-
const t = e.
|
|
988
|
-
if (e.id.startsWith("custom_") &&
|
|
989
|
-
const i = await
|
|
959
|
+
M.current && (M.current(), M.current = null), W.current = null, H();
|
|
960
|
+
const t = e.mode || "inline";
|
|
961
|
+
if (e.id.startsWith("custom_") && R) {
|
|
962
|
+
const i = await R(e);
|
|
990
963
|
if (i) {
|
|
991
|
-
const v = i.
|
|
992
|
-
|
|
964
|
+
const v = i.mode || t;
|
|
965
|
+
K(v, {
|
|
993
966
|
alias: i.label,
|
|
994
967
|
metadata: i.metadata,
|
|
995
968
|
defaultValue: i.defaultValue
|
|
996
|
-
}),
|
|
969
|
+
}), D(!1);
|
|
997
970
|
return;
|
|
998
971
|
}
|
|
999
972
|
}
|
|
1000
|
-
|
|
973
|
+
K(t, {
|
|
1001
974
|
alias: e.label,
|
|
1002
975
|
metadata: e.metadata,
|
|
1003
976
|
defaultValue: e.defaultValue
|
|
1004
|
-
}),
|
|
977
|
+
}), D(!1);
|
|
1005
978
|
},
|
|
1006
|
-
[
|
|
1007
|
-
),
|
|
979
|
+
[K, R, H]
|
|
980
|
+
), Se = S(
|
|
1008
981
|
(e) => {
|
|
1009
|
-
|
|
1010
|
-
const t =
|
|
982
|
+
M.current && (M.current(), M.current = null), W.current = null, H();
|
|
983
|
+
const t = F.current?.activeEditor;
|
|
1011
984
|
if (!t) return;
|
|
1012
985
|
const i = t.helpers?.structuredContentCommands;
|
|
1013
986
|
if (!i) return;
|
|
1014
|
-
const v = e.group || `group-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`,
|
|
987
|
+
const v = e.group || `group-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`, b = i.createTagObject?.({
|
|
1015
988
|
group: v
|
|
1016
989
|
});
|
|
1017
990
|
if ((e.mode || "inline") === "inline" ? t.commands.insertStructuredContentInline?.({
|
|
1018
991
|
attrs: {
|
|
1019
992
|
alias: e.alias,
|
|
1020
|
-
tag:
|
|
993
|
+
tag: b
|
|
1021
994
|
},
|
|
1022
995
|
text: e.alias
|
|
1023
996
|
}) : t.commands.insertStructuredContentBlock?.({
|
|
1024
997
|
attrs: {
|
|
1025
998
|
alias: e.alias,
|
|
1026
|
-
tag:
|
|
999
|
+
tag: b
|
|
1027
1000
|
},
|
|
1028
1001
|
text: e.alias
|
|
1029
1002
|
})) {
|
|
1030
|
-
e.group ||
|
|
1031
|
-
const
|
|
1032
|
-
z(
|
|
1003
|
+
e.group || Z(e.id, { tag: b }), D(!1);
|
|
1004
|
+
const C = Q(t);
|
|
1005
|
+
z(C), y?.(C);
|
|
1033
1006
|
}
|
|
1034
1007
|
},
|
|
1035
|
-
[
|
|
1036
|
-
),
|
|
1037
|
-
|
|
1038
|
-
}, [
|
|
1039
|
-
if (!
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
return;
|
|
1048
|
-
const e = g.findIndex(
|
|
1049
|
-
(i) => i.id === W
|
|
1050
|
-
), t = e > 0 ? e - 1 : g.length - 1;
|
|
1051
|
-
O(g[t].id);
|
|
1052
|
-
}, [g, W, O]), Ee = S(
|
|
1008
|
+
[Z, H, y]
|
|
1009
|
+
), Te = S(() => {
|
|
1010
|
+
D(!1), W.current = null, H(), M.current && (M.current(), M.current = null);
|
|
1011
|
+
}, [H]), Ee = S(() => {
|
|
1012
|
+
if (!F.current?.activeEditor || p.length === 0) return;
|
|
1013
|
+
const e = p.findIndex((i) => i.id === V), t = e >= 0 ? (e + 1) % p.length : 0;
|
|
1014
|
+
_(p[t].id);
|
|
1015
|
+
}, [p, V, _]), Ie = S(() => {
|
|
1016
|
+
if (!F.current?.activeEditor || p.length === 0) return;
|
|
1017
|
+
const e = p.findIndex((i) => i.id === V), t = e > 0 ? e - 1 : p.length - 1;
|
|
1018
|
+
_(p[t].id);
|
|
1019
|
+
}, [p, V, _]), Me = S(
|
|
1053
1020
|
async (e) => {
|
|
1054
|
-
const { fileName: t = "document", triggerDownload: i = !0 } = e || {}
|
|
1055
|
-
return await w.current?.export({
|
|
1021
|
+
const { fileName: t = "document", triggerDownload: i = !0 } = e || {}, v = await F.current?.export({
|
|
1056
1022
|
exportType: ["docx"],
|
|
1057
1023
|
exportedName: t,
|
|
1058
1024
|
triggerDownload: i
|
|
1059
|
-
});
|
|
1025
|
+
}), b = F.current?.activeEditor;
|
|
1026
|
+
if (b) {
|
|
1027
|
+
const c = Q(b);
|
|
1028
|
+
q?.({ fields: c, blob: i ? void 0 : v, fileName: t });
|
|
1029
|
+
}
|
|
1030
|
+
return v;
|
|
1060
1031
|
},
|
|
1061
|
-
[]
|
|
1032
|
+
[q]
|
|
1062
1033
|
);
|
|
1063
|
-
|
|
1064
|
-
insertField: (e) =>
|
|
1065
|
-
insertBlockField: (e) =>
|
|
1066
|
-
updateField:
|
|
1034
|
+
Be(d, () => ({
|
|
1035
|
+
insertField: (e) => K("inline", e),
|
|
1036
|
+
insertBlockField: (e) => K("block", e),
|
|
1037
|
+
updateField: Z,
|
|
1067
1038
|
deleteField: ae,
|
|
1068
|
-
selectField:
|
|
1069
|
-
nextField:
|
|
1070
|
-
previousField:
|
|
1071
|
-
getFields: () =>
|
|
1072
|
-
exportTemplate:
|
|
1073
|
-
getSuperDoc: () =>
|
|
1039
|
+
selectField: _,
|
|
1040
|
+
nextField: Ee,
|
|
1041
|
+
previousField: Ie,
|
|
1042
|
+
getFields: () => p,
|
|
1043
|
+
exportTemplate: Me,
|
|
1044
|
+
getSuperDoc: () => F.current
|
|
1074
1045
|
}));
|
|
1075
|
-
const
|
|
1076
|
-
return /* @__PURE__ */ o(
|
|
1077
|
-
"div",
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
id: "superdoc-toolbar",
|
|
1098
|
-
className: "superdoc-template-builder-toolbar",
|
|
1099
|
-
"data-testid": "template-builder-toolbar"
|
|
1100
|
-
}
|
|
1101
|
-
),
|
|
1102
|
-
/* @__PURE__ */ r(
|
|
1103
|
-
"div",
|
|
1104
|
-
{
|
|
1105
|
-
ref: ne,
|
|
1106
|
-
className: "superdoc-template-builder-editor",
|
|
1107
|
-
style: { height: J },
|
|
1108
|
-
"data-testid": "template-builder-editor"
|
|
1109
|
-
}
|
|
1110
|
-
)
|
|
1111
|
-
] }),
|
|
1112
|
-
d.position === "right" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1113
|
-
ge,
|
|
1114
|
-
{
|
|
1115
|
-
fields: g,
|
|
1116
|
-
onSelect: (e) => O(e.id),
|
|
1117
|
-
onDelete: ae,
|
|
1118
|
-
onUpdate: (e) => K(e.id, e),
|
|
1119
|
-
selectedFieldId: W || void 0
|
|
1120
|
-
}
|
|
1121
|
-
) })
|
|
1122
|
-
] }),
|
|
1046
|
+
const Re = u.component || We, xe = a.component || Le, $ = Pe(N);
|
|
1047
|
+
return /* @__PURE__ */ o("div", { className: `superdoc-template-builder ${A || ""}`, style: X, children: [
|
|
1048
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1049
|
+
a.position === "left" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1050
|
+
xe,
|
|
1051
|
+
{
|
|
1052
|
+
fields: p,
|
|
1053
|
+
onSelect: (e) => _(e.id),
|
|
1054
|
+
onDelete: ae,
|
|
1055
|
+
onUpdate: (e) => Z(e.id, e),
|
|
1056
|
+
selectedFieldId: V || void 0
|
|
1057
|
+
}
|
|
1058
|
+
) }),
|
|
1059
|
+
/* @__PURE__ */ o("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1060
|
+
$?.renderDefaultContainer && /* @__PURE__ */ r(
|
|
1061
|
+
"div",
|
|
1062
|
+
{
|
|
1063
|
+
id: "superdoc-toolbar",
|
|
1064
|
+
className: "superdoc-template-builder-toolbar",
|
|
1065
|
+
"data-testid": "template-builder-toolbar"
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1123
1068
|
/* @__PURE__ */ r(
|
|
1124
|
-
|
|
1069
|
+
"div",
|
|
1125
1070
|
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
filterQuery: j,
|
|
1131
|
-
allowCreate: s.allowCreate || !1,
|
|
1132
|
-
onSelect: Fe,
|
|
1133
|
-
onClose: ke,
|
|
1134
|
-
onCreateField: N,
|
|
1135
|
-
existingFields: g,
|
|
1136
|
-
onSelectExisting: we
|
|
1071
|
+
ref: se,
|
|
1072
|
+
className: "superdoc-template-builder-editor",
|
|
1073
|
+
style: { height: ie },
|
|
1074
|
+
"data-testid": "template-builder-editor"
|
|
1137
1075
|
}
|
|
1138
1076
|
)
|
|
1139
|
-
]
|
|
1140
|
-
|
|
1141
|
-
|
|
1077
|
+
] }),
|
|
1078
|
+
a.position === "right" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1079
|
+
xe,
|
|
1080
|
+
{
|
|
1081
|
+
fields: p,
|
|
1082
|
+
onSelect: (e) => _(e.id),
|
|
1083
|
+
onDelete: ae,
|
|
1084
|
+
onUpdate: (e) => Z(e.id, e),
|
|
1085
|
+
selectedFieldId: V || void 0
|
|
1086
|
+
}
|
|
1087
|
+
) })
|
|
1088
|
+
] }),
|
|
1089
|
+
/* @__PURE__ */ r(
|
|
1090
|
+
Re,
|
|
1091
|
+
{
|
|
1092
|
+
isVisible: j,
|
|
1093
|
+
position: m,
|
|
1094
|
+
availableFields: l.available || [],
|
|
1095
|
+
filteredFields: ee,
|
|
1096
|
+
filterQuery: h,
|
|
1097
|
+
allowCreate: l.allowCreate || !1,
|
|
1098
|
+
onSelect: ke,
|
|
1099
|
+
onClose: Te,
|
|
1100
|
+
onCreateField: R,
|
|
1101
|
+
existingFields: p,
|
|
1102
|
+
onSelectExisting: Se
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1105
|
+
] });
|
|
1142
1106
|
});
|
|
1143
|
-
|
|
1107
|
+
je.displayName = "SuperDocTemplateBuilder";
|
|
1144
1108
|
export {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1109
|
+
Le as FieldList,
|
|
1110
|
+
We as FieldMenu,
|
|
1111
|
+
je as default
|
|
1148
1112
|
};
|