@superdoc-dev/template-builder 0.2.0-next.4 → 0.2.0-next.6
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 +56 -4
- package/dist/defaults/FieldList.d.ts.map +1 -1
- package/dist/defaults/FieldMenu.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -22
- package/dist/index.mjs +484 -674
- package/dist/types.d.ts +19 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/index.mjs
CHANGED
|
@@ -1,301 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/
|
|
12
|
-
var Ee;
|
|
13
|
-
function De() {
|
|
14
|
-
if (Ee) return se;
|
|
15
|
-
Ee = 1;
|
|
16
|
-
var a = Symbol.for("react.transitional.element"), x = Symbol.for("react.fragment");
|
|
17
|
-
function m(c, n, i) {
|
|
18
|
-
var F = null;
|
|
19
|
-
if (i !== void 0 && (F = "" + i), n.key !== void 0 && (F = "" + n.key), "key" in n) {
|
|
20
|
-
i = {};
|
|
21
|
-
for (var D in n)
|
|
22
|
-
D !== "key" && (i[D] = n[D]);
|
|
23
|
-
} else i = n;
|
|
24
|
-
return n = i.ref, {
|
|
25
|
-
$$typeof: a,
|
|
26
|
-
type: c,
|
|
27
|
-
key: F,
|
|
28
|
-
ref: n !== void 0 ? n : null,
|
|
29
|
-
props: i
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return se.Fragment = x, se.jsx = m, se.jsxs = m, se;
|
|
33
|
-
}
|
|
34
|
-
var ae = {};
|
|
35
|
-
/**
|
|
36
|
-
* @license React
|
|
37
|
-
* react-jsx-runtime.development.js
|
|
38
|
-
*
|
|
39
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
-
*
|
|
41
|
-
* This source code is licensed under the MIT license found in the
|
|
42
|
-
* LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/
|
|
44
|
-
var Re;
|
|
45
|
-
function Le() {
|
|
46
|
-
return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
|
-
function a(e) {
|
|
48
|
-
if (e == null) return null;
|
|
49
|
-
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof === fe ? null : e.displayName || e.name || null;
|
|
51
|
-
if (typeof e == "string") return e;
|
|
52
|
-
switch (e) {
|
|
53
|
-
case O:
|
|
54
|
-
return "Fragment";
|
|
55
|
-
case y:
|
|
56
|
-
return "Profiler";
|
|
57
|
-
case ee:
|
|
58
|
-
return "StrictMode";
|
|
59
|
-
case g:
|
|
60
|
-
return "Suspense";
|
|
61
|
-
case v:
|
|
62
|
-
return "SuspenseList";
|
|
63
|
-
case W:
|
|
64
|
-
return "Activity";
|
|
65
|
-
}
|
|
66
|
-
if (typeof e == "object")
|
|
67
|
-
switch (typeof e.tag == "number" && console.error(
|
|
68
|
-
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
-
), e.$$typeof) {
|
|
70
|
-
case J:
|
|
71
|
-
return "Portal";
|
|
72
|
-
case A:
|
|
73
|
-
return e.displayName || "Context";
|
|
74
|
-
case $:
|
|
75
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case l:
|
|
77
|
-
var s = e.render;
|
|
78
|
-
return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case T:
|
|
80
|
-
return s = e.displayName || null, s !== null ? s : a(e.type) || "Memo";
|
|
81
|
-
case k:
|
|
82
|
-
s = e._payload, e = e._init;
|
|
83
|
-
try {
|
|
84
|
-
return a(e(s));
|
|
85
|
-
} catch {
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
function x(e) {
|
|
91
|
-
return "" + e;
|
|
92
|
-
}
|
|
93
|
-
function m(e) {
|
|
94
|
-
try {
|
|
95
|
-
x(e);
|
|
96
|
-
var s = !1;
|
|
97
|
-
} catch {
|
|
98
|
-
s = !0;
|
|
99
|
-
}
|
|
100
|
-
if (s) {
|
|
101
|
-
s = console;
|
|
102
|
-
var u = s.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
-
return u.call(
|
|
104
|
-
s,
|
|
105
|
-
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
d
|
|
107
|
-
), x(e);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function c(e) {
|
|
111
|
-
if (e === O) return "<>";
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof === k)
|
|
113
|
-
return "<...>";
|
|
114
|
-
try {
|
|
115
|
-
var s = a(e);
|
|
116
|
-
return s ? "<" + s + ">" : "<...>";
|
|
117
|
-
} catch {
|
|
118
|
-
return "<...>";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function n() {
|
|
122
|
-
var e = te.A;
|
|
123
|
-
return e === null ? null : e.getOwner();
|
|
124
|
-
}
|
|
125
|
-
function i() {
|
|
126
|
-
return Error("react-stack-top-frame");
|
|
127
|
-
}
|
|
128
|
-
function F(e) {
|
|
129
|
-
if (ie.call(e, "key")) {
|
|
130
|
-
var s = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
-
if (s && s.isReactWarning) return !1;
|
|
132
|
-
}
|
|
133
|
-
return e.key !== void 0;
|
|
134
|
-
}
|
|
135
|
-
function D(e, s) {
|
|
136
|
-
function u() {
|
|
137
|
-
M || (M = !0, console.error(
|
|
138
|
-
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
-
s
|
|
140
|
-
));
|
|
141
|
-
}
|
|
142
|
-
u.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
-
get: u,
|
|
144
|
-
configurable: !0
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function H() {
|
|
148
|
-
var e = a(this.type);
|
|
149
|
-
return ne[e] || (ne[e] = !0, console.error(
|
|
150
|
-
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
-
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
-
}
|
|
153
|
-
function G(e, s, u, d, B, X) {
|
|
154
|
-
var h = u.ref;
|
|
155
|
-
return e = {
|
|
156
|
-
$$typeof: L,
|
|
157
|
-
type: e,
|
|
158
|
-
key: s,
|
|
159
|
-
props: u,
|
|
160
|
-
_owner: d
|
|
161
|
-
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(e, "ref", {
|
|
162
|
-
enumerable: !1,
|
|
163
|
-
get: H
|
|
164
|
-
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
165
|
-
configurable: !1,
|
|
166
|
-
enumerable: !1,
|
|
167
|
-
writable: !0,
|
|
168
|
-
value: 0
|
|
169
|
-
}), Object.defineProperty(e, "_debugInfo", {
|
|
170
|
-
configurable: !1,
|
|
171
|
-
enumerable: !1,
|
|
172
|
-
writable: !0,
|
|
173
|
-
value: null
|
|
174
|
-
}), Object.defineProperty(e, "_debugStack", {
|
|
175
|
-
configurable: !1,
|
|
176
|
-
enumerable: !1,
|
|
177
|
-
writable: !0,
|
|
178
|
-
value: B
|
|
179
|
-
}), Object.defineProperty(e, "_debugTask", {
|
|
180
|
-
configurable: !1,
|
|
181
|
-
enumerable: !1,
|
|
182
|
-
writable: !0,
|
|
183
|
-
value: X
|
|
184
|
-
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
185
|
-
}
|
|
186
|
-
function P(e, s, u, d, B, X) {
|
|
187
|
-
var h = s.children;
|
|
188
|
-
if (h !== void 0)
|
|
189
|
-
if (d)
|
|
190
|
-
if (re(h)) {
|
|
191
|
-
for (d = 0; d < h.length; d++)
|
|
192
|
-
N(h[d]);
|
|
193
|
-
Object.freeze && Object.freeze(h);
|
|
194
|
-
} else
|
|
195
|
-
console.error(
|
|
196
|
-
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
-
);
|
|
198
|
-
else N(h);
|
|
199
|
-
if (ie.call(s, "key")) {
|
|
200
|
-
h = a(e);
|
|
201
|
-
var j = Object.keys(s).filter(function(pe) {
|
|
202
|
-
return pe !== "key";
|
|
203
|
-
});
|
|
204
|
-
d = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", q[h + d] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
-
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
-
let props = %s;
|
|
207
|
-
<%s {...props} />
|
|
208
|
-
React keys must be passed directly to JSX without using spread:
|
|
209
|
-
let props = %s;
|
|
210
|
-
<%s key={someKey} {...props} />`,
|
|
211
|
-
d,
|
|
212
|
-
h,
|
|
213
|
-
j,
|
|
214
|
-
h
|
|
215
|
-
), q[h + d] = !0);
|
|
216
|
-
}
|
|
217
|
-
if (h = null, u !== void 0 && (m(u), h = "" + u), F(s) && (m(s.key), h = "" + s.key), "key" in s) {
|
|
218
|
-
u = {};
|
|
219
|
-
for (var Q in s)
|
|
220
|
-
Q !== "key" && (u[Q] = s[Q]);
|
|
221
|
-
} else u = s;
|
|
222
|
-
return h && D(
|
|
223
|
-
u,
|
|
224
|
-
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
225
|
-
), G(
|
|
226
|
-
e,
|
|
227
|
-
h,
|
|
228
|
-
u,
|
|
229
|
-
n(),
|
|
230
|
-
B,
|
|
231
|
-
X
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
function N(e) {
|
|
235
|
-
R(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? R(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
236
|
-
}
|
|
237
|
-
function R(e) {
|
|
238
|
-
return typeof e == "object" && e !== null && e.$$typeof === L;
|
|
239
|
-
}
|
|
240
|
-
var Y = Ae, L = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), ee = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), $ = Symbol.for("react.consumer"), A = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), W = Symbol.for("react.activity"), fe = Symbol.for("react.client.reference"), te = Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ie = Object.prototype.hasOwnProperty, re = Array.isArray, w = console.createTask ? console.createTask : function() {
|
|
241
|
-
return null;
|
|
242
|
-
};
|
|
243
|
-
Y = {
|
|
244
|
-
react_stack_bottom_frame: function(e) {
|
|
245
|
-
return e();
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var M, ne = {}, I = Y.react_stack_bottom_frame.bind(
|
|
249
|
-
Y,
|
|
250
|
-
i
|
|
251
|
-
)(), oe = w(c(i)), q = {};
|
|
252
|
-
ae.Fragment = O, ae.jsx = function(e, s, u) {
|
|
253
|
-
var d = 1e4 > te.recentlyCreatedOwnerStacks++;
|
|
254
|
-
return P(
|
|
255
|
-
e,
|
|
256
|
-
s,
|
|
257
|
-
u,
|
|
258
|
-
!1,
|
|
259
|
-
d ? Error("react-stack-top-frame") : I,
|
|
260
|
-
d ? w(c(e)) : oe
|
|
261
|
-
);
|
|
262
|
-
}, ae.jsxs = function(e, s, u) {
|
|
263
|
-
var d = 1e4 > te.recentlyCreatedOwnerStacks++;
|
|
264
|
-
return P(
|
|
265
|
-
e,
|
|
266
|
-
s,
|
|
267
|
-
u,
|
|
268
|
-
!0,
|
|
269
|
-
d ? Error("react-stack-top-frame") : I,
|
|
270
|
-
d ? w(c(e)) : oe
|
|
271
|
-
);
|
|
272
|
-
};
|
|
273
|
-
})()), ae;
|
|
274
|
-
}
|
|
275
|
-
var Te;
|
|
276
|
-
function We() {
|
|
277
|
-
return Te || (Te = 1, process.env.NODE_ENV === "production" ? ce.exports = De() : ce.exports = Le()), ce.exports;
|
|
278
|
-
}
|
|
279
|
-
var o = We();
|
|
280
|
-
const Be = ({
|
|
281
|
-
isVisible: a,
|
|
282
|
-
position: x,
|
|
1
|
+
import { jsxs as g, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as T, useEffect as ee, useMemo as xe, useCallback as F, forwardRef as Ee, useRef as _, useImperativeHandle as De } from "react";
|
|
3
|
+
const Ne = ({
|
|
4
|
+
isVisible: s,
|
|
5
|
+
position: f,
|
|
283
6
|
availableFields: m,
|
|
284
7
|
filteredFields: c,
|
|
285
8
|
filterQuery: n,
|
|
286
|
-
allowCreate:
|
|
287
|
-
onSelect:
|
|
288
|
-
onClose:
|
|
289
|
-
onCreateField:
|
|
9
|
+
allowCreate: p,
|
|
10
|
+
onSelect: H,
|
|
11
|
+
onClose: j,
|
|
12
|
+
onCreateField: U
|
|
290
13
|
}) => {
|
|
291
|
-
const [G,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}, [
|
|
295
|
-
const
|
|
14
|
+
const [G, E] = T(!1), [S, y] = T(""), [A, k] = T("inline");
|
|
15
|
+
ee(() => {
|
|
16
|
+
s || (E(!1), y(""), k("inline"));
|
|
17
|
+
}, [s]);
|
|
18
|
+
const te = xe(() => ({
|
|
296
19
|
position: "absolute",
|
|
297
|
-
left:
|
|
298
|
-
top:
|
|
20
|
+
left: f?.left,
|
|
21
|
+
top: f?.top,
|
|
299
22
|
zIndex: 1e3,
|
|
300
23
|
background: "white",
|
|
301
24
|
border: "1px solid #ddd",
|
|
@@ -303,56 +26,57 @@ const Be = ({
|
|
|
303
26
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
304
27
|
padding: "8px 0",
|
|
305
28
|
minWidth: "200px"
|
|
306
|
-
}), [
|
|
307
|
-
const
|
|
308
|
-
return
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
|
|
29
|
+
}), [f]), Q = c ?? m, X = !!n, u = xe(() => {
|
|
30
|
+
const r = [], x = /* @__PURE__ */ new Map();
|
|
31
|
+
return Q.forEach((v) => {
|
|
32
|
+
const h = v.category?.trim() || "Uncategorized", D = x.get(h);
|
|
33
|
+
if (D !== void 0) {
|
|
34
|
+
r[D].fields.push(v);
|
|
312
35
|
return;
|
|
313
36
|
}
|
|
314
|
-
|
|
315
|
-
}),
|
|
316
|
-
}, [
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
return Object.keys(
|
|
321
|
-
const
|
|
322
|
-
let v = Object.keys(
|
|
323
|
-
return
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
}), v ?
|
|
37
|
+
x.set(h, r.length), r.push({ category: h, fields: [v] });
|
|
38
|
+
}), r;
|
|
39
|
+
}, [Q]), [P, I] = T({});
|
|
40
|
+
ee(() => {
|
|
41
|
+
I((r) => {
|
|
42
|
+
if (u.length === 0)
|
|
43
|
+
return Object.keys(r).length === 0 ? r : {};
|
|
44
|
+
const x = {};
|
|
45
|
+
let v = Object.keys(r).length !== u.length;
|
|
46
|
+
return u.forEach(({ category: h }, D) => {
|
|
47
|
+
const N = X ? !0 : r[h] ?? D === 0;
|
|
48
|
+
x[h] = N, !v && r[h] !== N && (v = !0);
|
|
49
|
+
}), v ? x : r;
|
|
327
50
|
});
|
|
328
|
-
}, [
|
|
329
|
-
const $ =
|
|
330
|
-
|
|
331
|
-
...
|
|
332
|
-
[
|
|
51
|
+
}, [u, X]);
|
|
52
|
+
const $ = F((r) => {
|
|
53
|
+
I((x) => ({
|
|
54
|
+
...x,
|
|
55
|
+
[r]: !x[r]
|
|
333
56
|
}));
|
|
334
57
|
}, []);
|
|
335
|
-
if (!
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
if (!
|
|
339
|
-
const
|
|
58
|
+
if (!s) return null;
|
|
59
|
+
const W = async () => {
|
|
60
|
+
const r = S.trim();
|
|
61
|
+
if (!r) return;
|
|
62
|
+
const x = {
|
|
340
63
|
id: `custom_${Date.now()}`,
|
|
341
|
-
label:
|
|
342
|
-
category: "Custom"
|
|
64
|
+
label: r,
|
|
65
|
+
category: "Custom",
|
|
66
|
+
metadata: { mode: A }
|
|
343
67
|
};
|
|
344
68
|
try {
|
|
345
|
-
if (
|
|
346
|
-
const v = await
|
|
347
|
-
|
|
69
|
+
if (U) {
|
|
70
|
+
const v = await U(x);
|
|
71
|
+
H(v || x);
|
|
348
72
|
} else
|
|
349
|
-
|
|
73
|
+
H(x);
|
|
350
74
|
} finally {
|
|
351
|
-
|
|
75
|
+
E(!1), y(""), k("inline");
|
|
352
76
|
}
|
|
353
77
|
};
|
|
354
|
-
return /* @__PURE__ */
|
|
355
|
-
|
|
78
|
+
return /* @__PURE__ */ g("div", { className: "superdoc-field-menu", style: te, children: [
|
|
79
|
+
X && /* @__PURE__ */ i(
|
|
356
80
|
"div",
|
|
357
81
|
{
|
|
358
82
|
style: {
|
|
@@ -360,9 +84,9 @@ const Be = ({
|
|
|
360
84
|
borderBottom: "1px solid #f0f0f0",
|
|
361
85
|
marginBottom: "4px"
|
|
362
86
|
},
|
|
363
|
-
children: /* @__PURE__ */
|
|
87
|
+
children: /* @__PURE__ */ g("div", { style: { fontSize: "12px", color: "#6b7280" }, children: [
|
|
364
88
|
"Filtering results for",
|
|
365
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ i(
|
|
366
90
|
"span",
|
|
367
91
|
{
|
|
368
92
|
style: { fontWeight: 600, color: "#111827", marginLeft: "4px" },
|
|
@@ -372,11 +96,11 @@ const Be = ({
|
|
|
372
96
|
] })
|
|
373
97
|
}
|
|
374
98
|
),
|
|
375
|
-
|
|
99
|
+
p && !G && /* @__PURE__ */ i(
|
|
376
100
|
"div",
|
|
377
101
|
{
|
|
378
102
|
className: "field-menu-item",
|
|
379
|
-
onClick: () =>
|
|
103
|
+
onClick: () => E(!0),
|
|
380
104
|
style: {
|
|
381
105
|
padding: "8px 16px",
|
|
382
106
|
cursor: "pointer",
|
|
@@ -386,16 +110,16 @@ const Be = ({
|
|
|
386
110
|
children: "+ Create New Field"
|
|
387
111
|
}
|
|
388
112
|
),
|
|
389
|
-
|
|
390
|
-
/* @__PURE__ */
|
|
113
|
+
p && G && /* @__PURE__ */ g("div", { style: { padding: "8px 16px" }, children: [
|
|
114
|
+
/* @__PURE__ */ i(
|
|
391
115
|
"input",
|
|
392
116
|
{
|
|
393
117
|
type: "text",
|
|
394
|
-
value:
|
|
118
|
+
value: S,
|
|
395
119
|
placeholder: "Field name...",
|
|
396
|
-
onChange: (
|
|
397
|
-
onKeyDown: (
|
|
398
|
-
|
|
120
|
+
onChange: (r) => y(r.target.value),
|
|
121
|
+
onKeyDown: (r) => {
|
|
122
|
+
r.key === "Enter" && W(), r.key === "Escape" && (E(!1), y(""), k("inline"));
|
|
399
123
|
},
|
|
400
124
|
autoFocus: !0,
|
|
401
125
|
style: {
|
|
@@ -406,7 +130,66 @@ const Be = ({
|
|
|
406
130
|
}
|
|
407
131
|
}
|
|
408
132
|
),
|
|
409
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ g(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
style: {
|
|
137
|
+
marginTop: "8px",
|
|
138
|
+
display: "flex",
|
|
139
|
+
gap: "12px",
|
|
140
|
+
fontSize: "13px"
|
|
141
|
+
},
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ g(
|
|
144
|
+
"label",
|
|
145
|
+
{
|
|
146
|
+
style: {
|
|
147
|
+
display: "flex",
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
gap: "4px",
|
|
150
|
+
cursor: "pointer"
|
|
151
|
+
},
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ i(
|
|
154
|
+
"input",
|
|
155
|
+
{
|
|
156
|
+
type: "radio",
|
|
157
|
+
value: "inline",
|
|
158
|
+
checked: A === "inline",
|
|
159
|
+
onChange: () => k("inline")
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
"Inline"
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ g(
|
|
167
|
+
"label",
|
|
168
|
+
{
|
|
169
|
+
style: {
|
|
170
|
+
display: "flex",
|
|
171
|
+
alignItems: "center",
|
|
172
|
+
gap: "4px",
|
|
173
|
+
cursor: "pointer"
|
|
174
|
+
},
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ i(
|
|
177
|
+
"input",
|
|
178
|
+
{
|
|
179
|
+
type: "radio",
|
|
180
|
+
value: "block",
|
|
181
|
+
checked: A === "block",
|
|
182
|
+
onChange: () => k("block")
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
"Block"
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ g(
|
|
410
193
|
"div",
|
|
411
194
|
{
|
|
412
195
|
style: {
|
|
@@ -415,27 +198,27 @@ const Be = ({
|
|
|
415
198
|
gap: "8px"
|
|
416
199
|
},
|
|
417
200
|
children: [
|
|
418
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ i(
|
|
419
202
|
"button",
|
|
420
203
|
{
|
|
421
|
-
onClick:
|
|
422
|
-
disabled: !
|
|
204
|
+
onClick: W,
|
|
205
|
+
disabled: !S.trim(),
|
|
423
206
|
style: {
|
|
424
207
|
padding: "4px 12px",
|
|
425
|
-
background:
|
|
208
|
+
background: S.trim() ? "#0066cc" : "#ccc",
|
|
426
209
|
color: "white",
|
|
427
210
|
border: "none",
|
|
428
211
|
borderRadius: "3px",
|
|
429
|
-
cursor:
|
|
212
|
+
cursor: S.trim() ? "pointer" : "not-allowed"
|
|
430
213
|
},
|
|
431
214
|
children: "Create"
|
|
432
215
|
}
|
|
433
216
|
),
|
|
434
|
-
/* @__PURE__ */
|
|
217
|
+
/* @__PURE__ */ i(
|
|
435
218
|
"button",
|
|
436
219
|
{
|
|
437
220
|
onClick: () => {
|
|
438
|
-
|
|
221
|
+
E(!1), y(""), k("inline");
|
|
439
222
|
},
|
|
440
223
|
style: {
|
|
441
224
|
padding: "4px 12px",
|
|
@@ -451,7 +234,7 @@ const Be = ({
|
|
|
451
234
|
}
|
|
452
235
|
)
|
|
453
236
|
] }),
|
|
454
|
-
|
|
237
|
+
p && m.length > 0 && /* @__PURE__ */ i(
|
|
455
238
|
"div",
|
|
456
239
|
{
|
|
457
240
|
style: {
|
|
@@ -460,7 +243,7 @@ const Be = ({
|
|
|
460
243
|
}
|
|
461
244
|
}
|
|
462
245
|
),
|
|
463
|
-
|
|
246
|
+
u.length === 0 ? /* @__PURE__ */ i(
|
|
464
247
|
"div",
|
|
465
248
|
{
|
|
466
249
|
style: {
|
|
@@ -471,20 +254,20 @@ const Be = ({
|
|
|
471
254
|
},
|
|
472
255
|
children: "No matching fields"
|
|
473
256
|
}
|
|
474
|
-
) :
|
|
475
|
-
const
|
|
476
|
-
return /* @__PURE__ */
|
|
257
|
+
) : u.map(({ category: r, fields: x }, v) => {
|
|
258
|
+
const h = !!P[r], D = `${Math.max(x.length * 40, 0)}px`;
|
|
259
|
+
return /* @__PURE__ */ g(
|
|
477
260
|
"div",
|
|
478
261
|
{
|
|
479
262
|
style: {
|
|
480
|
-
borderTop: v === 0 &&
|
|
263
|
+
borderTop: v === 0 && p ? void 0 : "1px solid #f0f0f0"
|
|
481
264
|
},
|
|
482
265
|
children: [
|
|
483
|
-
/* @__PURE__ */
|
|
266
|
+
/* @__PURE__ */ g(
|
|
484
267
|
"button",
|
|
485
268
|
{
|
|
486
269
|
type: "button",
|
|
487
|
-
onClick: () => $(
|
|
270
|
+
onClick: () => $(r),
|
|
488
271
|
style: {
|
|
489
272
|
width: "100%",
|
|
490
273
|
display: "flex",
|
|
@@ -498,13 +281,13 @@ const Be = ({
|
|
|
498
281
|
textAlign: "left"
|
|
499
282
|
},
|
|
500
283
|
children: [
|
|
501
|
-
/* @__PURE__ */
|
|
502
|
-
|
|
284
|
+
/* @__PURE__ */ g("span", { children: [
|
|
285
|
+
r,
|
|
503
286
|
" (",
|
|
504
|
-
|
|
287
|
+
x.length,
|
|
505
288
|
")"
|
|
506
289
|
] }),
|
|
507
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ i(
|
|
508
291
|
"span",
|
|
509
292
|
{
|
|
510
293
|
"aria-hidden": !0,
|
|
@@ -514,7 +297,7 @@ const Be = ({
|
|
|
514
297
|
height: "8px",
|
|
515
298
|
borderRight: "2px solid #666",
|
|
516
299
|
borderBottom: "2px solid #666",
|
|
517
|
-
transform:
|
|
300
|
+
transform: h ? "rotate(45deg)" : "rotate(-45deg)",
|
|
518
301
|
transition: "transform 0.2s ease",
|
|
519
302
|
marginLeft: "12px"
|
|
520
303
|
}
|
|
@@ -523,23 +306,23 @@ const Be = ({
|
|
|
523
306
|
]
|
|
524
307
|
}
|
|
525
308
|
),
|
|
526
|
-
/* @__PURE__ */
|
|
309
|
+
/* @__PURE__ */ i(
|
|
527
310
|
"div",
|
|
528
311
|
{
|
|
529
|
-
"data-category":
|
|
530
|
-
"aria-hidden": !
|
|
312
|
+
"data-category": r,
|
|
313
|
+
"aria-hidden": !h,
|
|
531
314
|
style: {
|
|
532
315
|
overflow: "hidden",
|
|
533
|
-
maxHeight:
|
|
534
|
-
opacity:
|
|
316
|
+
maxHeight: h ? D : "0px",
|
|
317
|
+
opacity: h ? 1 : 0,
|
|
535
318
|
transition: "max-height 0.2s ease, opacity 0.2s ease",
|
|
536
|
-
pointerEvents:
|
|
319
|
+
pointerEvents: h ? "auto" : "none"
|
|
537
320
|
},
|
|
538
|
-
children: /* @__PURE__ */
|
|
321
|
+
children: /* @__PURE__ */ i("div", { style: { padding: h ? "4px 0" : 0 }, children: x.map((N) => /* @__PURE__ */ i(
|
|
539
322
|
"div",
|
|
540
323
|
{
|
|
541
324
|
className: "field-menu-item",
|
|
542
|
-
onClick: () =>
|
|
325
|
+
onClick: () => H(N),
|
|
543
326
|
style: {
|
|
544
327
|
padding: "8px 16px",
|
|
545
328
|
cursor: "pointer",
|
|
@@ -547,28 +330,28 @@ const Be = ({
|
|
|
547
330
|
alignItems: "center",
|
|
548
331
|
justifyContent: "space-between"
|
|
549
332
|
},
|
|
550
|
-
children: /* @__PURE__ */
|
|
333
|
+
children: /* @__PURE__ */ i("span", { style: { fontWeight: 500 }, children: N.label })
|
|
551
334
|
},
|
|
552
|
-
|
|
335
|
+
N.id
|
|
553
336
|
)) })
|
|
554
337
|
}
|
|
555
338
|
)
|
|
556
339
|
]
|
|
557
340
|
},
|
|
558
|
-
|
|
341
|
+
r
|
|
559
342
|
);
|
|
560
343
|
}),
|
|
561
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ i(
|
|
562
345
|
"div",
|
|
563
346
|
{
|
|
564
347
|
style: {
|
|
565
348
|
borderTop: "1px solid #eee",
|
|
566
349
|
marginTop: "4px"
|
|
567
350
|
},
|
|
568
|
-
children: /* @__PURE__ */
|
|
351
|
+
children: /* @__PURE__ */ i(
|
|
569
352
|
"button",
|
|
570
353
|
{
|
|
571
|
-
onClick:
|
|
354
|
+
onClick: j,
|
|
572
355
|
style: {
|
|
573
356
|
width: "100%",
|
|
574
357
|
padding: "6px 16px",
|
|
@@ -583,12 +366,12 @@ const Be = ({
|
|
|
583
366
|
}
|
|
584
367
|
)
|
|
585
368
|
] });
|
|
586
|
-
},
|
|
587
|
-
fields:
|
|
588
|
-
onSelect:
|
|
369
|
+
}, Re = ({
|
|
370
|
+
fields: s,
|
|
371
|
+
onSelect: f,
|
|
589
372
|
onDelete: m,
|
|
590
373
|
selectedFieldId: c
|
|
591
|
-
}) => /* @__PURE__ */
|
|
374
|
+
}) => /* @__PURE__ */ g(
|
|
592
375
|
"div",
|
|
593
376
|
{
|
|
594
377
|
className: "superdoc-field-list",
|
|
@@ -600,12 +383,12 @@ const Be = ({
|
|
|
600
383
|
padding: "16px"
|
|
601
384
|
},
|
|
602
385
|
children: [
|
|
603
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ g("h3", { style: { margin: "0 0 16px 0", fontSize: "16px", fontWeight: "600" }, children: [
|
|
604
387
|
"Template Fields (",
|
|
605
|
-
|
|
388
|
+
s.length,
|
|
606
389
|
")"
|
|
607
390
|
] }),
|
|
608
|
-
|
|
391
|
+
s.length === 0 ? /* @__PURE__ */ g(
|
|
609
392
|
"div",
|
|
610
393
|
{
|
|
611
394
|
style: {
|
|
@@ -620,10 +403,10 @@ const Be = ({
|
|
|
620
403
|
" to add a field."
|
|
621
404
|
]
|
|
622
405
|
}
|
|
623
|
-
) : /* @__PURE__ */
|
|
406
|
+
) : /* @__PURE__ */ i("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: s.map((n) => /* @__PURE__ */ g(
|
|
624
407
|
"div",
|
|
625
408
|
{
|
|
626
|
-
onClick: () =>
|
|
409
|
+
onClick: () => f(n),
|
|
627
410
|
style: {
|
|
628
411
|
position: "relative",
|
|
629
412
|
padding: "12px",
|
|
@@ -633,19 +416,19 @@ const Be = ({
|
|
|
633
416
|
cursor: "pointer",
|
|
634
417
|
transition: "all 0.2s"
|
|
635
418
|
},
|
|
636
|
-
onMouseEnter: (
|
|
637
|
-
c !== n.id && (
|
|
419
|
+
onMouseEnter: (p) => {
|
|
420
|
+
c !== n.id && (p.currentTarget.style.background = "#f3f4f6");
|
|
638
421
|
},
|
|
639
|
-
onMouseLeave: (
|
|
640
|
-
c !== n.id && (
|
|
422
|
+
onMouseLeave: (p) => {
|
|
423
|
+
c !== n.id && (p.currentTarget.style.background = "#f9fafb");
|
|
641
424
|
},
|
|
642
425
|
title: n.alias,
|
|
643
426
|
children: [
|
|
644
|
-
/* @__PURE__ */
|
|
427
|
+
/* @__PURE__ */ i(
|
|
645
428
|
"button",
|
|
646
429
|
{
|
|
647
|
-
onClick: (
|
|
648
|
-
|
|
430
|
+
onClick: (p) => {
|
|
431
|
+
p.stopPropagation(), m(n.id);
|
|
649
432
|
},
|
|
650
433
|
style: {
|
|
651
434
|
position: "absolute",
|
|
@@ -661,14 +444,14 @@ const Be = ({
|
|
|
661
444
|
alignItems: "center",
|
|
662
445
|
justifyContent: "center"
|
|
663
446
|
},
|
|
664
|
-
onMouseEnter: (
|
|
665
|
-
|
|
447
|
+
onMouseEnter: (p) => {
|
|
448
|
+
p.currentTarget.style.color = "#ef4444";
|
|
666
449
|
},
|
|
667
|
-
onMouseLeave: (
|
|
668
|
-
|
|
450
|
+
onMouseLeave: (p) => {
|
|
451
|
+
p.currentTarget.style.color = "#9ca3af";
|
|
669
452
|
},
|
|
670
453
|
title: "Delete field",
|
|
671
|
-
children: /* @__PURE__ */
|
|
454
|
+
children: /* @__PURE__ */ i(
|
|
672
455
|
"svg",
|
|
673
456
|
{
|
|
674
457
|
width: "16",
|
|
@@ -676,7 +459,7 @@ const Be = ({
|
|
|
676
459
|
viewBox: "0 0 16 16",
|
|
677
460
|
fill: "none",
|
|
678
461
|
xmlns: "http://www.w3.org/2000/svg",
|
|
679
|
-
children: /* @__PURE__ */
|
|
462
|
+
children: /* @__PURE__ */ i(
|
|
680
463
|
"path",
|
|
681
464
|
{
|
|
682
465
|
d: "M6 2V1.5C6 1.22386 6.22386 1 6.5 1H9.5C9.77614 1 10 1.22386 10 1.5V2M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4",
|
|
@@ -690,8 +473,8 @@ const Be = ({
|
|
|
690
473
|
)
|
|
691
474
|
}
|
|
692
475
|
),
|
|
693
|
-
/* @__PURE__ */
|
|
694
|
-
/* @__PURE__ */
|
|
476
|
+
/* @__PURE__ */ g("div", { style: { paddingRight: "24px" }, children: [
|
|
477
|
+
/* @__PURE__ */ i(
|
|
695
478
|
"div",
|
|
696
479
|
{
|
|
697
480
|
style: {
|
|
@@ -702,14 +485,33 @@ const Be = ({
|
|
|
702
485
|
children: n.id
|
|
703
486
|
}
|
|
704
487
|
),
|
|
705
|
-
|
|
488
|
+
/* @__PURE__ */ g(
|
|
706
489
|
"div",
|
|
707
490
|
{
|
|
708
491
|
style: {
|
|
492
|
+
display: "flex",
|
|
493
|
+
alignItems: "center",
|
|
494
|
+
gap: "6px",
|
|
709
495
|
fontSize: "12px",
|
|
710
496
|
color: "#4b5563"
|
|
711
497
|
},
|
|
712
|
-
children:
|
|
498
|
+
children: [
|
|
499
|
+
n.alias && n.alias !== n.id && /* @__PURE__ */ i("span", { children: n.alias }),
|
|
500
|
+
n.mode && /* @__PURE__ */ i(
|
|
501
|
+
"span",
|
|
502
|
+
{
|
|
503
|
+
style: {
|
|
504
|
+
fontSize: "10px",
|
|
505
|
+
padding: "2px 6px",
|
|
506
|
+
borderRadius: "4px",
|
|
507
|
+
background: n.mode === "block" ? "#dbeafe" : "#f3f4f6",
|
|
508
|
+
color: n.mode === "block" ? "#1e40af" : "#4b5563",
|
|
509
|
+
fontWeight: "500"
|
|
510
|
+
},
|
|
511
|
+
children: n.mode
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
]
|
|
713
515
|
}
|
|
714
516
|
)
|
|
715
517
|
] })
|
|
@@ -719,356 +521,364 @@ const Be = ({
|
|
|
719
521
|
)) })
|
|
720
522
|
]
|
|
721
523
|
}
|
|
722
|
-
),
|
|
723
|
-
const
|
|
724
|
-
return
|
|
725
|
-
const
|
|
524
|
+
), ae = (s) => {
|
|
525
|
+
const f = s.helpers?.structuredContentCommands;
|
|
526
|
+
return f?.getStructuredContentTags ? (f.getStructuredContentTags(s.state) || []).map((c) => {
|
|
527
|
+
const n = c?.node ?? c, p = n?.attrs ?? {}, j = (n?.type?.name || "").includes("Block") ? "block" : "inline";
|
|
726
528
|
return {
|
|
727
|
-
id:
|
|
728
|
-
alias:
|
|
729
|
-
tag:
|
|
529
|
+
id: p.id,
|
|
530
|
+
alias: p.alias || p.label || "",
|
|
531
|
+
tag: p.tag,
|
|
532
|
+
mode: j
|
|
730
533
|
};
|
|
731
534
|
}) : [];
|
|
732
|
-
},
|
|
733
|
-
if (
|
|
734
|
-
if (
|
|
735
|
-
for (let m = 0; m <
|
|
736
|
-
const c =
|
|
737
|
-
if (!n || c.id !== n.id || c.alias !== n.alias || c.tag !== n.tag || c.position !== n.position)
|
|
535
|
+
}, he = (s, f) => {
|
|
536
|
+
if (s === f) return !0;
|
|
537
|
+
if (s.length !== f.length) return !1;
|
|
538
|
+
for (let m = 0; m < s.length; m += 1) {
|
|
539
|
+
const c = s[m], n = f[m];
|
|
540
|
+
if (!n || c.id !== n.id || c.alias !== n.alias || c.tag !== n.tag || c.position !== n.position || c.mode !== n.mode)
|
|
738
541
|
return !1;
|
|
739
542
|
}
|
|
740
543
|
return !0;
|
|
741
|
-
},
|
|
742
|
-
if (!
|
|
743
|
-
if (
|
|
544
|
+
}, Be = (s) => {
|
|
545
|
+
if (!s) return null;
|
|
546
|
+
if (s === !0)
|
|
744
547
|
return {
|
|
745
548
|
selector: "#superdoc-toolbar",
|
|
746
549
|
config: {},
|
|
747
550
|
renderDefaultContainer: !0
|
|
748
551
|
};
|
|
749
|
-
if (typeof
|
|
552
|
+
if (typeof s == "string")
|
|
750
553
|
return {
|
|
751
|
-
selector:
|
|
554
|
+
selector: s,
|
|
752
555
|
config: {},
|
|
753
556
|
renderDefaultContainer: !1
|
|
754
557
|
};
|
|
755
|
-
const { selector:
|
|
558
|
+
const { selector: f, ...m } = s;
|
|
756
559
|
return {
|
|
757
|
-
selector:
|
|
560
|
+
selector: f || "#superdoc-toolbar",
|
|
758
561
|
config: m,
|
|
759
|
-
renderDefaultContainer:
|
|
562
|
+
renderDefaultContainer: f === void 0
|
|
760
563
|
};
|
|
761
|
-
},
|
|
762
|
-
const
|
|
564
|
+
}, Z = 10, Le = 250, He = 300, ye = (s) => {
|
|
565
|
+
const f = window.innerWidth - Le - Z, m = window.innerHeight - He - Z, c = Math.min(s.left, f), n = Math.min(s.top, m);
|
|
763
566
|
return new DOMRect(
|
|
764
|
-
Math.max(c,
|
|
765
|
-
Math.max(n,
|
|
766
|
-
|
|
767
|
-
|
|
567
|
+
Math.max(c, Z),
|
|
568
|
+
Math.max(n, Z),
|
|
569
|
+
s.width,
|
|
570
|
+
s.height
|
|
768
571
|
);
|
|
769
|
-
},
|
|
572
|
+
}, Pe = Ee((s, f) => {
|
|
770
573
|
const {
|
|
771
574
|
document: m,
|
|
772
575
|
fields: c = {},
|
|
773
576
|
menu: n = {},
|
|
774
|
-
list:
|
|
775
|
-
toolbar:
|
|
776
|
-
onReady:
|
|
777
|
-
onTrigger:
|
|
577
|
+
list: p = {},
|
|
578
|
+
toolbar: H,
|
|
579
|
+
onReady: j,
|
|
580
|
+
onTrigger: U,
|
|
778
581
|
onFieldInsert: G,
|
|
779
|
-
onFieldUpdate:
|
|
780
|
-
onFieldDelete:
|
|
781
|
-
onFieldsChange:
|
|
782
|
-
onFieldSelect:
|
|
783
|
-
onFieldCreate:
|
|
784
|
-
className:
|
|
785
|
-
style:
|
|
786
|
-
documentHeight:
|
|
787
|
-
} =
|
|
582
|
+
onFieldUpdate: E,
|
|
583
|
+
onFieldDelete: S,
|
|
584
|
+
onFieldsChange: y,
|
|
585
|
+
onFieldSelect: A,
|
|
586
|
+
onFieldCreate: k,
|
|
587
|
+
className: te,
|
|
588
|
+
style: Q,
|
|
589
|
+
documentHeight: X = "600px"
|
|
590
|
+
} = s, [u, P] = T(
|
|
788
591
|
c.initial || []
|
|
789
|
-
), [
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}, [
|
|
795
|
-
const
|
|
796
|
-
(
|
|
797
|
-
const
|
|
798
|
-
return
|
|
799
|
-
const
|
|
800
|
-
return
|
|
801
|
-
}) :
|
|
592
|
+
), [I, $] = T(null), [W, r] = T(!1), [x, v] = T(), [h, D] = T(""), [N, be] = T(() => c.available || []), q = _(null), C = _(null), R = _(null), de = _(c);
|
|
593
|
+
de.current = c;
|
|
594
|
+
const B = _(null), ce = _(W);
|
|
595
|
+
ee(() => {
|
|
596
|
+
ce.current = W;
|
|
597
|
+
}, [W]);
|
|
598
|
+
const K = n.trigger || "{{", ne = de.current.available || [], ue = F(
|
|
599
|
+
(e) => {
|
|
600
|
+
const t = e.trim().toLowerCase();
|
|
601
|
+
return t ? ne.filter((o) => {
|
|
602
|
+
const l = o.label.toLowerCase(), w = o.category?.toLowerCase() || "";
|
|
603
|
+
return l.includes(t) || w.includes(t);
|
|
604
|
+
}) : ne;
|
|
802
605
|
},
|
|
803
|
-
[
|
|
804
|
-
),
|
|
805
|
-
(
|
|
806
|
-
|
|
606
|
+
[ne]
|
|
607
|
+
), re = F(
|
|
608
|
+
(e) => {
|
|
609
|
+
D(e), be(ue(e));
|
|
807
610
|
},
|
|
808
|
-
[
|
|
809
|
-
),
|
|
810
|
-
|
|
811
|
-
}, [
|
|
812
|
-
(
|
|
813
|
-
if (!
|
|
814
|
-
const
|
|
611
|
+
[ue]
|
|
612
|
+
), V = F(() => {
|
|
613
|
+
re("");
|
|
614
|
+
}, [re]), J = F(
|
|
615
|
+
(e, t) => {
|
|
616
|
+
if (!C.current?.activeEditor) return !1;
|
|
617
|
+
const o = C.current.activeEditor, l = u, w = e === "inline" ? o.commands.insertStructuredContentInline?.({
|
|
815
618
|
attrs: {
|
|
816
|
-
alias:
|
|
817
|
-
tag:
|
|
619
|
+
alias: t.alias,
|
|
620
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : t.category
|
|
818
621
|
},
|
|
819
|
-
text:
|
|
820
|
-
}) :
|
|
622
|
+
text: t.defaultValue || t.alias
|
|
623
|
+
}) : o.commands.insertStructuredContentBlock?.({
|
|
821
624
|
attrs: {
|
|
822
|
-
alias:
|
|
823
|
-
tag:
|
|
625
|
+
alias: t.alias,
|
|
626
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : t.category
|
|
824
627
|
},
|
|
825
|
-
text:
|
|
628
|
+
text: t.defaultValue || t.alias
|
|
826
629
|
});
|
|
827
|
-
if (
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
(
|
|
630
|
+
if (w) {
|
|
631
|
+
const b = ae(o);
|
|
632
|
+
P(b), y?.(b);
|
|
633
|
+
const a = b.find(
|
|
634
|
+
(d) => !l.some((L) => L.id === d.id)
|
|
832
635
|
);
|
|
833
|
-
|
|
636
|
+
a && G?.(a);
|
|
834
637
|
}
|
|
835
|
-
return
|
|
638
|
+
return w;
|
|
836
639
|
},
|
|
837
|
-
[G,
|
|
838
|
-
),
|
|
839
|
-
(
|
|
840
|
-
if (!
|
|
841
|
-
const
|
|
842
|
-
attrs:
|
|
640
|
+
[G, y, u]
|
|
641
|
+
), oe = F(
|
|
642
|
+
(e, t) => {
|
|
643
|
+
if (!C.current?.activeEditor) return !1;
|
|
644
|
+
const l = C.current.activeEditor.commands.updateStructuredContentById?.(e, {
|
|
645
|
+
attrs: t
|
|
843
646
|
});
|
|
844
|
-
return
|
|
845
|
-
const
|
|
846
|
-
(
|
|
647
|
+
return l && P((w) => {
|
|
648
|
+
const b = w.map(
|
|
649
|
+
(d) => d.id === e ? { ...d, ...t } : d
|
|
847
650
|
);
|
|
848
|
-
|
|
849
|
-
const
|
|
850
|
-
return
|
|
851
|
-
}),
|
|
651
|
+
y?.(b);
|
|
652
|
+
const a = b.find((d) => d.id === e);
|
|
653
|
+
return a && E?.(a), b;
|
|
654
|
+
}), l;
|
|
852
655
|
},
|
|
853
|
-
[
|
|
854
|
-
),
|
|
855
|
-
(
|
|
856
|
-
const
|
|
857
|
-
if (!
|
|
656
|
+
[E, y]
|
|
657
|
+
), ie = F(
|
|
658
|
+
(e) => {
|
|
659
|
+
const t = C.current?.activeEditor;
|
|
660
|
+
if (!t) {
|
|
858
661
|
console.warn(
|
|
859
662
|
"[SuperDocTemplateBuilder] deleteField called without active editor"
|
|
860
663
|
);
|
|
861
|
-
let
|
|
862
|
-
return
|
|
863
|
-
if (!
|
|
864
|
-
const
|
|
865
|
-
return
|
|
866
|
-
}),
|
|
664
|
+
let a = !1;
|
|
665
|
+
return P((d) => {
|
|
666
|
+
if (!d.some((M) => M.id === e)) return d;
|
|
667
|
+
const L = d.filter((M) => M.id !== e);
|
|
668
|
+
return a = !0, y?.(L), L;
|
|
669
|
+
}), a && (S?.(e), $((d) => d === e ? null : d)), a;
|
|
867
670
|
}
|
|
868
|
-
let
|
|
671
|
+
let o = !1;
|
|
869
672
|
try {
|
|
870
|
-
|
|
871
|
-
} catch (
|
|
673
|
+
o = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
674
|
+
} catch (a) {
|
|
872
675
|
console.error(
|
|
873
676
|
"[SuperDocTemplateBuilder] Delete command failed:",
|
|
874
|
-
|
|
677
|
+
a
|
|
875
678
|
);
|
|
876
679
|
}
|
|
877
|
-
let
|
|
878
|
-
const
|
|
879
|
-
!
|
|
880
|
-
let
|
|
881
|
-
return
|
|
882
|
-
if (
|
|
883
|
-
return
|
|
884
|
-
const
|
|
885
|
-
return
|
|
886
|
-
}),
|
|
680
|
+
let l = ae(t);
|
|
681
|
+
const w = l.some((a) => a.id === e);
|
|
682
|
+
!o && w && (l = l.filter((a) => a.id !== e));
|
|
683
|
+
let b = !1;
|
|
684
|
+
return P((a) => {
|
|
685
|
+
if (he(a, l))
|
|
686
|
+
return a;
|
|
687
|
+
const d = a.some((M) => M.id === e), L = l.some((M) => M.id === e);
|
|
688
|
+
return d && !L && (b = !0), y?.(l), l;
|
|
689
|
+
}), b && (S?.(e), $((a) => a === e ? null : a)), o || b;
|
|
887
690
|
},
|
|
888
|
-
[
|
|
889
|
-
),
|
|
890
|
-
(
|
|
891
|
-
if (!
|
|
892
|
-
|
|
893
|
-
const
|
|
894
|
-
|
|
691
|
+
[S, y]
|
|
692
|
+
), z = F(
|
|
693
|
+
(e) => {
|
|
694
|
+
if (!C.current?.activeEditor) return;
|
|
695
|
+
C.current.activeEditor.commands.selectStructuredContentById?.(e), $(e);
|
|
696
|
+
const o = u.find((l) => l.id === e);
|
|
697
|
+
o && A?.(o);
|
|
895
698
|
},
|
|
896
|
-
[
|
|
897
|
-
),
|
|
898
|
-
(
|
|
899
|
-
if (!
|
|
900
|
-
const
|
|
901
|
-
|
|
699
|
+
[u, A]
|
|
700
|
+
), se = F(
|
|
701
|
+
(e) => {
|
|
702
|
+
if (!e) return;
|
|
703
|
+
const t = ae(e);
|
|
704
|
+
P((o) => he(o, t) ? o : (y?.(t), t));
|
|
902
705
|
},
|
|
903
|
-
[
|
|
706
|
+
[y]
|
|
904
707
|
);
|
|
905
|
-
|
|
906
|
-
const { SuperDoc:
|
|
907
|
-
selector:
|
|
708
|
+
ee(() => q.current ? ((async () => {
|
|
709
|
+
const { SuperDoc: t } = await import("superdoc"), o = {
|
|
710
|
+
selector: q.current,
|
|
908
711
|
document: m?.source,
|
|
909
712
|
documentMode: m?.mode || "editing",
|
|
910
713
|
onReady: () => {
|
|
911
|
-
if (
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
const { state:
|
|
915
|
-
if (
|
|
916
|
-
const
|
|
917
|
-
if (
|
|
918
|
-
const
|
|
919
|
-
new DOMRect(
|
|
920
|
-
),
|
|
921
|
-
const
|
|
922
|
-
if (!
|
|
923
|
-
const
|
|
924
|
-
|
|
714
|
+
if (l.activeEditor) {
|
|
715
|
+
const w = l.activeEditor;
|
|
716
|
+
w.on("update", ({ editor: b }) => {
|
|
717
|
+
const { state: a } = b, { from: d } = a.selection;
|
|
718
|
+
if (d >= K.length) {
|
|
719
|
+
const le = d - K.length;
|
|
720
|
+
if (a.doc.textBetween(le, d) === K) {
|
|
721
|
+
const me = b.view.coordsAtPos(d), fe = ye(
|
|
722
|
+
new DOMRect(me.left, me.top, 0, 0)
|
|
723
|
+
), ge = () => {
|
|
724
|
+
const Y = C.current?.activeEditor;
|
|
725
|
+
if (!Y) return;
|
|
726
|
+
const Se = Y.state.selection.from, Ie = Y.state.tr.delete(le, Se);
|
|
727
|
+
Y.view.dispatch(Ie);
|
|
925
728
|
};
|
|
926
|
-
|
|
927
|
-
position: { from:
|
|
928
|
-
bounds:
|
|
929
|
-
cleanup:
|
|
729
|
+
R.current = ge, B.current = d, v(fe), r(!0), V(), U?.({
|
|
730
|
+
position: { from: le, to: d },
|
|
731
|
+
bounds: fe,
|
|
732
|
+
cleanup: ge
|
|
930
733
|
});
|
|
931
734
|
return;
|
|
932
735
|
}
|
|
933
736
|
}
|
|
934
|
-
if (!
|
|
737
|
+
if (!ce.current)
|
|
935
738
|
return;
|
|
936
|
-
if (
|
|
937
|
-
|
|
739
|
+
if (B.current == null) {
|
|
740
|
+
r(!1), V();
|
|
938
741
|
return;
|
|
939
742
|
}
|
|
940
|
-
if (
|
|
941
|
-
|
|
743
|
+
if (d < B.current) {
|
|
744
|
+
r(!1), B.current = null, V();
|
|
942
745
|
return;
|
|
943
746
|
}
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
|
|
747
|
+
const L = a.doc.textBetween(
|
|
748
|
+
B.current,
|
|
749
|
+
d
|
|
947
750
|
);
|
|
948
|
-
|
|
949
|
-
const
|
|
950
|
-
new DOMRect(
|
|
751
|
+
re(L);
|
|
752
|
+
const M = b.view.coordsAtPos(d), Te = ye(
|
|
753
|
+
new DOMRect(M.left, M.top, 0, 0)
|
|
951
754
|
);
|
|
952
|
-
|
|
953
|
-
}),
|
|
954
|
-
|
|
955
|
-
}),
|
|
755
|
+
v(Te);
|
|
756
|
+
}), w.on("update", () => {
|
|
757
|
+
se(w);
|
|
758
|
+
}), se(w);
|
|
956
759
|
}
|
|
957
|
-
|
|
760
|
+
j?.();
|
|
958
761
|
}
|
|
959
|
-
},
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
762
|
+
}, l = new t({
|
|
763
|
+
selector: q.current,
|
|
764
|
+
documentMode: m?.mode || "editing",
|
|
765
|
+
...o,
|
|
766
|
+
...O && {
|
|
767
|
+
toolbar: O.selector,
|
|
963
768
|
modules: {
|
|
964
769
|
toolbar: {
|
|
965
|
-
selector:
|
|
966
|
-
toolbarGroups:
|
|
967
|
-
excludeItems:
|
|
968
|
-
...
|
|
770
|
+
selector: O.selector,
|
|
771
|
+
toolbarGroups: O.config.toolbarGroups || ["center"],
|
|
772
|
+
excludeItems: O.config.excludeItems || [],
|
|
773
|
+
...O.config
|
|
969
774
|
}
|
|
970
775
|
}
|
|
971
776
|
}
|
|
972
777
|
});
|
|
973
|
-
|
|
778
|
+
C.current = l;
|
|
974
779
|
})(), () => {
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
780
|
+
R.current = null, B.current = null;
|
|
781
|
+
const t = C.current;
|
|
782
|
+
t && typeof t.destroy == "function" && t.destroy(), C.current = null;
|
|
978
783
|
}) : void 0, [
|
|
979
784
|
m?.source,
|
|
980
785
|
m?.mode,
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
786
|
+
K,
|
|
787
|
+
se,
|
|
788
|
+
j,
|
|
789
|
+
U,
|
|
790
|
+
H
|
|
986
791
|
]);
|
|
987
|
-
const
|
|
988
|
-
async (
|
|
989
|
-
|
|
792
|
+
const ve = F(
|
|
793
|
+
async (e) => {
|
|
794
|
+
R.current && (R.current(), R.current = null), B.current = null, V();
|
|
795
|
+
const t = e.metadata?.mode || "inline";
|
|
796
|
+
if (e.id.startsWith("custom_") && k)
|
|
990
797
|
try {
|
|
991
|
-
const
|
|
992
|
-
if (
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
798
|
+
const o = await k(e);
|
|
799
|
+
if (o) {
|
|
800
|
+
const l = o.metadata?.mode || t;
|
|
801
|
+
J(l, {
|
|
802
|
+
alias: o.label,
|
|
803
|
+
category: o.category,
|
|
804
|
+
metadata: o.metadata,
|
|
805
|
+
defaultValue: o.defaultValue
|
|
806
|
+
}), r(!1);
|
|
999
807
|
return;
|
|
1000
808
|
}
|
|
1001
|
-
} catch (
|
|
1002
|
-
console.error("Field creation failed:",
|
|
809
|
+
} catch (o) {
|
|
810
|
+
console.error("Field creation failed:", o);
|
|
1003
811
|
}
|
|
1004
|
-
|
|
1005
|
-
alias:
|
|
1006
|
-
category:
|
|
1007
|
-
metadata:
|
|
1008
|
-
defaultValue:
|
|
1009
|
-
}),
|
|
812
|
+
J(t, {
|
|
813
|
+
alias: e.label,
|
|
814
|
+
category: e.category,
|
|
815
|
+
metadata: e.metadata,
|
|
816
|
+
defaultValue: e.defaultValue
|
|
817
|
+
}), r(!1);
|
|
1010
818
|
},
|
|
1011
|
-
[
|
|
1012
|
-
),
|
|
1013
|
-
|
|
1014
|
-
}, [
|
|
1015
|
-
if (!
|
|
819
|
+
[J, k, V]
|
|
820
|
+
), Ce = F(() => {
|
|
821
|
+
r(!1), B.current = null, V(), R.current && (R.current(), R.current = null);
|
|
822
|
+
}, [V]), Fe = F(() => {
|
|
823
|
+
if (!C.current?.activeEditor || u.length === 0)
|
|
1016
824
|
return;
|
|
1017
|
-
const
|
|
1018
|
-
(
|
|
1019
|
-
),
|
|
1020
|
-
|
|
1021
|
-
}, [
|
|
1022
|
-
if (!
|
|
825
|
+
const e = u.findIndex(
|
|
826
|
+
(o) => o.id === I
|
|
827
|
+
), t = e >= 0 ? (e + 1) % u.length : 0;
|
|
828
|
+
z(u[t].id);
|
|
829
|
+
}, [u, I, z]), we = F(() => {
|
|
830
|
+
if (!C.current?.activeEditor || u.length === 0)
|
|
1023
831
|
return;
|
|
1024
|
-
const
|
|
1025
|
-
(
|
|
1026
|
-
),
|
|
1027
|
-
|
|
1028
|
-
}, [
|
|
1029
|
-
async (
|
|
832
|
+
const e = u.findIndex(
|
|
833
|
+
(o) => o.id === I
|
|
834
|
+
), t = e > 0 ? e - 1 : u.length - 1;
|
|
835
|
+
z(u[t].id);
|
|
836
|
+
}, [u, I, z]), ke = F(
|
|
837
|
+
async (e) => {
|
|
838
|
+
const { fileName: t = "document", triggerDownload: o = !0 } = e || {};
|
|
1030
839
|
try {
|
|
1031
|
-
await
|
|
840
|
+
return await C.current?.export({
|
|
1032
841
|
exportType: ["docx"],
|
|
1033
|
-
exportedName: t
|
|
842
|
+
exportedName: t,
|
|
843
|
+
triggerDownload: o
|
|
1034
844
|
});
|
|
1035
|
-
} catch (
|
|
1036
|
-
throw console.error("Failed to export DOCX",
|
|
845
|
+
} catch (l) {
|
|
846
|
+
throw console.error("Failed to export DOCX", l), l;
|
|
1037
847
|
}
|
|
1038
848
|
},
|
|
1039
849
|
[]
|
|
1040
850
|
);
|
|
1041
|
-
|
|
1042
|
-
insertField: (
|
|
1043
|
-
insertBlockField: (
|
|
1044
|
-
updateField:
|
|
1045
|
-
deleteField:
|
|
1046
|
-
selectField:
|
|
1047
|
-
nextField:
|
|
1048
|
-
previousField:
|
|
1049
|
-
getFields: () =>
|
|
1050
|
-
exportTemplate:
|
|
851
|
+
De(f, () => ({
|
|
852
|
+
insertField: (e) => J("inline", e),
|
|
853
|
+
insertBlockField: (e) => J("block", e),
|
|
854
|
+
updateField: oe,
|
|
855
|
+
deleteField: ie,
|
|
856
|
+
selectField: z,
|
|
857
|
+
nextField: Fe,
|
|
858
|
+
previousField: we,
|
|
859
|
+
getFields: () => u,
|
|
860
|
+
exportTemplate: ke
|
|
1051
861
|
}));
|
|
1052
|
-
const
|
|
1053
|
-
return /* @__PURE__ */
|
|
862
|
+
const Me = n.component || Ne, pe = p.component || Re, O = Be(H);
|
|
863
|
+
return /* @__PURE__ */ g(
|
|
1054
864
|
"div",
|
|
1055
865
|
{
|
|
1056
|
-
className: `superdoc-template-builder ${
|
|
1057
|
-
style:
|
|
866
|
+
className: `superdoc-template-builder ${te || ""}`,
|
|
867
|
+
style: Q,
|
|
1058
868
|
children: [
|
|
1059
|
-
/* @__PURE__ */
|
|
1060
|
-
|
|
1061
|
-
|
|
869
|
+
/* @__PURE__ */ g("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
870
|
+
p.position === "left" && /* @__PURE__ */ i("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ i(
|
|
871
|
+
pe,
|
|
1062
872
|
{
|
|
1063
|
-
fields:
|
|
1064
|
-
onSelect: (
|
|
1065
|
-
onDelete:
|
|
1066
|
-
onUpdate: (
|
|
1067
|
-
selectedFieldId:
|
|
873
|
+
fields: u,
|
|
874
|
+
onSelect: (e) => z(e.id),
|
|
875
|
+
onDelete: ie,
|
|
876
|
+
onUpdate: (e) => oe(e.id, e),
|
|
877
|
+
selectedFieldId: I || void 0
|
|
1068
878
|
}
|
|
1069
879
|
) }),
|
|
1070
|
-
/* @__PURE__ */
|
|
1071
|
-
|
|
880
|
+
/* @__PURE__ */ g("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
881
|
+
O?.renderDefaultContainer && /* @__PURE__ */ i(
|
|
1072
882
|
"div",
|
|
1073
883
|
{
|
|
1074
884
|
id: "superdoc-toolbar",
|
|
@@ -1076,48 +886,48 @@ const Be = ({
|
|
|
1076
886
|
"data-testid": "template-builder-toolbar"
|
|
1077
887
|
}
|
|
1078
888
|
),
|
|
1079
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ i(
|
|
1080
890
|
"div",
|
|
1081
891
|
{
|
|
1082
|
-
ref:
|
|
892
|
+
ref: q,
|
|
1083
893
|
className: "superdoc-template-builder-editor",
|
|
1084
|
-
style: { height:
|
|
894
|
+
style: { height: X },
|
|
1085
895
|
"data-testid": "template-builder-editor"
|
|
1086
896
|
}
|
|
1087
897
|
)
|
|
1088
898
|
] }),
|
|
1089
|
-
|
|
1090
|
-
|
|
899
|
+
p.position === "right" && /* @__PURE__ */ i("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ i(
|
|
900
|
+
pe,
|
|
1091
901
|
{
|
|
1092
|
-
fields:
|
|
1093
|
-
onSelect: (
|
|
1094
|
-
onDelete:
|
|
1095
|
-
onUpdate: (
|
|
1096
|
-
selectedFieldId:
|
|
902
|
+
fields: u,
|
|
903
|
+
onSelect: (e) => z(e.id),
|
|
904
|
+
onDelete: ie,
|
|
905
|
+
onUpdate: (e) => oe(e.id, e),
|
|
906
|
+
selectedFieldId: I || void 0
|
|
1097
907
|
}
|
|
1098
908
|
) })
|
|
1099
909
|
] }),
|
|
1100
|
-
/* @__PURE__ */
|
|
1101
|
-
|
|
910
|
+
/* @__PURE__ */ i(
|
|
911
|
+
Me,
|
|
1102
912
|
{
|
|
1103
|
-
isVisible:
|
|
1104
|
-
position:
|
|
913
|
+
isVisible: W,
|
|
914
|
+
position: x,
|
|
1105
915
|
availableFields: c.available || [],
|
|
1106
|
-
filteredFields:
|
|
1107
|
-
filterQuery:
|
|
916
|
+
filteredFields: N,
|
|
917
|
+
filterQuery: h,
|
|
1108
918
|
allowCreate: c.allowCreate || !1,
|
|
1109
|
-
onSelect:
|
|
1110
|
-
onClose:
|
|
1111
|
-
onCreateField:
|
|
919
|
+
onSelect: ve,
|
|
920
|
+
onClose: Ce,
|
|
921
|
+
onCreateField: k
|
|
1112
922
|
}
|
|
1113
923
|
)
|
|
1114
924
|
]
|
|
1115
925
|
}
|
|
1116
926
|
);
|
|
1117
927
|
});
|
|
1118
|
-
|
|
928
|
+
Pe.displayName = "SuperDocTemplateBuilder";
|
|
1119
929
|
export {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
930
|
+
Re as FieldList,
|
|
931
|
+
Ne as FieldMenu,
|
|
932
|
+
Pe as default
|
|
1123
933
|
};
|