@blocklet/pages-kit-inner-components 0.6.18 → 0.6.19
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/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{draft-data-CVjF01PQ.js → draft-data-BM4piqW0.js} +1 -1
- package/lib/cjs/chunks/{home-BarvCpAK.js → home--QTzptul.js} +2 -2
- package/lib/cjs/chunks/index-CKYYXx-8.js +475 -0
- package/lib/cjs/chunks/{publish-button-CNo2gT6Q.js → publish-button-B0Ubvq3p.js} +1 -1
- package/lib/cjs/chunks/state-tEydRMV8.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/setting.js +1 -1
- package/lib/es/add-component.js +6 -8
- package/lib/es/chunks/{draft-data-BiayOfQz.js → draft-data-CpCuyq4R.js} +1 -1
- package/lib/es/chunks/{home-DBc-g4K0.js → home-B1QFMvMR.js} +3 -3
- package/lib/es/chunks/{index-DaF8ujCZ.js → index-D3m-37ll.js} +542 -471
- package/lib/es/chunks/{publish-button-DiKDLFU8.js → publish-button-BUo0AlQd.js} +3 -3
- package/lib/es/chunks/state-DSo43FAB.js +601 -0
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +13 -4
- package/lib/es/setting.js +1 -1
- package/package.json +12 -12
- package/lib/cjs/chunks/index-DH8UBqWG.js +0 -475
- package/lib/cjs/chunks/state-DCxHc_MB.js +0 -1
- package/lib/es/chunks/state-C3hsEhCe.js +0 -569
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as t, jsxs as m, Fragment as oe } from "react/jsx-runtime";
|
|
2
|
-
import { u as ae, b as le } from "./state-
|
|
2
|
+
import { u as ae, b as le } from "./state-DSo43FAB.js";
|
|
3
3
|
import { useLocaleContext as G } from "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import q from "@arcblock/ux/lib/Toast";
|
|
5
5
|
import { generateParamCombinations as ce } from "@blocklet/pages-kit/utils/route";
|
|
@@ -10,8 +10,8 @@ import { produce as De } from "immer";
|
|
|
10
10
|
import Z from "lodash/difference";
|
|
11
11
|
import { useState as D, useMemo as C, useCallback as O, useImperativeHandle as Oe, useEffect as E, useRef as Ae } from "react";
|
|
12
12
|
import { useAsync as je } from "react-use";
|
|
13
|
-
import { L as ve } from "./home-
|
|
14
|
-
import { p as Ce, g as Re } from "./index-
|
|
13
|
+
import { L as ve } from "./home-B1QFMvMR.js";
|
|
14
|
+
import { p as Ce, g as Re } from "./index-D3m-37ll.js";
|
|
15
15
|
function ze(s) {
|
|
16
16
|
const [u, g] = D(!1);
|
|
17
17
|
return /* @__PURE__ */ t(
|
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
import { jsx as K } from "react/jsx-runtime";
|
|
2
|
+
import { joinURL as N, withQuery as V } from "ufo";
|
|
3
|
+
import { createAxios as z } from "@blocklet/js-sdk";
|
|
4
|
+
import Q from "lodash/isEmpty";
|
|
5
|
+
import * as X from "yaml";
|
|
6
|
+
import { useLocaleContext as q } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import { nextId as M } from "@blocklet/pages-kit/utils/common";
|
|
8
|
+
import { getPageTemplateModel as Y } from "@blocklet/pages-kit/utils/page-model";
|
|
9
|
+
import "@mui/material";
|
|
10
|
+
import Z, { getYjsDoc as H } from "@syncedstore/core";
|
|
11
|
+
import { useSyncedStore as ee } from "@syncedstore/react";
|
|
12
|
+
import { useLocalStorageState as te } from "ahooks";
|
|
13
|
+
import { produce as L } from "immer";
|
|
14
|
+
import J from "lodash/cloneDeep";
|
|
15
|
+
import T from "lodash/debounce";
|
|
16
|
+
import { createContext as oe, useState as R, useRef as ne, useMemo as y, useCallback as _, useEffect as D, useContext as re } from "react";
|
|
17
|
+
import { useParams as se, useNavigate as ce } from "react-router-dom";
|
|
18
|
+
import { IndexeddbPersistence as ie } from "y-indexeddb";
|
|
19
|
+
import { WebsocketProvider as ae } from "y-websocket";
|
|
20
|
+
import { UndoManager as de } from "yjs";
|
|
21
|
+
import "@blocklet/pages-kit/types";
|
|
22
|
+
function le() {
|
|
23
|
+
const { pathname: n } = window.location, p = n.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2], l = window.__PROJECT_ID__;
|
|
24
|
+
if (!p && !l)
|
|
25
|
+
throw new Error("Unable to get projectId from pathname");
|
|
26
|
+
return p || l;
|
|
27
|
+
}
|
|
28
|
+
function Ue(n) {
|
|
29
|
+
return `${n}:pages:version`;
|
|
30
|
+
}
|
|
31
|
+
function Fe(n, o) {
|
|
32
|
+
return o === "yaml" ? Q(n) ? "" : X.stringify(n, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(n || {})) : o === "array" ? JSON.parse(JSON.stringify(n || [])) : n;
|
|
33
|
+
}
|
|
34
|
+
const $ = window.blocklet?.prefix || "/", G = z({
|
|
35
|
+
timeout: 200 * 1e3
|
|
36
|
+
}), ue = window.location.protocol === "https:" ? "wss" : "ws", We = (n) => N(`${ue}://${window.location.hostname}`, $, `api/${n}/ws/pages`), pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
37
|
+
blocklet?.componentMountPoints.find((n) => n.did === pe)?.mountPoint || N($, "/image-bin");
|
|
38
|
+
function Ke(n) {
|
|
39
|
+
return n && !/^(https?:\/\/|\/)/.test(n) ? window.location.origin + N($, "uploads", n) : n;
|
|
40
|
+
}
|
|
41
|
+
const fe = window.innerWidth <= 750;
|
|
42
|
+
function Ve(n, o, p) {
|
|
43
|
+
if (!n || /\.gif/.test(n)) return n;
|
|
44
|
+
const l = (fe ? o / 1.5 : o) * (p === "quality" ? 1.5 : 1);
|
|
45
|
+
return ge(n, { imageFilter: "resize", w: l, f: "webp" });
|
|
46
|
+
}
|
|
47
|
+
function ge(n, o) {
|
|
48
|
+
return !n || !o ? n : V(n, o);
|
|
49
|
+
}
|
|
50
|
+
async function me(n) {
|
|
51
|
+
return G.get(`/api/projects/${n}`).then((o) => o.data);
|
|
52
|
+
}
|
|
53
|
+
async function Se(n) {
|
|
54
|
+
return G.post(`/api/projects/${n.id}/update`, n).then((o) => o.data);
|
|
55
|
+
}
|
|
56
|
+
const Pe = 500, B = oe(null);
|
|
57
|
+
function ze({
|
|
58
|
+
url: n,
|
|
59
|
+
name: o,
|
|
60
|
+
children: p,
|
|
61
|
+
waitingSynced: l
|
|
62
|
+
}) {
|
|
63
|
+
const [w, g] = R(!1), { locale: u } = q(), m = U(), C = `${m}:MakerLocalState`, e = `${m}:${o}`, [t, s] = te(C, {
|
|
64
|
+
defaultValue: {},
|
|
65
|
+
listenStorageChange: !0
|
|
66
|
+
}), r = ne(t);
|
|
67
|
+
r.current = t;
|
|
68
|
+
const i = y(
|
|
69
|
+
() => Z({
|
|
70
|
+
dataSourceIds: [],
|
|
71
|
+
dataSources: {},
|
|
72
|
+
pages: {},
|
|
73
|
+
pageIds: [],
|
|
74
|
+
routes: {},
|
|
75
|
+
routeIds: [],
|
|
76
|
+
components: {},
|
|
77
|
+
supportedLocales: [],
|
|
78
|
+
config: {},
|
|
79
|
+
resources: {}
|
|
80
|
+
}),
|
|
81
|
+
[]
|
|
82
|
+
), c = y(() => H(i), [i]);
|
|
83
|
+
y(() => new ie(e, c), [e, c]);
|
|
84
|
+
const a = y(
|
|
85
|
+
() => new ae(n, e, c, {
|
|
86
|
+
params: {},
|
|
87
|
+
resyncInterval: 5 * 60 * 1e3
|
|
88
|
+
}),
|
|
89
|
+
[n, e, c]
|
|
90
|
+
), d = _(() => {
|
|
91
|
+
a && (a.disconnect(), a.connect());
|
|
92
|
+
}, [a]), S = y(
|
|
93
|
+
() => new de(
|
|
94
|
+
[
|
|
95
|
+
c.getArray("pageIds"),
|
|
96
|
+
c.getMap("pages"),
|
|
97
|
+
c.getArray("supportedLocales"),
|
|
98
|
+
c.getMap("config"),
|
|
99
|
+
c.getMap("dataSources"),
|
|
100
|
+
c.getArray("dataSourceIds"),
|
|
101
|
+
c.getArray("routeIds"),
|
|
102
|
+
c.getMap("routes")
|
|
103
|
+
],
|
|
104
|
+
{ doc: c }
|
|
105
|
+
),
|
|
106
|
+
[c]
|
|
107
|
+
), [v, b] = R(null), [x, A] = R(!1), [O, E] = R(void 0), j = _(async () => {
|
|
108
|
+
if (m) {
|
|
109
|
+
A(!0);
|
|
110
|
+
try {
|
|
111
|
+
const f = await me(m);
|
|
112
|
+
b(f);
|
|
113
|
+
} catch (f) {
|
|
114
|
+
console.error("Failed to fetch project:", f);
|
|
115
|
+
} finally {
|
|
116
|
+
A(!1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, [m]), k = _(
|
|
120
|
+
async (f, P) => {
|
|
121
|
+
if (E(void 0), !!m) {
|
|
122
|
+
P?.optimisticUpdate && v && b((I) => ({
|
|
123
|
+
...I,
|
|
124
|
+
...f
|
|
125
|
+
}));
|
|
126
|
+
try {
|
|
127
|
+
const I = await Se({
|
|
128
|
+
...f
|
|
129
|
+
});
|
|
130
|
+
b(I);
|
|
131
|
+
} catch (I) {
|
|
132
|
+
console.error("Failed to update project:", I), P?.optimisticUpdate && b(v), E(I?.response?.data);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
[m, v]
|
|
137
|
+
);
|
|
138
|
+
D(() => {
|
|
139
|
+
m && j();
|
|
140
|
+
}, [m, j]);
|
|
141
|
+
const W = y(
|
|
142
|
+
() => ({
|
|
143
|
+
doc: c,
|
|
144
|
+
state: i,
|
|
145
|
+
localState: {
|
|
146
|
+
...t,
|
|
147
|
+
// always use the locale from the context
|
|
148
|
+
currentLocale: u
|
|
149
|
+
},
|
|
150
|
+
setLocalState: (f) => s(typeof f == "function" ? (P) => f(P ?? {}) : f),
|
|
151
|
+
undoManager: S,
|
|
152
|
+
projectState: {
|
|
153
|
+
project: v,
|
|
154
|
+
isLoadingProject: x,
|
|
155
|
+
error: O
|
|
156
|
+
},
|
|
157
|
+
updateProject: k,
|
|
158
|
+
forceSync: d
|
|
159
|
+
}),
|
|
160
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
161
|
+
[
|
|
162
|
+
c,
|
|
163
|
+
i,
|
|
164
|
+
JSON.stringify(t),
|
|
165
|
+
// resolve the problem of react warning
|
|
166
|
+
s,
|
|
167
|
+
S,
|
|
168
|
+
v,
|
|
169
|
+
x,
|
|
170
|
+
k,
|
|
171
|
+
O,
|
|
172
|
+
u,
|
|
173
|
+
d
|
|
174
|
+
]
|
|
175
|
+
);
|
|
176
|
+
return D(() => {
|
|
177
|
+
S.on("stack-item-added", ({ stackItem: f }) => {
|
|
178
|
+
const { currentPageId: P, currentLocale: I, pages: h } = r.current;
|
|
179
|
+
f.meta.set("localState", { currentPageId: P, currentLocale: I, pages: h });
|
|
180
|
+
}), S.on("stack-item-popped", ({ stackItem: f }) => {
|
|
181
|
+
const P = f.meta.get("localState");
|
|
182
|
+
P && s((I) => ({ ...I, ...P }));
|
|
183
|
+
});
|
|
184
|
+
}, [S, s]), D(() => {
|
|
185
|
+
a.awareness.setLocalState(t);
|
|
186
|
+
}, [a, t]), D(() => {
|
|
187
|
+
a.once("synced", () => g(!0));
|
|
188
|
+
const f = () => {
|
|
189
|
+
s((h) => ({
|
|
190
|
+
...h,
|
|
191
|
+
networkStatus: void 0
|
|
192
|
+
}));
|
|
193
|
+
}, P = () => {
|
|
194
|
+
s((h) => ({
|
|
195
|
+
...h,
|
|
196
|
+
networkStatus: "offline"
|
|
197
|
+
}));
|
|
198
|
+
}, I = T(({ status: h }) => {
|
|
199
|
+
h === "connected" ? f() : h === "disconnected" && P();
|
|
200
|
+
}, Pe);
|
|
201
|
+
return a.on("status", I), window.addEventListener("online", f), window.addEventListener("offline", P), () => {
|
|
202
|
+
a.off("status", I), window.removeEventListener("online", f), window.removeEventListener("offline", P);
|
|
203
|
+
};
|
|
204
|
+
}, [a, s]), l && !w ? null : /* @__PURE__ */ K(B.Provider, { value: W, children: p });
|
|
205
|
+
}
|
|
206
|
+
const Ie = () => {
|
|
207
|
+
const n = re(B);
|
|
208
|
+
if (!n)
|
|
209
|
+
throw new Error("Context is null");
|
|
210
|
+
const o = ee(n.state), { setLocalState: p, localState: l } = n, w = ce(), g = U(), u = y(
|
|
211
|
+
() => ({
|
|
212
|
+
get currentPage() {
|
|
213
|
+
const {
|
|
214
|
+
localState: { currentPageId: e }
|
|
215
|
+
} = n;
|
|
216
|
+
return e ? o.pages[e] : void 0;
|
|
217
|
+
},
|
|
218
|
+
get currentSection() {
|
|
219
|
+
const {
|
|
220
|
+
localState: { currentPageId: e, ...t }
|
|
221
|
+
} = n;
|
|
222
|
+
if (!e)
|
|
223
|
+
return;
|
|
224
|
+
const s = t.pages?.[e]?.currentSectionId;
|
|
225
|
+
if (s)
|
|
226
|
+
return o.pages[e]?.sections[s] ?? this.currentPageModel?.getComponentById(s)?.model;
|
|
227
|
+
},
|
|
228
|
+
get currentSectionProperties() {
|
|
229
|
+
const {
|
|
230
|
+
localState: { currentPageId: e, ...t }
|
|
231
|
+
} = n;
|
|
232
|
+
if (!e)
|
|
233
|
+
return;
|
|
234
|
+
const s = t.pages?.[e]?.currentSectionId;
|
|
235
|
+
if (!s)
|
|
236
|
+
return;
|
|
237
|
+
const r = o.pages[e]?.dataSource?.[s];
|
|
238
|
+
if (!r)
|
|
239
|
+
return;
|
|
240
|
+
const { currentLocale: i } = this.currentLocaleMap;
|
|
241
|
+
return i ? r[i] : void 0;
|
|
242
|
+
},
|
|
243
|
+
get currentSectionPropertiesWithFallback() {
|
|
244
|
+
const {
|
|
245
|
+
localState: { currentPageId: e, ...t }
|
|
246
|
+
} = n;
|
|
247
|
+
if (!e)
|
|
248
|
+
return;
|
|
249
|
+
const s = t.pages?.[e]?.currentSectionId;
|
|
250
|
+
if (!s)
|
|
251
|
+
return;
|
|
252
|
+
const r = o.pages[e]?.dataSource?.[s];
|
|
253
|
+
if (!r)
|
|
254
|
+
return;
|
|
255
|
+
const { currentLocale: i, defaultLocale: c, fallbackLocale: a } = this.currentLocaleMap;
|
|
256
|
+
if (i && r[i])
|
|
257
|
+
return r[i];
|
|
258
|
+
if (c && r[c])
|
|
259
|
+
return r[c];
|
|
260
|
+
if (a && r[a])
|
|
261
|
+
return r[a];
|
|
262
|
+
},
|
|
263
|
+
get currentLocaleMap() {
|
|
264
|
+
const {
|
|
265
|
+
localState: { currentLocale: e },
|
|
266
|
+
state: {
|
|
267
|
+
supportedLocales: t,
|
|
268
|
+
config: { defaultLocale: s }
|
|
269
|
+
}
|
|
270
|
+
} = n;
|
|
271
|
+
return {
|
|
272
|
+
currentLocale: e,
|
|
273
|
+
defaultLocale: s,
|
|
274
|
+
fallbackLocale: t?.[0]?.locale ?? "en"
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
get currentRoute() {
|
|
278
|
+
const {
|
|
279
|
+
localState: { currentRouteId: e }
|
|
280
|
+
} = n;
|
|
281
|
+
return e ? o.routes?.[e] : void 0;
|
|
282
|
+
},
|
|
283
|
+
get currentPageModel() {
|
|
284
|
+
const e = this.currentPage ?? null;
|
|
285
|
+
if (e)
|
|
286
|
+
return Y(e, !1);
|
|
287
|
+
}
|
|
288
|
+
}),
|
|
289
|
+
[JSON.stringify(l), o]
|
|
290
|
+
), m = y(
|
|
291
|
+
() => ({
|
|
292
|
+
setCurrentSectionId: (e, t) => {
|
|
293
|
+
e === l.currentPageId && t === l.pages?.[e]?.currentSectionId || (w(N("/admin/maker", g ?? "", "pages", e)), p(
|
|
294
|
+
(s) => L(s, (r) => {
|
|
295
|
+
r.currentPageId = e, r.currentComponentId = void 0, t !== void 0 && (r.pages ??= {}, r.pages[e] ??= {}, r.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
296
|
+
})
|
|
297
|
+
));
|
|
298
|
+
},
|
|
299
|
+
setCurrentComponentId: (e) => {
|
|
300
|
+
e !== l.currentComponentId && (w(N("/admin/maker", g ?? "", "components", e)), p(
|
|
301
|
+
(t) => L(t, (s) => {
|
|
302
|
+
s.currentComponentId = e;
|
|
303
|
+
})
|
|
304
|
+
));
|
|
305
|
+
},
|
|
306
|
+
setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
|
|
307
|
+
p(
|
|
308
|
+
(s) => L(s, (r) => {
|
|
309
|
+
r.currentRouteId = e, r.currentDynamicParams = t;
|
|
310
|
+
})
|
|
311
|
+
);
|
|
312
|
+
},
|
|
313
|
+
// 本地缓存组件调试参数,避免用户切换组件后,需要重新输入
|
|
314
|
+
setCustomComponentPreviewerProperties: (() => {
|
|
315
|
+
const e = {};
|
|
316
|
+
let t = "";
|
|
317
|
+
const s = T(() => {
|
|
318
|
+
p(
|
|
319
|
+
(r) => L(r, (i) => {
|
|
320
|
+
i.customComponentPreviewerProperties ??= {}, i.customComponentPreviewerProperties[t] = {
|
|
321
|
+
...i.customComponentPreviewerProperties[t],
|
|
322
|
+
...J(e[t])
|
|
323
|
+
}, delete e[t];
|
|
324
|
+
})
|
|
325
|
+
);
|
|
326
|
+
}, 5);
|
|
327
|
+
return (r, i) => {
|
|
328
|
+
const c = e[r] ?? {};
|
|
329
|
+
Object.assign(c, i), e[r] = c, t = r, s();
|
|
330
|
+
};
|
|
331
|
+
})(),
|
|
332
|
+
setRouteGenerateProcess: (e) => {
|
|
333
|
+
p(
|
|
334
|
+
(t) => L(t, (s) => {
|
|
335
|
+
e ? s.routeGenerateProcess = {
|
|
336
|
+
...s.routeGenerateProcess,
|
|
337
|
+
...e
|
|
338
|
+
} : s.routeGenerateProcess = {};
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
},
|
|
342
|
+
resetRouteGenerateProcess: () => {
|
|
343
|
+
p(
|
|
344
|
+
(e) => L(e, (t) => {
|
|
345
|
+
t.routeGenerateProcess = {
|
|
346
|
+
progress: "complete"
|
|
347
|
+
};
|
|
348
|
+
})
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}),
|
|
352
|
+
[p, w, g, u]
|
|
353
|
+
), C = y(
|
|
354
|
+
() => ({
|
|
355
|
+
addPage: (e, t) => {
|
|
356
|
+
const s = e?.id ?? M(), r = {
|
|
357
|
+
...e,
|
|
358
|
+
id: s,
|
|
359
|
+
createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
360
|
+
updatedAt: e?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
361
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
362
|
+
slug: e?.slug ?? `/${s}`,
|
|
363
|
+
sections: e?.sections ?? {},
|
|
364
|
+
sectionIds: e?.sectionIds ?? [],
|
|
365
|
+
isPublic: e?.isPublic ?? !0,
|
|
366
|
+
templateConfig: e?.templateConfig ?? {
|
|
367
|
+
isTemplate: e?.templateConfig?.isTemplate ?? !0,
|
|
368
|
+
displayTemplateId: e?.templateConfig?.displayTemplateId ?? void 0,
|
|
369
|
+
dataSourceIds: e?.templateConfig?.dataSourceIds ?? void 0,
|
|
370
|
+
dataSourceParameters: e?.templateConfig?.dataSourceParameters ?? {},
|
|
371
|
+
enabledGenerate: e?.templateConfig?.enabledGenerate ?? !1,
|
|
372
|
+
agentId: e?.templateConfig?.agentId ?? void 0
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return n.doc.transact(() => {
|
|
376
|
+
o.pages[r.id] = r, o.pageIds.splice(t ?? o.pageIds.length, 0, r.id);
|
|
377
|
+
}), r;
|
|
378
|
+
},
|
|
379
|
+
addRoute: (e, t) => {
|
|
380
|
+
const s = e?.id ?? M(), r = {
|
|
381
|
+
...e,
|
|
382
|
+
id: s,
|
|
383
|
+
createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
384
|
+
updatedAt: e?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
385
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
386
|
+
path: e?.path ?? `/${s}`,
|
|
387
|
+
handler: e?.handler ?? "Pages Kit",
|
|
388
|
+
isPublic: e?.isPublic ?? !0,
|
|
389
|
+
params: e?.params ?? [],
|
|
390
|
+
enabledGenerate: e?.enabledGenerate ?? !1,
|
|
391
|
+
displayTemplateId: e?.displayTemplateId ?? void 0,
|
|
392
|
+
dataSource: e?.dataSource ?? {}
|
|
393
|
+
};
|
|
394
|
+
return n.doc.transact(() => {
|
|
395
|
+
o.routes ??= {}, o.routeIds ??= [], o.routes[r.id] = r, o.routeIds.splice(t ?? o.routeIds.length, 0, r.id);
|
|
396
|
+
}), r;
|
|
397
|
+
},
|
|
398
|
+
deleteRoute: (e) => {
|
|
399
|
+
if (!e)
|
|
400
|
+
return;
|
|
401
|
+
const t = o.routeIds?.indexOf(e);
|
|
402
|
+
t !== void 0 && t !== -1 && n.doc.transact(() => {
|
|
403
|
+
o.routeIds?.splice(t, 1), delete o.routes?.[e];
|
|
404
|
+
});
|
|
405
|
+
},
|
|
406
|
+
deletePage: (e) => {
|
|
407
|
+
const t = o.pageIds.indexOf(e);
|
|
408
|
+
t !== -1 && n.doc.transact(() => {
|
|
409
|
+
o.pageIds.splice(t, 1), delete o.pages[e];
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
movePage: (e, t) => {
|
|
413
|
+
const { pageIds: s } = o, r = s.indexOf(e);
|
|
414
|
+
r >= 0 && s.splice(t, 0, ...s.splice(r, 1));
|
|
415
|
+
},
|
|
416
|
+
addSection: (e, t, s, r) => {
|
|
417
|
+
const i = o.pages[e];
|
|
418
|
+
if (!i)
|
|
419
|
+
throw new Error(`Page ${e} is not exists`);
|
|
420
|
+
const c = {
|
|
421
|
+
...t,
|
|
422
|
+
id: t.id ?? M(),
|
|
423
|
+
isTemplateSection: t.isTemplateSection ?? !0,
|
|
424
|
+
llmConfig: t.llmConfig ?? {}
|
|
425
|
+
}, a = J(c.locales);
|
|
426
|
+
return delete c.locales, n.doc.transact(() => {
|
|
427
|
+
if (r && r.component === "layout-block") {
|
|
428
|
+
const d = u.currentPageModel?.getComponentById(r.id);
|
|
429
|
+
d && (d.model.sections ??= {}, d.model.sections[c.id] = c, d.model.sectionIds ??= [], d.model.sectionIds.push(c.id));
|
|
430
|
+
} else
|
|
431
|
+
i.sections[c.id] = c, i.sectionIds.splice(s ?? i.sectionIds.length, 0, c.id);
|
|
432
|
+
a && (i.dataSource ??= {}, i.dataSource[c.id] = a);
|
|
433
|
+
}), c;
|
|
434
|
+
},
|
|
435
|
+
deleteSection: (e, t) => {
|
|
436
|
+
const s = o.pages[e];
|
|
437
|
+
if (!s)
|
|
438
|
+
throw new Error(`Page ${e} is not exists`);
|
|
439
|
+
n.doc.transact(() => {
|
|
440
|
+
const r = [], i = u.currentPageModel?.getComponentById(t), c = i?.parent;
|
|
441
|
+
if (i && (r.push(i.model.id, ...i.all().map((a) => a.model.id)), c?.model.component === "layout-block")) {
|
|
442
|
+
const a = c.model.sectionIds?.indexOf(t);
|
|
443
|
+
a !== void 0 && a !== -1 && (c.model.sectionIds?.splice(a, 1), delete c.model.sections?.[t]), c.model.config?.gridSettings && Object.keys(c.model.config.gridSettings).forEach((d) => {
|
|
444
|
+
try {
|
|
445
|
+
delete c.model.config.gridSettings[d]?.[t];
|
|
446
|
+
} catch {
|
|
447
|
+
}
|
|
448
|
+
}), c.model.config?.backgroundSectionId === t && (c.model.config.backgroundSectionId = void 0);
|
|
449
|
+
}
|
|
450
|
+
r.forEach((a) => {
|
|
451
|
+
const d = s.sectionIds.indexOf(a);
|
|
452
|
+
d !== -1 && s.sectionIds.splice(d, 1), s.sections[a] && delete s.sections[a], s.dataSource?.[a] && delete s.dataSource?.[a];
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
lockSection: (e, t) => {
|
|
457
|
+
if (!o.pages[e])
|
|
458
|
+
throw new Error(`Page ${e} is not exists`);
|
|
459
|
+
const r = u.currentPageModel?.getComponentById(t)?.model;
|
|
460
|
+
r && (r.locked = !r.locked);
|
|
461
|
+
},
|
|
462
|
+
toggleSectionVisibility: (e, t, s) => {
|
|
463
|
+
if (!o.pages[e])
|
|
464
|
+
throw new Error(`Page ${e} is not exists`);
|
|
465
|
+
const i = u.currentPageModel?.getComponentById(t)?.model;
|
|
466
|
+
i && (i.visibility = s);
|
|
467
|
+
},
|
|
468
|
+
moveSection: (e, t, s, r) => {
|
|
469
|
+
if (!o.pages[e])
|
|
470
|
+
throw new Error(`Page ${e} is not exists`);
|
|
471
|
+
if (r && r !== t) {
|
|
472
|
+
const c = u.currentPageModel?.getComponentById(t), a = u.currentPageModel?.getComponentById(r), d = c?.parent, S = a?.parent;
|
|
473
|
+
S && d && S?.model?.id === d?.model?.id ? n.doc.transact(() => {
|
|
474
|
+
d.model.sectionIds.splice(c.getIndex(), 1), d.model.sectionIds.splice(a.getIndex(), 0, t);
|
|
475
|
+
}) : S && d && S?.model?.id !== d?.model?.id && t !== r && !c?.model?.sectionIds?.includes(r) && n.doc.transact(() => {
|
|
476
|
+
S.model.sections[t] = JSON.parse(JSON.stringify(c.model)), S.model.sectionIds.splice(a.getIndex(), 0, t), d.model.sectionIds.splice(c.getIndex(), 1), delete d.model.sections[t];
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
copySection: (e, t) => {
|
|
481
|
+
if (!o.pages[e])
|
|
482
|
+
throw new Error(`Page ${e} is not exists`);
|
|
483
|
+
const r = u.currentPageModel?.getComponentById(t);
|
|
484
|
+
if (!r?.model)
|
|
485
|
+
throw new Error(`Section ${t} is not exists`);
|
|
486
|
+
const i = JSON.parse(JSON.stringify(r.model)), c = F(i), a = c.id, d = r?.parent;
|
|
487
|
+
if (d) {
|
|
488
|
+
if (d.model.sections[a] = c, d.model.sectionIds.push(a), u.currentPage?.dataSource?.[t] && (u.currentPage.dataSource[a] = JSON.parse(
|
|
489
|
+
JSON.stringify(u.currentPage.dataSource[t])
|
|
490
|
+
), c.component === "layout-block")) {
|
|
491
|
+
const S = (v, b) => {
|
|
492
|
+
v?.forEach((x, A) => {
|
|
493
|
+
const O = b?.[A];
|
|
494
|
+
if (O && u.currentPage?.dataSource) {
|
|
495
|
+
const E = u.currentPage.dataSource[O];
|
|
496
|
+
E && (u.currentPage.dataSource[x] = JSON.parse(JSON.stringify(E)));
|
|
497
|
+
const j = c.sections?.[x], k = i.sections?.[O];
|
|
498
|
+
j?.component === "layout-block" && j.sectionIds && k?.sectionIds && S(j.sectionIds, k.sectionIds);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
c.sectionIds && i.sectionIds && S(c.sectionIds, i.sectionIds);
|
|
503
|
+
}
|
|
504
|
+
m.setCurrentSectionId(e, a);
|
|
505
|
+
}
|
|
506
|
+
return c;
|
|
507
|
+
},
|
|
508
|
+
addDataSource: (e) => {
|
|
509
|
+
const t = e.id ?? M(), s = {
|
|
510
|
+
...e ?? {},
|
|
511
|
+
id: t,
|
|
512
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
513
|
+
};
|
|
514
|
+
return n.doc.transact(() => {
|
|
515
|
+
o.dataSourceIds ??= [], o.dataSources ??= {}, o.dataSourceIds.push(t), o.dataSources[t] = s;
|
|
516
|
+
}), o.dataSources[t];
|
|
517
|
+
},
|
|
518
|
+
deleteDataSource: (e) => {
|
|
519
|
+
const t = o.dataSourceIds.indexOf(e);
|
|
520
|
+
t !== -1 && n.doc.transact(() => {
|
|
521
|
+
o.dataSourceIds.splice(t, 1), delete o.dataSources[e];
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}),
|
|
525
|
+
[o, n.doc, u]
|
|
526
|
+
);
|
|
527
|
+
return {
|
|
528
|
+
...n,
|
|
529
|
+
state: o,
|
|
530
|
+
actions: C,
|
|
531
|
+
localActions: m,
|
|
532
|
+
...u
|
|
533
|
+
};
|
|
534
|
+
}, U = () => {
|
|
535
|
+
const { projectId: n } = se();
|
|
536
|
+
return n ?? le() ?? "";
|
|
537
|
+
}, Qe = () => window.__PROJECT_SLUG__ ?? "";
|
|
538
|
+
function we(n) {
|
|
539
|
+
const { resources: o } = n;
|
|
540
|
+
if (!o.components)
|
|
541
|
+
return {};
|
|
542
|
+
const p = {};
|
|
543
|
+
return window?.blocklet?.componentMountPoints?.forEach((l) => {
|
|
544
|
+
p[l.did] = l;
|
|
545
|
+
}), Object.fromEntries(
|
|
546
|
+
Object.entries(o.components).map(([l, { blockletId: w, component: g }]) => [
|
|
547
|
+
l,
|
|
548
|
+
{ data: g, blockletId: w, blockletTitle: p[w]?.title || w }
|
|
549
|
+
])
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
function ye(n) {
|
|
553
|
+
const { components: o } = n;
|
|
554
|
+
return o || {};
|
|
555
|
+
}
|
|
556
|
+
function he(n) {
|
|
557
|
+
return {
|
|
558
|
+
...we(n),
|
|
559
|
+
...ye(n)
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
const Xe = () => he(Ie().state);
|
|
563
|
+
function F(n) {
|
|
564
|
+
const o = JSON.parse(JSON.stringify(n)), p = M();
|
|
565
|
+
if (o.component === "layout-block") {
|
|
566
|
+
const l = { ...o.config ?? {} }, w = o.sectionIds?.map((g) => {
|
|
567
|
+
const u = o.sections?.[g], m = F(o.sections?.[g]), C = m.id;
|
|
568
|
+
return u?.id === o.config?.backgroundSectionId && (l.backgroundSectionId = m.id), o.config?.gridSettings && Object.keys(o.config.gridSettings).forEach((e) => {
|
|
569
|
+
l.gridSettings[e] = {
|
|
570
|
+
...l.gridSettings[e] ?? {},
|
|
571
|
+
[C]: {
|
|
572
|
+
...o.config?.gridSettings?.[e]?.[g],
|
|
573
|
+
id: C
|
|
574
|
+
}
|
|
575
|
+
}, delete o.config?.gridSettings?.[e]?.[g];
|
|
576
|
+
}), m;
|
|
577
|
+
});
|
|
578
|
+
o.sections = Object.fromEntries(w?.map((g) => [g.id, g]) ?? []), o.sectionIds = w?.map((g) => g.id) ?? [], o.config = l;
|
|
579
|
+
}
|
|
580
|
+
return {
|
|
581
|
+
...o,
|
|
582
|
+
id: p
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
export {
|
|
586
|
+
ze as S,
|
|
587
|
+
Ie as a,
|
|
588
|
+
Ue as b,
|
|
589
|
+
he as c,
|
|
590
|
+
Qe as d,
|
|
591
|
+
Ve as e,
|
|
592
|
+
Ke as f,
|
|
593
|
+
We as g,
|
|
594
|
+
Xe as h,
|
|
595
|
+
G as i,
|
|
596
|
+
ye as j,
|
|
597
|
+
we as k,
|
|
598
|
+
le as l,
|
|
599
|
+
Fe as t,
|
|
600
|
+
U as u
|
|
601
|
+
};
|
package/lib/es/home.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import "./chunks/state-
|
|
2
|
+
import "./chunks/state-DSo43FAB.js";
|
|
3
3
|
import "@arcblock/ux/lib/Locale/context";
|
|
4
4
|
import "@arcblock/ux/lib/Result";
|
|
5
5
|
import "@arcblock/ux/lib/Theme";
|
|
@@ -21,8 +21,8 @@ import "react-helmet";
|
|
|
21
21
|
import "react-router-dom";
|
|
22
22
|
import "react-use";
|
|
23
23
|
import "ufo";
|
|
24
|
-
import "./chunks/index-
|
|
25
|
-
import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-
|
|
24
|
+
import "./chunks/index-D3m-37ll.js";
|
|
25
|
+
import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-B1QFMvMR.js";
|
|
26
26
|
import "./chunks/session-C72Dq8zg.js";
|
|
27
27
|
export {
|
|
28
28
|
R as HomeView,
|
package/lib/es/locales.js
CHANGED
|
@@ -254,9 +254,9 @@ const t = e({
|
|
|
254
254
|
chooseEmbed: "Choose embed",
|
|
255
255
|
translateFrom: "Translate from",
|
|
256
256
|
backgroundColor: "Color",
|
|
257
|
-
backgroundImage: "Image/Video",
|
|
257
|
+
backgroundImage: "Image / Video",
|
|
258
258
|
customColor: "Custom color",
|
|
259
|
-
customImage: "Custom image/video",
|
|
259
|
+
customImage: "Custom image / video",
|
|
260
260
|
boxed: "Nested box mode",
|
|
261
261
|
bigMode: "Big title mode",
|
|
262
262
|
paddingY: "Vertical Padding",
|
|
@@ -302,6 +302,11 @@ const t = e({
|
|
|
302
302
|
mobile: "Mobile",
|
|
303
303
|
desktop: "Desktop",
|
|
304
304
|
columns: "Columns",
|
|
305
|
+
gap: "Gap",
|
|
306
|
+
gapHelper: "Set the gap between components",
|
|
307
|
+
gapUnit: "px",
|
|
308
|
+
padding: "Padding",
|
|
309
|
+
paddingHelper: "Set the padding of the layout",
|
|
305
310
|
visualGridLayout: "Configure Grid Layout",
|
|
306
311
|
dragResizeInstructions: "Drag and resize cards to set layout, you can set different layouts for desktop and mobile",
|
|
307
312
|
setAsBackgroundElement: "Set as background element (cannot drag and resize)",
|
|
@@ -763,9 +768,9 @@ const t = e({
|
|
|
763
768
|
chooseEmbed: "选择部件",
|
|
764
769
|
translateFrom: "翻译来自",
|
|
765
770
|
backgroundColor: "颜色",
|
|
766
|
-
backgroundImage: "
|
|
771
|
+
backgroundImage: "图片 / 视频",
|
|
767
772
|
customColor: "自定义颜色",
|
|
768
|
-
customImage: "
|
|
773
|
+
customImage: "自定义图片 / 视频",
|
|
769
774
|
boxed: "嵌套盒子模式",
|
|
770
775
|
bigMode: "大标题模式",
|
|
771
776
|
paddingY: "上下内边距",
|
|
@@ -811,6 +816,10 @@ const t = e({
|
|
|
811
816
|
mobile: "移动端",
|
|
812
817
|
desktop: "桌面端",
|
|
813
818
|
columns: "列数",
|
|
819
|
+
gap: "间距",
|
|
820
|
+
gapHelper: "设置组件之间的间距",
|
|
821
|
+
padding: "内边距",
|
|
822
|
+
paddingHelper: "设置布局的内边距",
|
|
814
823
|
visualGridLayout: "配置网格布局",
|
|
815
824
|
dragResizeInstructions: "通过调整卡片位置和大小调整布局,可以分别设置桌面端和移动端两种布局",
|
|
816
825
|
setAsBackgroundElement: "设置为背景卡片(无法拖拽排序、无法设置大小)",
|
package/lib/es/setting.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r, jsxs as v, Fragment as F } from "react/jsx-runtime";
|
|
2
2
|
import { Box as P, Alert as Qe, Typography as T, TextField as z, Stack as k, FormLabel as ee, TableContainer as Xe, Paper as G, Table as Oe, TableHead as Ne, TableRow as re, TableCell as te, TableBody as je, Button as E, IconButton as Y, FormControlLabel as be, Switch as ze, InputAdornment as $, alpha as ae, Tooltip as _, buttonClasses as Ze, Dialog as ge, DialogTitle as Ve, DialogContent as Re, DialogActions as Ee, Checkbox as er, Autocomplete as Ae, MenuItem as ce, Collapse as rr, Divider as tr, Popper as nr } from "@mui/material";
|
|
3
|
-
import { t as ye, f as ne, a as oe, h as xe } from "./chunks/state-
|
|
3
|
+
import { t as ye, f as ne, a as oe, h as xe } from "./chunks/state-DSo43FAB.js";
|
|
4
4
|
import q from "@arcblock/ux/lib/Empty";
|
|
5
5
|
import { useLocaleContext as V } from "@arcblock/ux/lib/Locale/context";
|
|
6
6
|
import { CodeEditor as ve } from "@blocklet/code-editor";
|