@cmssy/react 14.1.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +23 -55
- package/dist/client.d.cts +4 -4
- package/dist/client.d.ts +4 -4
- package/dist/client.js +20 -52
- package/dist/index.cjs +14 -28
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -25
- package/dist/{internal-server-CP0tEgpM.d.cts → internal-server-Bkracpae.d.cts} +6 -7
- package/dist/{internal-server-CP0tEgpM.d.ts → internal-server-Bkracpae.d.ts} +6 -7
- package/dist/internal-server.cjs +9 -19
- package/dist/internal-server.d.cts +2 -2
- package/dist/internal-server.d.ts +2 -2
- package/dist/internal-server.js +5 -17
- package/package.json +3 -3
package/dist/client.cjs
CHANGED
|
@@ -7,43 +7,11 @@ var internal = require('@cmssy/core/internal');
|
|
|
7
7
|
var blockErrorBoundary = require('@cmssy/react/block-error-boundary');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
|
|
10
|
-
// src/registry.ts
|
|
11
10
|
function buildBlockMap(blocks) {
|
|
12
11
|
const map = /* @__PURE__ */ Object.create(null);
|
|
13
12
|
for (const block of blocks) map[block.type] = block.component;
|
|
14
13
|
return map;
|
|
15
14
|
}
|
|
16
|
-
function propsToSchema(props) {
|
|
17
|
-
const schema = {};
|
|
18
|
-
for (const [key, def] of Object.entries(props)) {
|
|
19
|
-
schema[key] = { ...def, label: def.label || key };
|
|
20
|
-
}
|
|
21
|
-
return schema;
|
|
22
|
-
}
|
|
23
|
-
function blocksToSchemas(blocks) {
|
|
24
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
25
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
26
|
-
return out;
|
|
27
|
-
}
|
|
28
|
-
function layoutRegionsToBridge(regions) {
|
|
29
|
-
return regions.map(
|
|
30
|
-
(region) => region.settings ? { ...region, settings: propsToSchema(region.settings) } : { ...region }
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function blocksToMeta(blocks, defaults = {}) {
|
|
34
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
35
|
-
for (const block of blocks) {
|
|
36
|
-
const category = block.category ?? defaults.category;
|
|
37
|
-
out[block.type] = {
|
|
38
|
-
label: block.label ?? block.type,
|
|
39
|
-
...category ? { category } : {},
|
|
40
|
-
...block.icon ? { icon: block.icon } : {},
|
|
41
|
-
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
42
|
-
...block.description ? { description: block.description } : {}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
15
|
|
|
48
16
|
// src/bridge/shortcut-keys.ts
|
|
49
17
|
function isMacPlatform() {
|
|
@@ -243,16 +211,16 @@ function collectLayoutBlocks(rects, pageIds) {
|
|
|
243
211
|
const out = [];
|
|
244
212
|
if (typeof document === "undefined") return out;
|
|
245
213
|
const seen = /* @__PURE__ */ new Set();
|
|
246
|
-
for (const el of document.querySelectorAll("[data-layout-
|
|
214
|
+
for (const el of document.querySelectorAll("[data-layout-region]")) {
|
|
247
215
|
const id = el.getAttribute("data-block-id");
|
|
248
216
|
const type = el.getAttribute("data-block-type");
|
|
249
|
-
const
|
|
250
|
-
if (id && type &&
|
|
217
|
+
const layoutRegion = el.getAttribute("data-layout-region");
|
|
218
|
+
if (id && type && layoutRegion !== null && !pageIds.has(id) && !seen.has(id)) {
|
|
251
219
|
seen.add(id);
|
|
252
220
|
out.push({
|
|
253
221
|
id,
|
|
254
222
|
type,
|
|
255
|
-
|
|
223
|
+
layoutRegion,
|
|
256
224
|
bounds: rects.get(id) ?? ZERO_RECT
|
|
257
225
|
});
|
|
258
226
|
}
|
|
@@ -322,7 +290,7 @@ function useEditBridge(page, config) {
|
|
|
322
290
|
schemas: config.schemas ?? /* @__PURE__ */ Object.create(null),
|
|
323
291
|
blockMeta: config.blockMeta ?? /* @__PURE__ */ Object.create(null),
|
|
324
292
|
capabilities: canDetectInvisibleBlocks() ? ["shortcuts", "invisible-blocks"] : ["shortcuts"],
|
|
325
|
-
...config.layoutRegions ? { layoutRegions: layoutRegionsToBridge(config.layoutRegions) } : {}
|
|
293
|
+
...config.layoutRegions ? { layoutRegions: core.layoutRegionsToBridge(config.layoutRegions) } : {}
|
|
326
294
|
});
|
|
327
295
|
} catch (error) {
|
|
328
296
|
if (typeof console !== "undefined") {
|
|
@@ -340,7 +308,7 @@ function useEditBridge(page, config) {
|
|
|
340
308
|
if (!message) return;
|
|
341
309
|
postTarget = event.origin;
|
|
342
310
|
if (message.type === "cmssy:patch") {
|
|
343
|
-
if (message.
|
|
311
|
+
if (message.layoutRegion !== void 0) return;
|
|
344
312
|
setPatches((prev) => ({
|
|
345
313
|
...prev,
|
|
346
314
|
[message.blockId]: { ...prev[message.blockId], ...message.content }
|
|
@@ -411,12 +379,12 @@ function useEditBridge(page, config) {
|
|
|
411
379
|
event.stopPropagation();
|
|
412
380
|
}
|
|
413
381
|
const r = el.getBoundingClientRect();
|
|
414
|
-
const
|
|
382
|
+
const layoutRegion = el.getAttribute("data-layout-region");
|
|
415
383
|
postSafe({
|
|
416
384
|
type: "cmssy:click",
|
|
417
385
|
blockId: id,
|
|
418
386
|
rect: { x: r.x, y: r.y, width: r.width, height: r.height },
|
|
419
|
-
...
|
|
387
|
+
...layoutRegion !== null ? { layoutRegion } : {}
|
|
420
388
|
});
|
|
421
389
|
};
|
|
422
390
|
const onKeyDown = (event) => {
|
|
@@ -514,7 +482,7 @@ function visible(el) {
|
|
|
514
482
|
function blockElements() {
|
|
515
483
|
return Array.from(
|
|
516
484
|
document.querySelectorAll(
|
|
517
|
-
"[data-block-id]:not([data-layout-
|
|
485
|
+
"[data-block-id]:not([data-layout-region])"
|
|
518
486
|
)
|
|
519
487
|
).filter(visible);
|
|
520
488
|
}
|
|
@@ -753,7 +721,7 @@ function CmssyBlock({
|
|
|
753
721
|
schema,
|
|
754
722
|
editable,
|
|
755
723
|
editMode,
|
|
756
|
-
|
|
724
|
+
layoutRegion,
|
|
757
725
|
context,
|
|
758
726
|
data
|
|
759
727
|
}) {
|
|
@@ -765,7 +733,7 @@ function CmssyBlock({
|
|
|
765
733
|
{
|
|
766
734
|
"data-block-id": block.id,
|
|
767
735
|
"data-block-type": block.type,
|
|
768
|
-
"data-layout-
|
|
736
|
+
"data-layout-region": layoutRegion,
|
|
769
737
|
draggable: editable || void 0,
|
|
770
738
|
style: hidden ? { display: "none" } : void 0,
|
|
771
739
|
children
|
|
@@ -879,8 +847,8 @@ function EditableBlocks({
|
|
|
879
847
|
const bridgeConfig = react.useMemo(
|
|
880
848
|
() => ({
|
|
881
849
|
...edit,
|
|
882
|
-
schemas: edit.schemas ?? blocksToSchemas(blocks),
|
|
883
|
-
blockMeta: edit.blockMeta ?? blocksToMeta(blocks, { category })
|
|
850
|
+
schemas: edit.schemas ?? core.blocksToSchemas(blocks),
|
|
851
|
+
blockMeta: edit.blockMeta ?? core.blocksToMeta(blocks, { category })
|
|
884
852
|
}),
|
|
885
853
|
[edit, blocks, category]
|
|
886
854
|
);
|
|
@@ -982,7 +950,7 @@ function CmssyLazyEditor({ load, ...props }) {
|
|
|
982
950
|
) : null
|
|
983
951
|
] });
|
|
984
952
|
}
|
|
985
|
-
function useLayoutPatchBridge(
|
|
953
|
+
function useLayoutPatchBridge(region, config) {
|
|
986
954
|
const [patches, setPatches] = react.useState({});
|
|
987
955
|
react.useEffect(() => {
|
|
988
956
|
setPatches({});
|
|
@@ -996,7 +964,7 @@ function useLayoutPatchBridge(position, config) {
|
|
|
996
964
|
editorOrigin
|
|
997
965
|
);
|
|
998
966
|
if (!message) return;
|
|
999
|
-
if (message.type === "cmssy:patch" && message.
|
|
967
|
+
if (message.type === "cmssy:patch" && message.layoutRegion === region) {
|
|
1000
968
|
setPatches((prev) => ({
|
|
1001
969
|
...prev,
|
|
1002
970
|
[message.blockId]: { ...prev[message.blockId], ...message.content }
|
|
@@ -1005,13 +973,13 @@ function useLayoutPatchBridge(position, config) {
|
|
|
1005
973
|
};
|
|
1006
974
|
window.addEventListener("message", handler);
|
|
1007
975
|
return () => window.removeEventListener("message", handler);
|
|
1008
|
-
}, [config.editorOrigin,
|
|
976
|
+
}, [config.editorOrigin, region]);
|
|
1009
977
|
return patches;
|
|
1010
978
|
}
|
|
1011
979
|
function CmssyEditableLayout({
|
|
1012
980
|
groups,
|
|
1013
981
|
blocks,
|
|
1014
|
-
|
|
982
|
+
region,
|
|
1015
983
|
page,
|
|
1016
984
|
locale = "en",
|
|
1017
985
|
defaultLocale = "en",
|
|
@@ -1023,14 +991,14 @@ function CmssyEditableLayout({
|
|
|
1023
991
|
}) {
|
|
1024
992
|
const blockMap = react.useMemo(() => buildBlockMap(blocks), [blocks]);
|
|
1025
993
|
const schemas = react.useMemo(
|
|
1026
|
-
() => edit.schemas ?? blocksToSchemas(blocks),
|
|
994
|
+
() => edit.schemas ?? core.blocksToSchemas(blocks),
|
|
1027
995
|
[edit.schemas, blocks]
|
|
1028
996
|
);
|
|
1029
997
|
const layoutBlocks = react.useMemo(() => {
|
|
1030
|
-
const group = groups.find((g) => g.
|
|
998
|
+
const group = groups.find((g) => g.region === region);
|
|
1031
999
|
return group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
1032
|
-
}, [groups,
|
|
1033
|
-
const patches = useLayoutPatchBridge(
|
|
1000
|
+
}, [groups, region]);
|
|
1001
|
+
const patches = useLayoutPatchBridge(region, edit);
|
|
1034
1002
|
const context = react.useMemo(
|
|
1035
1003
|
() => internal.buildBlockContext(locale, defaultLocale, enabledLocales, true, void 0, {
|
|
1036
1004
|
page,
|
|
@@ -1050,7 +1018,7 @@ function CmssyEditableLayout({
|
|
|
1050
1018
|
resolvedContent: resolvedContent?.[block.id],
|
|
1051
1019
|
schema: schemas[block.type],
|
|
1052
1020
|
editMode: true,
|
|
1053
|
-
|
|
1021
|
+
layoutRegion: region,
|
|
1054
1022
|
context,
|
|
1055
1023
|
data: data?.[block.id]
|
|
1056
1024
|
},
|
|
@@ -1087,7 +1055,7 @@ function CmssyLazyLayout({ load, ...props }) {
|
|
|
1087
1055
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1088
1056
|
"div",
|
|
1089
1057
|
{
|
|
1090
|
-
"data-cmssy-layout-slot": props.
|
|
1058
|
+
"data-cmssy-layout-slot": props.region,
|
|
1091
1059
|
"data-cmssy-editor-content": resolvedCount,
|
|
1092
1060
|
hidden: true
|
|
1093
1061
|
}
|
package/dist/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, LayoutRegion, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-Bkracpae.cjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -71,7 +71,7 @@ declare function CmssyLazyEditor({ load, ...props }: CmssyLazyEditorProps): reac
|
|
|
71
71
|
interface CmssyEditableLayoutProps {
|
|
72
72
|
groups: CmssyLayoutGroup[];
|
|
73
73
|
blocks: BlockDefinition[];
|
|
74
|
-
|
|
74
|
+
region: string;
|
|
75
75
|
page?: LayoutBlockPage;
|
|
76
76
|
locale?: string;
|
|
77
77
|
defaultLocale?: string;
|
|
@@ -81,11 +81,11 @@ interface CmssyEditableLayoutProps {
|
|
|
81
81
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
82
82
|
appContext?: Record<string, unknown>;
|
|
83
83
|
}
|
|
84
|
-
declare function CmssyEditableLayout({ groups, blocks,
|
|
84
|
+
declare function CmssyEditableLayout({ groups, blocks, region, page, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
85
85
|
|
|
86
86
|
interface CmssyLazyLayoutProps {
|
|
87
87
|
groups: CmssyLayoutGroup[];
|
|
88
|
-
|
|
88
|
+
region: string;
|
|
89
89
|
page?: LayoutBlockPage;
|
|
90
90
|
locale?: string;
|
|
91
91
|
defaultLocale?: string;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BlockSchema, BlockMeta, LayoutRegion, CmssyPageData, CmssyFormDefinition, CmssyLayoutGroup } from '@cmssy/core';
|
|
3
|
-
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage } from './internal-server-Bkracpae.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
6
6
|
interface EditBridgeConfig {
|
|
@@ -71,7 +71,7 @@ declare function CmssyLazyEditor({ load, ...props }: CmssyLazyEditorProps): reac
|
|
|
71
71
|
interface CmssyEditableLayoutProps {
|
|
72
72
|
groups: CmssyLayoutGroup[];
|
|
73
73
|
blocks: BlockDefinition[];
|
|
74
|
-
|
|
74
|
+
region: string;
|
|
75
75
|
page?: LayoutBlockPage;
|
|
76
76
|
locale?: string;
|
|
77
77
|
defaultLocale?: string;
|
|
@@ -81,11 +81,11 @@ interface CmssyEditableLayoutProps {
|
|
|
81
81
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
82
82
|
appContext?: Record<string, unknown>;
|
|
83
83
|
}
|
|
84
|
-
declare function CmssyEditableLayout({ groups, blocks,
|
|
84
|
+
declare function CmssyEditableLayout({ groups, blocks, region, page, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, appContext, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
85
85
|
|
|
86
86
|
interface CmssyLazyLayoutProps {
|
|
87
87
|
groups: CmssyLayoutGroup[];
|
|
88
|
-
|
|
88
|
+
region: string;
|
|
89
89
|
page?: LayoutBlockPage;
|
|
90
90
|
locale?: string;
|
|
91
91
|
defaultLocale?: string;
|
package/dist/client.js
CHANGED
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState, useRef, useEffect, useMemo, createElement } from 'react';
|
|
3
|
-
import { postToEditor, PROTOCOL_VERSION, parseEditorMessage } from '@cmssy/core';
|
|
3
|
+
import { blocksToMeta, blocksToSchemas, postToEditor, layoutRegionsToBridge, PROTOCOL_VERSION, parseEditorMessage } from '@cmssy/core';
|
|
4
4
|
import { resolveInitialTarget, buildBlockContext, getBlockContentForLanguage, normalizeBlockContent, asBucket } from '@cmssy/core/internal';
|
|
5
5
|
import { BlockErrorBoundary } from '@cmssy/react/block-error-boundary';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
|
-
// src/registry.ts
|
|
9
8
|
function buildBlockMap(blocks) {
|
|
10
9
|
const map = /* @__PURE__ */ Object.create(null);
|
|
11
10
|
for (const block of blocks) map[block.type] = block.component;
|
|
12
11
|
return map;
|
|
13
12
|
}
|
|
14
|
-
function propsToSchema(props) {
|
|
15
|
-
const schema = {};
|
|
16
|
-
for (const [key, def] of Object.entries(props)) {
|
|
17
|
-
schema[key] = { ...def, label: def.label || key };
|
|
18
|
-
}
|
|
19
|
-
return schema;
|
|
20
|
-
}
|
|
21
|
-
function blocksToSchemas(blocks) {
|
|
22
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
23
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
function layoutRegionsToBridge(regions) {
|
|
27
|
-
return regions.map(
|
|
28
|
-
(region) => region.settings ? { ...region, settings: propsToSchema(region.settings) } : { ...region }
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
function blocksToMeta(blocks, defaults = {}) {
|
|
32
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
33
|
-
for (const block of blocks) {
|
|
34
|
-
const category = block.category ?? defaults.category;
|
|
35
|
-
out[block.type] = {
|
|
36
|
-
label: block.label ?? block.type,
|
|
37
|
-
...category ? { category } : {},
|
|
38
|
-
...block.icon ? { icon: block.icon } : {},
|
|
39
|
-
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
40
|
-
...block.description ? { description: block.description } : {}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return out;
|
|
44
|
-
}
|
|
45
13
|
|
|
46
14
|
// src/bridge/shortcut-keys.ts
|
|
47
15
|
function isMacPlatform() {
|
|
@@ -241,16 +209,16 @@ function collectLayoutBlocks(rects, pageIds) {
|
|
|
241
209
|
const out = [];
|
|
242
210
|
if (typeof document === "undefined") return out;
|
|
243
211
|
const seen = /* @__PURE__ */ new Set();
|
|
244
|
-
for (const el of document.querySelectorAll("[data-layout-
|
|
212
|
+
for (const el of document.querySelectorAll("[data-layout-region]")) {
|
|
245
213
|
const id = el.getAttribute("data-block-id");
|
|
246
214
|
const type = el.getAttribute("data-block-type");
|
|
247
|
-
const
|
|
248
|
-
if (id && type &&
|
|
215
|
+
const layoutRegion = el.getAttribute("data-layout-region");
|
|
216
|
+
if (id && type && layoutRegion !== null && !pageIds.has(id) && !seen.has(id)) {
|
|
249
217
|
seen.add(id);
|
|
250
218
|
out.push({
|
|
251
219
|
id,
|
|
252
220
|
type,
|
|
253
|
-
|
|
221
|
+
layoutRegion,
|
|
254
222
|
bounds: rects.get(id) ?? ZERO_RECT
|
|
255
223
|
});
|
|
256
224
|
}
|
|
@@ -338,7 +306,7 @@ function useEditBridge(page, config) {
|
|
|
338
306
|
if (!message) return;
|
|
339
307
|
postTarget = event.origin;
|
|
340
308
|
if (message.type === "cmssy:patch") {
|
|
341
|
-
if (message.
|
|
309
|
+
if (message.layoutRegion !== void 0) return;
|
|
342
310
|
setPatches((prev) => ({
|
|
343
311
|
...prev,
|
|
344
312
|
[message.blockId]: { ...prev[message.blockId], ...message.content }
|
|
@@ -409,12 +377,12 @@ function useEditBridge(page, config) {
|
|
|
409
377
|
event.stopPropagation();
|
|
410
378
|
}
|
|
411
379
|
const r = el.getBoundingClientRect();
|
|
412
|
-
const
|
|
380
|
+
const layoutRegion = el.getAttribute("data-layout-region");
|
|
413
381
|
postSafe({
|
|
414
382
|
type: "cmssy:click",
|
|
415
383
|
blockId: id,
|
|
416
384
|
rect: { x: r.x, y: r.y, width: r.width, height: r.height },
|
|
417
|
-
...
|
|
385
|
+
...layoutRegion !== null ? { layoutRegion } : {}
|
|
418
386
|
});
|
|
419
387
|
};
|
|
420
388
|
const onKeyDown = (event) => {
|
|
@@ -512,7 +480,7 @@ function visible(el) {
|
|
|
512
480
|
function blockElements() {
|
|
513
481
|
return Array.from(
|
|
514
482
|
document.querySelectorAll(
|
|
515
|
-
"[data-block-id]:not([data-layout-
|
|
483
|
+
"[data-block-id]:not([data-layout-region])"
|
|
516
484
|
)
|
|
517
485
|
).filter(visible);
|
|
518
486
|
}
|
|
@@ -751,7 +719,7 @@ function CmssyBlock({
|
|
|
751
719
|
schema,
|
|
752
720
|
editable,
|
|
753
721
|
editMode,
|
|
754
|
-
|
|
722
|
+
layoutRegion,
|
|
755
723
|
context,
|
|
756
724
|
data
|
|
757
725
|
}) {
|
|
@@ -763,7 +731,7 @@ function CmssyBlock({
|
|
|
763
731
|
{
|
|
764
732
|
"data-block-id": block.id,
|
|
765
733
|
"data-block-type": block.type,
|
|
766
|
-
"data-layout-
|
|
734
|
+
"data-layout-region": layoutRegion,
|
|
767
735
|
draggable: editable || void 0,
|
|
768
736
|
style: hidden ? { display: "none" } : void 0,
|
|
769
737
|
children
|
|
@@ -980,7 +948,7 @@ function CmssyLazyEditor({ load, ...props }) {
|
|
|
980
948
|
) : null
|
|
981
949
|
] });
|
|
982
950
|
}
|
|
983
|
-
function useLayoutPatchBridge(
|
|
951
|
+
function useLayoutPatchBridge(region, config) {
|
|
984
952
|
const [patches, setPatches] = useState({});
|
|
985
953
|
useEffect(() => {
|
|
986
954
|
setPatches({});
|
|
@@ -994,7 +962,7 @@ function useLayoutPatchBridge(position, config) {
|
|
|
994
962
|
editorOrigin
|
|
995
963
|
);
|
|
996
964
|
if (!message) return;
|
|
997
|
-
if (message.type === "cmssy:patch" && message.
|
|
965
|
+
if (message.type === "cmssy:patch" && message.layoutRegion === region) {
|
|
998
966
|
setPatches((prev) => ({
|
|
999
967
|
...prev,
|
|
1000
968
|
[message.blockId]: { ...prev[message.blockId], ...message.content }
|
|
@@ -1003,13 +971,13 @@ function useLayoutPatchBridge(position, config) {
|
|
|
1003
971
|
};
|
|
1004
972
|
window.addEventListener("message", handler);
|
|
1005
973
|
return () => window.removeEventListener("message", handler);
|
|
1006
|
-
}, [config.editorOrigin,
|
|
974
|
+
}, [config.editorOrigin, region]);
|
|
1007
975
|
return patches;
|
|
1008
976
|
}
|
|
1009
977
|
function CmssyEditableLayout({
|
|
1010
978
|
groups,
|
|
1011
979
|
blocks,
|
|
1012
|
-
|
|
980
|
+
region,
|
|
1013
981
|
page,
|
|
1014
982
|
locale = "en",
|
|
1015
983
|
defaultLocale = "en",
|
|
@@ -1025,10 +993,10 @@ function CmssyEditableLayout({
|
|
|
1025
993
|
[edit.schemas, blocks]
|
|
1026
994
|
);
|
|
1027
995
|
const layoutBlocks = useMemo(() => {
|
|
1028
|
-
const group = groups.find((g) => g.
|
|
996
|
+
const group = groups.find((g) => g.region === region);
|
|
1029
997
|
return group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
1030
|
-
}, [groups,
|
|
1031
|
-
const patches = useLayoutPatchBridge(
|
|
998
|
+
}, [groups, region]);
|
|
999
|
+
const patches = useLayoutPatchBridge(region, edit);
|
|
1032
1000
|
const context = useMemo(
|
|
1033
1001
|
() => buildBlockContext(locale, defaultLocale, enabledLocales, true, void 0, {
|
|
1034
1002
|
page,
|
|
@@ -1048,7 +1016,7 @@ function CmssyEditableLayout({
|
|
|
1048
1016
|
resolvedContent: resolvedContent?.[block.id],
|
|
1049
1017
|
schema: schemas[block.type],
|
|
1050
1018
|
editMode: true,
|
|
1051
|
-
|
|
1019
|
+
layoutRegion: region,
|
|
1052
1020
|
context,
|
|
1053
1021
|
data: data?.[block.id]
|
|
1054
1022
|
},
|
|
@@ -1085,7 +1053,7 @@ function CmssyLazyLayout({ load, ...props }) {
|
|
|
1085
1053
|
/* @__PURE__ */ jsx(
|
|
1086
1054
|
"div",
|
|
1087
1055
|
{
|
|
1088
|
-
"data-cmssy-layout-slot": props.
|
|
1056
|
+
"data-cmssy-layout-slot": props.region,
|
|
1089
1057
|
"data-cmssy-editor-content": resolvedCount,
|
|
1090
1058
|
hidden: true
|
|
1091
1059
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -8,8 +8,6 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
8
8
|
var locale = require('@cmssy/core/internal/locale');
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
11
|
-
|
|
12
|
-
// src/registry.ts
|
|
13
11
|
function defineBlock(def) {
|
|
14
12
|
return def;
|
|
15
13
|
}
|
|
@@ -25,18 +23,6 @@ function buildLoaderMap(blocks) {
|
|
|
25
23
|
}
|
|
26
24
|
return map;
|
|
27
25
|
}
|
|
28
|
-
function propsToSchema(props) {
|
|
29
|
-
const schema = {};
|
|
30
|
-
for (const [key, def] of Object.entries(props)) {
|
|
31
|
-
schema[key] = { ...def, label: def.label || key };
|
|
32
|
-
}
|
|
33
|
-
return schema;
|
|
34
|
-
}
|
|
35
|
-
function blocksToSchemas(blocks) {
|
|
36
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
37
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
26
|
|
|
41
27
|
// src/components/block-error.ts
|
|
42
28
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -300,7 +286,7 @@ async function CmssyServerPage({
|
|
|
300
286
|
defaultLocale,
|
|
301
287
|
context,
|
|
302
288
|
enabledLocales,
|
|
303
|
-
{ schemas: blocksToSchemas(blocks), config, workspaceId: workspace?.id }
|
|
289
|
+
{ schemas: core.blocksToSchemas(blocks), config, workspaceId: workspace?.id }
|
|
304
290
|
);
|
|
305
291
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: page.blocks.map(
|
|
306
292
|
(block, i) => renderResolvedBlock(block, map, locale, defaultLocale, {
|
|
@@ -356,14 +342,14 @@ async function resolveEditorBlockData({
|
|
|
356
342
|
defaultLocale,
|
|
357
343
|
context,
|
|
358
344
|
enabledLocales,
|
|
359
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
345
|
+
{ schemas: core.blocksToSchemas(blocks), config }
|
|
360
346
|
);
|
|
361
347
|
return collectBlockData(page.blocks, resolved, isPreview);
|
|
362
348
|
}
|
|
363
349
|
async function resolveEditorLayoutBlockData({
|
|
364
350
|
groups,
|
|
365
351
|
blocks,
|
|
366
|
-
|
|
352
|
+
region,
|
|
367
353
|
page,
|
|
368
354
|
locale,
|
|
369
355
|
defaultLocale,
|
|
@@ -373,7 +359,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
373
359
|
config,
|
|
374
360
|
appContext
|
|
375
361
|
}) {
|
|
376
|
-
const group = groups.find((g) => g.
|
|
362
|
+
const group = groups.find((g) => g.region === region);
|
|
377
363
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
378
364
|
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
379
365
|
const loaderMap = buildLoaderMap(blocks);
|
|
@@ -392,7 +378,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
392
378
|
defaultLocale,
|
|
393
379
|
context,
|
|
394
380
|
enabledLocales,
|
|
395
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
381
|
+
{ schemas: core.blocksToSchemas(blocks), config }
|
|
396
382
|
);
|
|
397
383
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
398
384
|
}
|
|
@@ -401,7 +387,7 @@ function layoutSlotPage(slug) {
|
|
|
401
387
|
}
|
|
402
388
|
async function resolveCmssyLayoutSlot(config, options) {
|
|
403
389
|
const {
|
|
404
|
-
|
|
390
|
+
region,
|
|
405
391
|
blocks,
|
|
406
392
|
editMode,
|
|
407
393
|
preview = false,
|
|
@@ -424,7 +410,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
424
410
|
});
|
|
425
411
|
const base = {
|
|
426
412
|
groups,
|
|
427
|
-
settings: groups.find((g) => g.
|
|
413
|
+
settings: groups.find((g) => g.region === region)?.settings ?? null,
|
|
428
414
|
page,
|
|
429
415
|
locale: locale$1,
|
|
430
416
|
defaultLocale: siteLocales.defaultLocale,
|
|
@@ -435,7 +421,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
435
421
|
const editorData = await resolveEditorLayoutBlockData({
|
|
436
422
|
groups,
|
|
437
423
|
blocks,
|
|
438
|
-
|
|
424
|
+
region,
|
|
439
425
|
page,
|
|
440
426
|
locale: locale$1,
|
|
441
427
|
defaultLocale: siteLocales.defaultLocale,
|
|
@@ -455,7 +441,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
455
441
|
async function CmssyServerLayout({
|
|
456
442
|
groups,
|
|
457
443
|
blocks,
|
|
458
|
-
|
|
444
|
+
region,
|
|
459
445
|
page,
|
|
460
446
|
locale: localeProp,
|
|
461
447
|
defaultLocale: defaultLocaleProp,
|
|
@@ -471,7 +457,7 @@ async function CmssyServerLayout({
|
|
|
471
457
|
enabledLocales: enabledLocalesProp,
|
|
472
458
|
config
|
|
473
459
|
});
|
|
474
|
-
const group = groups.find((g) => g.
|
|
460
|
+
const group = groups.find((g) => g.region === region);
|
|
475
461
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
476
462
|
if (layoutBlocks.length === 0) return null;
|
|
477
463
|
const map = buildBlockMap(blocks);
|
|
@@ -491,7 +477,7 @@ async function CmssyServerLayout({
|
|
|
491
477
|
defaultLocale,
|
|
492
478
|
context,
|
|
493
479
|
enabledLocales,
|
|
494
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
480
|
+
{ schemas: core.blocksToSchemas(blocks), config }
|
|
495
481
|
);
|
|
496
482
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: layoutBlocks.map(
|
|
497
483
|
(block, i) => renderResolvedBlock(block, map, locale, defaultLocale, {
|
|
@@ -518,7 +504,7 @@ async function resolveCmssyLayout(config, options) {
|
|
|
518
504
|
const { groups, settings, page, locale, defaultLocale, enabledLocales } = resolved;
|
|
519
505
|
const shared = {
|
|
520
506
|
groups,
|
|
521
|
-
|
|
507
|
+
region: options.region,
|
|
522
508
|
page,
|
|
523
509
|
locale,
|
|
524
510
|
defaultLocale,
|
|
@@ -564,7 +550,7 @@ function CmssyBlock({
|
|
|
564
550
|
schema,
|
|
565
551
|
editable,
|
|
566
552
|
editMode,
|
|
567
|
-
|
|
553
|
+
layoutRegion,
|
|
568
554
|
context,
|
|
569
555
|
data
|
|
570
556
|
}) {
|
|
@@ -576,7 +562,7 @@ function CmssyBlock({
|
|
|
576
562
|
{
|
|
577
563
|
"data-block-id": block.id,
|
|
578
564
|
"data-block-type": block.type,
|
|
579
|
-
"data-layout-
|
|
565
|
+
"data-layout-region": layoutRegion,
|
|
580
566
|
draggable: editable || void 0,
|
|
581
567
|
style: hidden ? { display: "none" } : void 0,
|
|
582
568
|
children
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent,
|
|
3
|
-
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-
|
|
4
|
-
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutRegion, LayoutRegionId, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-Bkracpae.cjs';
|
|
4
|
+
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-Bkracpae.cjs';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
@@ -24,7 +24,7 @@ interface CmssyServerPageProps {
|
|
|
24
24
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, appContext, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
25
25
|
|
|
26
26
|
interface ResolveCmssyLayoutSlotBase {
|
|
27
|
-
|
|
27
|
+
region: string;
|
|
28
28
|
blocks: BlockDefinition[];
|
|
29
29
|
editMode: boolean;
|
|
30
30
|
preview?: boolean;
|
|
@@ -57,7 +57,7 @@ declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCms
|
|
|
57
57
|
|
|
58
58
|
interface CmssyLayoutEditableProps {
|
|
59
59
|
groups: CmssyLayoutGroup[];
|
|
60
|
-
|
|
60
|
+
region: string;
|
|
61
61
|
page?: CmssyBlockPage;
|
|
62
62
|
locale: string;
|
|
63
63
|
defaultLocale: string;
|
|
@@ -69,8 +69,8 @@ interface CmssyLayoutEditableProps {
|
|
|
69
69
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
70
70
|
appContext?: Record<string, unknown>;
|
|
71
71
|
}
|
|
72
|
-
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "
|
|
73
|
-
|
|
72
|
+
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "region" | keyof CmssyLayoutSlotLocaleSource> & CmssyLayoutSlotLocaleSource & {
|
|
73
|
+
region: P;
|
|
74
74
|
editable?: ComponentType<CmssyLayoutEditableProps>;
|
|
75
75
|
};
|
|
76
76
|
interface CmssyLayoutResolution<C extends CmssyConfig = CmssyConfig, P extends CmssyRegionOf<C> = CmssyRegionOf<C>> {
|
|
@@ -87,7 +87,7 @@ declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegion
|
|
|
87
87
|
interface CmssyServerLayoutProps {
|
|
88
88
|
groups: CmssyLayoutGroup[];
|
|
89
89
|
blocks: BlockDefinition[];
|
|
90
|
-
|
|
90
|
+
region: string;
|
|
91
91
|
page?: LayoutBlockPage;
|
|
92
92
|
locale?: string;
|
|
93
93
|
defaultLocale?: string;
|
|
@@ -97,7 +97,7 @@ interface CmssyServerLayoutProps {
|
|
|
97
97
|
editMode?: boolean;
|
|
98
98
|
preview?: boolean;
|
|
99
99
|
}
|
|
100
|
-
declare function CmssyServerLayout({ groups, blocks,
|
|
100
|
+
declare function CmssyServerLayout({ groups, blocks, region, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
101
101
|
|
|
102
102
|
interface CmssyBlockProps {
|
|
103
103
|
block: RawBlock;
|
|
@@ -111,11 +111,11 @@ interface CmssyBlockProps {
|
|
|
111
111
|
schema?: Record<string, FieldDefinition>;
|
|
112
112
|
editable?: boolean;
|
|
113
113
|
editMode?: boolean;
|
|
114
|
-
|
|
114
|
+
layoutRegion?: string;
|
|
115
115
|
context?: CmssyBlockContext;
|
|
116
116
|
data?: unknown;
|
|
117
117
|
}
|
|
118
|
-
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode,
|
|
118
|
+
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode, layoutRegion, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
119
119
|
|
|
120
120
|
interface UnknownBlockProps {
|
|
121
121
|
type: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CmssyPageData, CmssyClientConfig, CmssyFormDefinition, CmssyBlockAuthContext, CmssyBlockWorkspace, CmssyLayoutGroup, CmssyBlockPage, RetryOption, CmssyConfig, CmssyRegionOf, CmssyRegionSettingsOf, RawBlock, CmssyBlockContext } from '@cmssy/core';
|
|
2
|
-
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent,
|
|
3
|
-
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-
|
|
4
|
-
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-
|
|
2
|
+
export { AppToEditorMessage, BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BoundsMessage, BuildBlockContextExtra, ClickMessage, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClient, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayout, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssyRegion, CmssyRegionOf, CmssyRegionSettings, CmssyRegionSettingsOf, CmssyRequestError, CmssyRetryMode, CmssySiteConfig, CmssyTypedDocument, EditorToAppMessage, FetchLike, FetchLikeResponse, FetchPageOptions, FieldControl, FieldDefinition, FieldType, GraphqlRequestOptions, InferBlockContent, LayoutRegion, LayoutRegionId, MediaLike, PROTOCOL_VERSION, ParentReadyMessage, PatchMessage, PostTarget, QueryScopedOptions, RawBlock, RawLayoutBlock, ReadyMessage, RetryOption, RetryPolicy, SelectMessage, SubmitFormInput, TypedField, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
|
+
import { B as BlockDefinition, L as LayoutBlockPage, a as BlockMap } from './internal-server-Bkracpae.js';
|
|
4
|
+
export { b as BlockProps, E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, d as buildBlockMap, e as defineBlock, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData } from './internal-server-Bkracpae.js';
|
|
5
5
|
import { FieldDefinition } from '@cmssy/types';
|
|
6
6
|
export { FieldCondition, FieldConditionGroup, FieldConditionLogic } from '@cmssy/types';
|
|
7
7
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
@@ -24,7 +24,7 @@ interface CmssyServerPageProps {
|
|
|
24
24
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, appContext, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
25
25
|
|
|
26
26
|
interface ResolveCmssyLayoutSlotBase {
|
|
27
|
-
|
|
27
|
+
region: string;
|
|
28
28
|
blocks: BlockDefinition[];
|
|
29
29
|
editMode: boolean;
|
|
30
30
|
preview?: boolean;
|
|
@@ -57,7 +57,7 @@ declare function resolveCmssyLayoutSlot(config: CmssyConfig, options: ResolveCms
|
|
|
57
57
|
|
|
58
58
|
interface CmssyLayoutEditableProps {
|
|
59
59
|
groups: CmssyLayoutGroup[];
|
|
60
|
-
|
|
60
|
+
region: string;
|
|
61
61
|
page?: CmssyBlockPage;
|
|
62
62
|
locale: string;
|
|
63
63
|
defaultLocale: string;
|
|
@@ -69,8 +69,8 @@ interface CmssyLayoutEditableProps {
|
|
|
69
69
|
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
70
70
|
appContext?: Record<string, unknown>;
|
|
71
71
|
}
|
|
72
|
-
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "
|
|
73
|
-
|
|
72
|
+
type ResolveCmssyLayoutOptions<C extends CmssyConfig, P extends CmssyRegionOf<C>> = Omit<ResolveCmssyLayoutSlotOptions, "region" | keyof CmssyLayoutSlotLocaleSource> & CmssyLayoutSlotLocaleSource & {
|
|
73
|
+
region: P;
|
|
74
74
|
editable?: ComponentType<CmssyLayoutEditableProps>;
|
|
75
75
|
};
|
|
76
76
|
interface CmssyLayoutResolution<C extends CmssyConfig = CmssyConfig, P extends CmssyRegionOf<C> = CmssyRegionOf<C>> {
|
|
@@ -87,7 +87,7 @@ declare function resolveCmssyLayout<C extends CmssyConfig, P extends CmssyRegion
|
|
|
87
87
|
interface CmssyServerLayoutProps {
|
|
88
88
|
groups: CmssyLayoutGroup[];
|
|
89
89
|
blocks: BlockDefinition[];
|
|
90
|
-
|
|
90
|
+
region: string;
|
|
91
91
|
page?: LayoutBlockPage;
|
|
92
92
|
locale?: string;
|
|
93
93
|
defaultLocale?: string;
|
|
@@ -97,7 +97,7 @@ interface CmssyServerLayoutProps {
|
|
|
97
97
|
editMode?: boolean;
|
|
98
98
|
preview?: boolean;
|
|
99
99
|
}
|
|
100
|
-
declare function CmssyServerLayout({ groups, blocks,
|
|
100
|
+
declare function CmssyServerLayout({ groups, blocks, region, page, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, appContext, editMode, preview, }: CmssyServerLayoutProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
101
101
|
|
|
102
102
|
interface CmssyBlockProps {
|
|
103
103
|
block: RawBlock;
|
|
@@ -111,11 +111,11 @@ interface CmssyBlockProps {
|
|
|
111
111
|
schema?: Record<string, FieldDefinition>;
|
|
112
112
|
editable?: boolean;
|
|
113
113
|
editMode?: boolean;
|
|
114
|
-
|
|
114
|
+
layoutRegion?: string;
|
|
115
115
|
context?: CmssyBlockContext;
|
|
116
116
|
data?: unknown;
|
|
117
117
|
}
|
|
118
|
-
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode,
|
|
118
|
+
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode, layoutRegion, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
119
119
|
|
|
120
120
|
interface UnknownBlockProps {
|
|
121
121
|
type: string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveEditorOrigin } from '@cmssy/core';
|
|
1
|
+
import { blocksToSchemas, resolveEditorOrigin } from '@cmssy/core';
|
|
2
2
|
export { CmssyRequestError, PROTOCOL_VERSION, createCmssyClient, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor } from '@cmssy/core';
|
|
3
3
|
import { buildBlockContext, fetchLayouts, getBlockContentForLanguage, normalizeBlockContent, asBucket, resolveSiteLocales as resolveSiteLocales$1, resolveRelationContent } from '@cmssy/core/internal';
|
|
4
4
|
export { buildBlockContext } from '@cmssy/core/internal';
|
|
@@ -8,8 +8,6 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
8
8
|
import { resolveSiteLocales, splitLocaleFromPath } from '@cmssy/core/internal/locale';
|
|
9
9
|
|
|
10
10
|
// src/index.ts
|
|
11
|
-
|
|
12
|
-
// src/registry.ts
|
|
13
11
|
function defineBlock(def) {
|
|
14
12
|
return def;
|
|
15
13
|
}
|
|
@@ -25,18 +23,6 @@ function buildLoaderMap(blocks) {
|
|
|
25
23
|
}
|
|
26
24
|
return map;
|
|
27
25
|
}
|
|
28
|
-
function propsToSchema(props) {
|
|
29
|
-
const schema = {};
|
|
30
|
-
for (const [key, def] of Object.entries(props)) {
|
|
31
|
-
schema[key] = { ...def, label: def.label || key };
|
|
32
|
-
}
|
|
33
|
-
return schema;
|
|
34
|
-
}
|
|
35
|
-
function blocksToSchemas(blocks) {
|
|
36
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
37
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
38
|
-
return out;
|
|
39
|
-
}
|
|
40
26
|
|
|
41
27
|
// src/components/block-error.ts
|
|
42
28
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -363,7 +349,7 @@ async function resolveEditorBlockData({
|
|
|
363
349
|
async function resolveEditorLayoutBlockData({
|
|
364
350
|
groups,
|
|
365
351
|
blocks,
|
|
366
|
-
|
|
352
|
+
region,
|
|
367
353
|
page,
|
|
368
354
|
locale,
|
|
369
355
|
defaultLocale,
|
|
@@ -373,7 +359,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
373
359
|
config,
|
|
374
360
|
appContext
|
|
375
361
|
}) {
|
|
376
|
-
const group = groups.find((g) => g.
|
|
362
|
+
const group = groups.find((g) => g.region === region);
|
|
377
363
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
378
364
|
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
379
365
|
const loaderMap = buildLoaderMap(blocks);
|
|
@@ -401,7 +387,7 @@ function layoutSlotPage(slug) {
|
|
|
401
387
|
}
|
|
402
388
|
async function resolveCmssyLayoutSlot(config, options) {
|
|
403
389
|
const {
|
|
404
|
-
|
|
390
|
+
region,
|
|
405
391
|
blocks,
|
|
406
392
|
editMode,
|
|
407
393
|
preview = false,
|
|
@@ -424,7 +410,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
424
410
|
});
|
|
425
411
|
const base = {
|
|
426
412
|
groups,
|
|
427
|
-
settings: groups.find((g) => g.
|
|
413
|
+
settings: groups.find((g) => g.region === region)?.settings ?? null,
|
|
428
414
|
page,
|
|
429
415
|
locale,
|
|
430
416
|
defaultLocale: siteLocales.defaultLocale,
|
|
@@ -435,7 +421,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
435
421
|
const editorData = await resolveEditorLayoutBlockData({
|
|
436
422
|
groups,
|
|
437
423
|
blocks,
|
|
438
|
-
|
|
424
|
+
region,
|
|
439
425
|
page,
|
|
440
426
|
locale,
|
|
441
427
|
defaultLocale: siteLocales.defaultLocale,
|
|
@@ -455,7 +441,7 @@ async function resolveCmssyLayoutSlot(config, options) {
|
|
|
455
441
|
async function CmssyServerLayout({
|
|
456
442
|
groups,
|
|
457
443
|
blocks,
|
|
458
|
-
|
|
444
|
+
region,
|
|
459
445
|
page,
|
|
460
446
|
locale: localeProp,
|
|
461
447
|
defaultLocale: defaultLocaleProp,
|
|
@@ -471,7 +457,7 @@ async function CmssyServerLayout({
|
|
|
471
457
|
enabledLocales: enabledLocalesProp,
|
|
472
458
|
config
|
|
473
459
|
});
|
|
474
|
-
const group = groups.find((g) => g.
|
|
460
|
+
const group = groups.find((g) => g.region === region);
|
|
475
461
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
476
462
|
if (layoutBlocks.length === 0) return null;
|
|
477
463
|
const map = buildBlockMap(blocks);
|
|
@@ -518,7 +504,7 @@ async function resolveCmssyLayout(config, options) {
|
|
|
518
504
|
const { groups, settings, page, locale, defaultLocale, enabledLocales } = resolved;
|
|
519
505
|
const shared = {
|
|
520
506
|
groups,
|
|
521
|
-
|
|
507
|
+
region: options.region,
|
|
522
508
|
page,
|
|
523
509
|
locale,
|
|
524
510
|
defaultLocale,
|
|
@@ -564,7 +550,7 @@ function CmssyBlock({
|
|
|
564
550
|
schema,
|
|
565
551
|
editable,
|
|
566
552
|
editMode,
|
|
567
|
-
|
|
553
|
+
layoutRegion,
|
|
568
554
|
context,
|
|
569
555
|
data
|
|
570
556
|
}) {
|
|
@@ -576,7 +562,7 @@ function CmssyBlock({
|
|
|
576
562
|
{
|
|
577
563
|
"data-block-id": block.id,
|
|
578
564
|
"data-block-type": block.type,
|
|
579
|
-
"data-layout-
|
|
565
|
+
"data-layout-region": layoutRegion,
|
|
580
566
|
draggable: editable || void 0,
|
|
581
567
|
style: hidden ? { display: "none" } : void 0,
|
|
582
568
|
children
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent,
|
|
1
|
+
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BuildBlockContextExtra, CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
@@ -25,7 +25,7 @@ interface BlockDefinition {
|
|
|
25
25
|
label?: string;
|
|
26
26
|
category?: string;
|
|
27
27
|
icon?: string;
|
|
28
|
-
|
|
28
|
+
layoutRegions?: string[];
|
|
29
29
|
description?: string;
|
|
30
30
|
props: Record<string, FieldDefinition>;
|
|
31
31
|
loader?: BlockLoader;
|
|
@@ -42,7 +42,7 @@ declare function defineBlock<P extends BlockPropsSchema, C = InferBlockContent<P
|
|
|
42
42
|
label?: string;
|
|
43
43
|
category?: string;
|
|
44
44
|
icon?: string;
|
|
45
|
-
|
|
45
|
+
layoutRegions?: string[];
|
|
46
46
|
description?: string;
|
|
47
47
|
props: P;
|
|
48
48
|
loader?: (args: {
|
|
@@ -65,7 +65,6 @@ type BlockMap = Record<string, ComponentType<{
|
|
|
65
65
|
data?: unknown;
|
|
66
66
|
}>>;
|
|
67
67
|
declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
|
|
68
|
-
declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
|
|
69
68
|
|
|
70
69
|
type LayoutBlockPage = NonNullable<BuildBlockContextExtra["page"]>;
|
|
71
70
|
interface EditorBlockData {
|
|
@@ -88,7 +87,7 @@ declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Rec
|
|
|
88
87
|
interface ResolveLayoutBlockDataOptions {
|
|
89
88
|
groups: CmssyLayoutGroup[];
|
|
90
89
|
blocks: BlockDefinition[];
|
|
91
|
-
|
|
90
|
+
region: string;
|
|
92
91
|
page?: LayoutBlockPage;
|
|
93
92
|
locale: string;
|
|
94
93
|
defaultLocale: string;
|
|
@@ -98,7 +97,7 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
98
97
|
config?: CmssyClientConfig;
|
|
99
98
|
appContext?: Record<string, unknown>;
|
|
100
99
|
}
|
|
101
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks,
|
|
100
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, region, page, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
102
101
|
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
103
102
|
|
|
104
|
-
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f,
|
|
103
|
+
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f, resolveBlockData as g, resolveLayoutBlockData as h, resolveEditorBlockData as r };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent,
|
|
1
|
+
import { FieldDefinition, CmssyBlockContext, BlockPropsSchema, InferBlockContent, BuildBlockContextExtra, CmssyPageData, CmssyFormDefinition, CmssyClientConfig, CmssyLayoutGroup } from '@cmssy/core';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
3
|
|
|
4
4
|
interface BlockProps<P extends BlockPropsSchema, D = unknown> {
|
|
@@ -25,7 +25,7 @@ interface BlockDefinition {
|
|
|
25
25
|
label?: string;
|
|
26
26
|
category?: string;
|
|
27
27
|
icon?: string;
|
|
28
|
-
|
|
28
|
+
layoutRegions?: string[];
|
|
29
29
|
description?: string;
|
|
30
30
|
props: Record<string, FieldDefinition>;
|
|
31
31
|
loader?: BlockLoader;
|
|
@@ -42,7 +42,7 @@ declare function defineBlock<P extends BlockPropsSchema, C = InferBlockContent<P
|
|
|
42
42
|
label?: string;
|
|
43
43
|
category?: string;
|
|
44
44
|
icon?: string;
|
|
45
|
-
|
|
45
|
+
layoutRegions?: string[];
|
|
46
46
|
description?: string;
|
|
47
47
|
props: P;
|
|
48
48
|
loader?: (args: {
|
|
@@ -65,7 +65,6 @@ type BlockMap = Record<string, ComponentType<{
|
|
|
65
65
|
data?: unknown;
|
|
66
66
|
}>>;
|
|
67
67
|
declare function buildBlockMap(blocks: BlockDefinition[]): BlockMap;
|
|
68
|
-
declare function blocksToSchemas(blocks: BlockDefinition[]): Record<string, BlockSchema>;
|
|
69
68
|
|
|
70
69
|
type LayoutBlockPage = NonNullable<BuildBlockContextExtra["page"]>;
|
|
71
70
|
interface EditorBlockData {
|
|
@@ -88,7 +87,7 @@ declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Rec
|
|
|
88
87
|
interface ResolveLayoutBlockDataOptions {
|
|
89
88
|
groups: CmssyLayoutGroup[];
|
|
90
89
|
blocks: BlockDefinition[];
|
|
91
|
-
|
|
90
|
+
region: string;
|
|
92
91
|
page?: LayoutBlockPage;
|
|
93
92
|
locale: string;
|
|
94
93
|
defaultLocale: string;
|
|
@@ -98,7 +97,7 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
98
97
|
config?: CmssyClientConfig;
|
|
99
98
|
appContext?: Record<string, unknown>;
|
|
100
99
|
}
|
|
101
|
-
declare function resolveEditorLayoutBlockData({ groups, blocks,
|
|
100
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, region, page, locale, defaultLocale, enabledLocales, forms, isPreview, config, appContext, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
102
101
|
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
103
102
|
|
|
104
|
-
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f,
|
|
103
|
+
export { type BlockDefinition as B, type EditorBlockData as E, type LayoutBlockPage as L, type ResolveBlockDataOptions as R, type BlockMap as a, type BlockProps as b, type ResolveLayoutBlockDataOptions as c, buildBlockMap as d, defineBlock as e, resolveEditorLayoutBlockData as f, resolveBlockData as g, resolveLayoutBlockData as h, resolveEditorBlockData as r };
|
package/dist/internal-server.cjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var internal = require('@cmssy/core/internal');
|
|
4
|
+
var core = require('@cmssy/core');
|
|
4
5
|
|
|
5
6
|
// src/components/resolve-block-data.ts
|
|
6
|
-
|
|
7
|
-
// src/registry.ts
|
|
8
7
|
function buildLoaderMap(blocks) {
|
|
9
8
|
const map = /* @__PURE__ */ Object.create(null);
|
|
10
9
|
for (const block of blocks) {
|
|
@@ -12,18 +11,6 @@ function buildLoaderMap(blocks) {
|
|
|
12
11
|
}
|
|
13
12
|
return map;
|
|
14
13
|
}
|
|
15
|
-
function propsToSchema(props) {
|
|
16
|
-
const schema = {};
|
|
17
|
-
for (const [key, def] of Object.entries(props)) {
|
|
18
|
-
schema[key] = { ...def, label: def.label || key };
|
|
19
|
-
}
|
|
20
|
-
return schema;
|
|
21
|
-
}
|
|
22
|
-
function blocksToSchemas(blocks) {
|
|
23
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
24
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
25
|
-
return out;
|
|
26
|
-
}
|
|
27
14
|
|
|
28
15
|
// src/components/block-error.ts
|
|
29
16
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -126,7 +113,7 @@ async function resolveEditorBlockData({
|
|
|
126
113
|
defaultLocale,
|
|
127
114
|
context,
|
|
128
115
|
enabledLocales,
|
|
129
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
116
|
+
{ schemas: core.blocksToSchemas(blocks), config }
|
|
130
117
|
);
|
|
131
118
|
return collectBlockData(page.blocks, resolved, isPreview);
|
|
132
119
|
}
|
|
@@ -136,7 +123,7 @@ async function resolveBlockData(options) {
|
|
|
136
123
|
async function resolveEditorLayoutBlockData({
|
|
137
124
|
groups,
|
|
138
125
|
blocks,
|
|
139
|
-
|
|
126
|
+
region,
|
|
140
127
|
page,
|
|
141
128
|
locale,
|
|
142
129
|
defaultLocale,
|
|
@@ -146,7 +133,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
146
133
|
config,
|
|
147
134
|
appContext
|
|
148
135
|
}) {
|
|
149
|
-
const group = groups.find((g) => g.
|
|
136
|
+
const group = groups.find((g) => g.region === region);
|
|
150
137
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
151
138
|
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
152
139
|
const loaderMap = buildLoaderMap(blocks);
|
|
@@ -165,7 +152,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
165
152
|
defaultLocale,
|
|
166
153
|
context,
|
|
167
154
|
enabledLocales,
|
|
168
|
-
{ schemas: blocksToSchemas(blocks), config }
|
|
155
|
+
{ schemas: core.blocksToSchemas(blocks), config }
|
|
169
156
|
);
|
|
170
157
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
171
158
|
}
|
|
@@ -173,7 +160,10 @@ async function resolveLayoutBlockData(options) {
|
|
|
173
160
|
return (await resolveEditorLayoutBlockData(options)).data;
|
|
174
161
|
}
|
|
175
162
|
|
|
176
|
-
exports
|
|
163
|
+
Object.defineProperty(exports, "blocksToSchemas", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () { return core.blocksToSchemas; }
|
|
166
|
+
});
|
|
177
167
|
exports.resolveBlockData = resolveBlockData;
|
|
178
168
|
exports.resolveEditorBlockData = resolveEditorBlockData;
|
|
179
169
|
exports.resolveEditorLayoutBlockData = resolveEditorLayoutBlockData;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as
|
|
2
|
-
|
|
1
|
+
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as resolveBlockData, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData, h as resolveLayoutBlockData } from './internal-server-Bkracpae.cjs';
|
|
2
|
+
export { blocksToSchemas } from '@cmssy/core';
|
|
3
3
|
import 'react';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as
|
|
2
|
-
|
|
1
|
+
export { E as EditorBlockData, R as ResolveBlockDataOptions, c as ResolveLayoutBlockDataOptions, g as resolveBlockData, r as resolveEditorBlockData, f as resolveEditorLayoutBlockData, h as resolveLayoutBlockData } from './internal-server-Bkracpae.js';
|
|
2
|
+
export { blocksToSchemas } from '@cmssy/core';
|
|
3
3
|
import 'react';
|
package/dist/internal-server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { buildBlockContext, getBlockContentForLanguage, resolveRelationContent, normalizeBlockContent } from '@cmssy/core/internal';
|
|
2
|
+
import { blocksToSchemas } from '@cmssy/core';
|
|
3
|
+
export { blocksToSchemas } from '@cmssy/core';
|
|
2
4
|
|
|
3
5
|
// src/components/resolve-block-data.ts
|
|
4
|
-
|
|
5
|
-
// src/registry.ts
|
|
6
6
|
function buildLoaderMap(blocks) {
|
|
7
7
|
const map = /* @__PURE__ */ Object.create(null);
|
|
8
8
|
for (const block of blocks) {
|
|
@@ -10,18 +10,6 @@ function buildLoaderMap(blocks) {
|
|
|
10
10
|
}
|
|
11
11
|
return map;
|
|
12
12
|
}
|
|
13
|
-
function propsToSchema(props) {
|
|
14
|
-
const schema = {};
|
|
15
|
-
for (const [key, def] of Object.entries(props)) {
|
|
16
|
-
schema[key] = { ...def, label: def.label || key };
|
|
17
|
-
}
|
|
18
|
-
return schema;
|
|
19
|
-
}
|
|
20
|
-
function blocksToSchemas(blocks) {
|
|
21
|
-
const out = /* @__PURE__ */ Object.create(null);
|
|
22
|
-
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
13
|
|
|
26
14
|
// src/components/block-error.ts
|
|
27
15
|
var BLOCK_ERROR_KEY = "__cmssyBlockError";
|
|
@@ -134,7 +122,7 @@ async function resolveBlockData(options) {
|
|
|
134
122
|
async function resolveEditorLayoutBlockData({
|
|
135
123
|
groups,
|
|
136
124
|
blocks,
|
|
137
|
-
|
|
125
|
+
region,
|
|
138
126
|
page,
|
|
139
127
|
locale,
|
|
140
128
|
defaultLocale,
|
|
@@ -144,7 +132,7 @@ async function resolveEditorLayoutBlockData({
|
|
|
144
132
|
config,
|
|
145
133
|
appContext
|
|
146
134
|
}) {
|
|
147
|
-
const group = groups.find((g) => g.
|
|
135
|
+
const group = groups.find((g) => g.region === region);
|
|
148
136
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive !== false).slice().sort((a, b) => a.order - b.order) : [];
|
|
149
137
|
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
150
138
|
const loaderMap = buildLoaderMap(blocks);
|
|
@@ -171,4 +159,4 @@ async function resolveLayoutBlockData(options) {
|
|
|
171
159
|
return (await resolveEditorLayoutBlockData(options)).data;
|
|
172
160
|
}
|
|
173
161
|
|
|
174
|
-
export {
|
|
162
|
+
export { resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"vitest": "^2.1.0"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@cmssy/types": "0.
|
|
100
|
-
"@cmssy/core": "
|
|
99
|
+
"@cmssy/types": "0.40.0",
|
|
100
|
+
"@cmssy/core": "15.0.0"
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
103
|
"build": "tsup",
|