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