@cmssy/react 9.6.1 → 9.7.1
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 +18 -6
- package/dist/client.d.cts +6 -2
- package/dist/client.d.ts +6 -2
- package/dist/client.js +18 -6
- package/dist/index.cjs +18 -7
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +17 -8
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
|
@@ -522,6 +522,7 @@ function CmssyBlock({
|
|
|
522
522
|
patchedContent,
|
|
523
523
|
patchedStyle,
|
|
524
524
|
patchedAdvanced,
|
|
525
|
+
resolvedContent,
|
|
525
526
|
schema,
|
|
526
527
|
editable,
|
|
527
528
|
editMode,
|
|
@@ -568,9 +569,9 @@ function CmssyBlock({
|
|
|
568
569
|
)
|
|
569
570
|
);
|
|
570
571
|
}
|
|
571
|
-
const base = core.getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
572
|
+
const base = resolvedContent ? { ...resolvedContent } : core.getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
572
573
|
const content = patchedContent ? { ...base, ...patchedContent } : base;
|
|
573
|
-
if (schema) core.normalizeRelationContent(content, schema);
|
|
574
|
+
if (schema) core.normalizeRelationContent(content, schema, resolvedContent);
|
|
574
575
|
const style = patchedStyle ? { ...core.asBucket(block.style), ...patchedStyle } : core.asBucket(block.style);
|
|
575
576
|
const advanced = patchedAdvanced ? { ...core.asBucket(block.advanced), ...patchedAdvanced } : core.asBucket(block.advanced);
|
|
576
577
|
return wrap(
|
|
@@ -600,7 +601,8 @@ function CmssyEditablePage({
|
|
|
600
601
|
edit,
|
|
601
602
|
category,
|
|
602
603
|
forms,
|
|
603
|
-
data
|
|
604
|
+
data,
|
|
605
|
+
resolvedContent
|
|
604
606
|
}) {
|
|
605
607
|
if (!Array.isArray(blocks)) {
|
|
606
608
|
throw new Error(
|
|
@@ -619,7 +621,8 @@ function CmssyEditablePage({
|
|
|
619
621
|
edit,
|
|
620
622
|
category,
|
|
621
623
|
forms,
|
|
622
|
-
data
|
|
624
|
+
data,
|
|
625
|
+
resolvedContent
|
|
623
626
|
}
|
|
624
627
|
);
|
|
625
628
|
}
|
|
@@ -632,7 +635,8 @@ function EditableBlocks({
|
|
|
632
635
|
edit,
|
|
633
636
|
category,
|
|
634
637
|
forms,
|
|
635
|
-
data
|
|
638
|
+
data,
|
|
639
|
+
resolvedContent
|
|
636
640
|
}) {
|
|
637
641
|
const blockMap = react.useMemo(() => buildBlockMap(blocks), [blocks]);
|
|
638
642
|
const context = react.useMemo(
|
|
@@ -682,6 +686,7 @@ function EditableBlocks({
|
|
|
682
686
|
patchedContent: patches[block.id],
|
|
683
687
|
patchedStyle: patchesStyle[block.id],
|
|
684
688
|
patchedAdvanced: patchesAdvanced[block.id],
|
|
689
|
+
resolvedContent: resolvedContent?.[block.id],
|
|
685
690
|
schema: bridgeConfig.schemas?.[block.type],
|
|
686
691
|
blockMap,
|
|
687
692
|
editable: true,
|
|
@@ -778,9 +783,14 @@ function CmssyEditableLayout({
|
|
|
778
783
|
defaultLocale = "en",
|
|
779
784
|
enabledLocales,
|
|
780
785
|
edit,
|
|
781
|
-
data
|
|
786
|
+
data,
|
|
787
|
+
resolvedContent
|
|
782
788
|
}) {
|
|
783
789
|
const blockMap = react.useMemo(() => buildBlockMap(blocks), [blocks]);
|
|
790
|
+
const schemas = react.useMemo(
|
|
791
|
+
() => edit.schemas ?? blocksToSchemas(blocks),
|
|
792
|
+
[edit.schemas, blocks]
|
|
793
|
+
);
|
|
784
794
|
const layoutBlocks = react.useMemo(() => {
|
|
785
795
|
const group = groups.find((g) => g.position === position);
|
|
786
796
|
return group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
@@ -799,6 +809,8 @@ function CmssyEditableLayout({
|
|
|
799
809
|
defaultLocale,
|
|
800
810
|
blockMap,
|
|
801
811
|
patchedContent: patches[block.id],
|
|
812
|
+
resolvedContent: resolvedContent?.[block.id],
|
|
813
|
+
schema: schemas[block.type],
|
|
802
814
|
editMode: true,
|
|
803
815
|
layoutPosition: position,
|
|
804
816
|
context,
|
package/dist/client.d.cts
CHANGED
|
@@ -48,8 +48,9 @@ interface CmssyEditablePageProps {
|
|
|
48
48
|
category?: string;
|
|
49
49
|
forms?: Record<string, CmssyFormDefinition>;
|
|
50
50
|
data?: Record<string, unknown>;
|
|
51
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
51
52
|
}
|
|
52
|
-
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
53
|
+
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
53
54
|
|
|
54
55
|
interface CmssyLazyEditorProps {
|
|
55
56
|
page: CmssyPageData | null;
|
|
@@ -59,6 +60,7 @@ interface CmssyLazyEditorProps {
|
|
|
59
60
|
edit: EditBridgeConfig;
|
|
60
61
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
62
|
data?: Record<string, unknown>;
|
|
63
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
62
64
|
load: () => Promise<{
|
|
63
65
|
blocks: BlockDefinition[];
|
|
64
66
|
category?: string;
|
|
@@ -75,8 +77,9 @@ interface CmssyEditableLayoutProps {
|
|
|
75
77
|
enabledLocales?: string[];
|
|
76
78
|
edit: EditBridgeConfig;
|
|
77
79
|
data?: Record<string, unknown>;
|
|
80
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
78
81
|
}
|
|
79
|
-
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
82
|
+
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
80
83
|
|
|
81
84
|
interface CmssyLazyLayoutProps {
|
|
82
85
|
groups: CmssyLayoutGroup[];
|
|
@@ -86,6 +89,7 @@ interface CmssyLazyLayoutProps {
|
|
|
86
89
|
enabledLocales?: string[];
|
|
87
90
|
edit: EditBridgeConfig;
|
|
88
91
|
data?: Record<string, unknown>;
|
|
92
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
89
93
|
load: () => Promise<{
|
|
90
94
|
blocks: BlockDefinition[];
|
|
91
95
|
}>;
|
package/dist/client.d.ts
CHANGED
|
@@ -48,8 +48,9 @@ interface CmssyEditablePageProps {
|
|
|
48
48
|
category?: string;
|
|
49
49
|
forms?: Record<string, CmssyFormDefinition>;
|
|
50
50
|
data?: Record<string, unknown>;
|
|
51
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
51
52
|
}
|
|
52
|
-
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
53
|
+
declare function CmssyEditablePage({ page, blocks, locale, defaultLocale, enabledLocales, edit, category, forms, data, resolvedContent, }: CmssyEditablePageProps): react_jsx_runtime.JSX.Element | null;
|
|
53
54
|
|
|
54
55
|
interface CmssyLazyEditorProps {
|
|
55
56
|
page: CmssyPageData | null;
|
|
@@ -59,6 +60,7 @@ interface CmssyLazyEditorProps {
|
|
|
59
60
|
edit: EditBridgeConfig;
|
|
60
61
|
forms?: Record<string, CmssyFormDefinition>;
|
|
61
62
|
data?: Record<string, unknown>;
|
|
63
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
62
64
|
load: () => Promise<{
|
|
63
65
|
blocks: BlockDefinition[];
|
|
64
66
|
category?: string;
|
|
@@ -75,8 +77,9 @@ interface CmssyEditableLayoutProps {
|
|
|
75
77
|
enabledLocales?: string[];
|
|
76
78
|
edit: EditBridgeConfig;
|
|
77
79
|
data?: Record<string, unknown>;
|
|
80
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
78
81
|
}
|
|
79
|
-
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
82
|
+
declare function CmssyEditableLayout({ groups, blocks, position, locale, defaultLocale, enabledLocales, edit, data, resolvedContent, }: CmssyEditableLayoutProps): react_jsx_runtime.JSX.Element | null;
|
|
80
83
|
|
|
81
84
|
interface CmssyLazyLayoutProps {
|
|
82
85
|
groups: CmssyLayoutGroup[];
|
|
@@ -86,6 +89,7 @@ interface CmssyLazyLayoutProps {
|
|
|
86
89
|
enabledLocales?: string[];
|
|
87
90
|
edit: EditBridgeConfig;
|
|
88
91
|
data?: Record<string, unknown>;
|
|
92
|
+
resolvedContent?: Record<string, Record<string, unknown>>;
|
|
89
93
|
load: () => Promise<{
|
|
90
94
|
blocks: BlockDefinition[];
|
|
91
95
|
}>;
|
package/dist/client.js
CHANGED
|
@@ -521,6 +521,7 @@ function CmssyBlock({
|
|
|
521
521
|
patchedContent,
|
|
522
522
|
patchedStyle,
|
|
523
523
|
patchedAdvanced,
|
|
524
|
+
resolvedContent,
|
|
524
525
|
schema,
|
|
525
526
|
editable,
|
|
526
527
|
editMode,
|
|
@@ -567,9 +568,9 @@ function CmssyBlock({
|
|
|
567
568
|
)
|
|
568
569
|
);
|
|
569
570
|
}
|
|
570
|
-
const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
571
|
+
const base = resolvedContent ? { ...resolvedContent } : getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
571
572
|
const content = patchedContent ? { ...base, ...patchedContent } : base;
|
|
572
|
-
if (schema) normalizeRelationContent(content, schema);
|
|
573
|
+
if (schema) normalizeRelationContent(content, schema, resolvedContent);
|
|
573
574
|
const style = patchedStyle ? { ...asBucket(block.style), ...patchedStyle } : asBucket(block.style);
|
|
574
575
|
const advanced = patchedAdvanced ? { ...asBucket(block.advanced), ...patchedAdvanced } : asBucket(block.advanced);
|
|
575
576
|
return wrap(
|
|
@@ -599,7 +600,8 @@ function CmssyEditablePage({
|
|
|
599
600
|
edit,
|
|
600
601
|
category,
|
|
601
602
|
forms,
|
|
602
|
-
data
|
|
603
|
+
data,
|
|
604
|
+
resolvedContent
|
|
603
605
|
}) {
|
|
604
606
|
if (!Array.isArray(blocks)) {
|
|
605
607
|
throw new Error(
|
|
@@ -618,7 +620,8 @@ function CmssyEditablePage({
|
|
|
618
620
|
edit,
|
|
619
621
|
category,
|
|
620
622
|
forms,
|
|
621
|
-
data
|
|
623
|
+
data,
|
|
624
|
+
resolvedContent
|
|
622
625
|
}
|
|
623
626
|
);
|
|
624
627
|
}
|
|
@@ -631,7 +634,8 @@ function EditableBlocks({
|
|
|
631
634
|
edit,
|
|
632
635
|
category,
|
|
633
636
|
forms,
|
|
634
|
-
data
|
|
637
|
+
data,
|
|
638
|
+
resolvedContent
|
|
635
639
|
}) {
|
|
636
640
|
const blockMap = useMemo(() => buildBlockMap(blocks), [blocks]);
|
|
637
641
|
const context = useMemo(
|
|
@@ -681,6 +685,7 @@ function EditableBlocks({
|
|
|
681
685
|
patchedContent: patches[block.id],
|
|
682
686
|
patchedStyle: patchesStyle[block.id],
|
|
683
687
|
patchedAdvanced: patchesAdvanced[block.id],
|
|
688
|
+
resolvedContent: resolvedContent?.[block.id],
|
|
684
689
|
schema: bridgeConfig.schemas?.[block.type],
|
|
685
690
|
blockMap,
|
|
686
691
|
editable: true,
|
|
@@ -777,9 +782,14 @@ function CmssyEditableLayout({
|
|
|
777
782
|
defaultLocale = "en",
|
|
778
783
|
enabledLocales,
|
|
779
784
|
edit,
|
|
780
|
-
data
|
|
785
|
+
data,
|
|
786
|
+
resolvedContent
|
|
781
787
|
}) {
|
|
782
788
|
const blockMap = useMemo(() => buildBlockMap(blocks), [blocks]);
|
|
789
|
+
const schemas = useMemo(
|
|
790
|
+
() => edit.schemas ?? blocksToSchemas(blocks),
|
|
791
|
+
[edit.schemas, blocks]
|
|
792
|
+
);
|
|
783
793
|
const layoutBlocks = useMemo(() => {
|
|
784
794
|
const group = groups.find((g) => g.position === position);
|
|
785
795
|
return group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
@@ -798,6 +808,8 @@ function CmssyEditableLayout({
|
|
|
798
808
|
defaultLocale,
|
|
799
809
|
blockMap,
|
|
800
810
|
patchedContent: patches[block.id],
|
|
811
|
+
resolvedContent: resolvedContent?.[block.id],
|
|
812
|
+
schema: schemas[block.type],
|
|
801
813
|
editMode: true,
|
|
802
814
|
layoutPosition: position,
|
|
803
815
|
context,
|
package/dist/index.cjs
CHANGED
|
@@ -319,18 +319,20 @@ async function CmssyServerPage({
|
|
|
319
319
|
}
|
|
320
320
|
function collectBlockData(blocks, resolved, isPreview) {
|
|
321
321
|
const data = {};
|
|
322
|
+
const content = {};
|
|
322
323
|
blocks.forEach((block, index) => {
|
|
323
324
|
const entry = resolved[index];
|
|
324
325
|
if (!entry) return;
|
|
326
|
+
content[block.id] = entry.content;
|
|
325
327
|
if (entry.error && isPreview) {
|
|
326
328
|
data[block.id] = markBlockError(entry.error);
|
|
327
329
|
} else if (entry.data !== void 0) {
|
|
328
330
|
data[block.id] = entry.data;
|
|
329
331
|
}
|
|
330
332
|
});
|
|
331
|
-
return data;
|
|
333
|
+
return { data, content };
|
|
332
334
|
}
|
|
333
|
-
async function
|
|
335
|
+
async function resolveEditorBlockData({
|
|
334
336
|
page,
|
|
335
337
|
blocks,
|
|
336
338
|
locale,
|
|
@@ -340,7 +342,7 @@ async function resolveBlockData({
|
|
|
340
342
|
isPreview = false,
|
|
341
343
|
config
|
|
342
344
|
}) {
|
|
343
|
-
if (!page) return {};
|
|
345
|
+
if (!page) return { data: {}, content: {} };
|
|
344
346
|
const loaderMap = buildLoaderMap(blocks);
|
|
345
347
|
const context = core.buildBlockContext(
|
|
346
348
|
locale,
|
|
@@ -360,7 +362,10 @@ async function resolveBlockData({
|
|
|
360
362
|
);
|
|
361
363
|
return collectBlockData(page.blocks, resolved, isPreview);
|
|
362
364
|
}
|
|
363
|
-
async function
|
|
365
|
+
async function resolveBlockData(options) {
|
|
366
|
+
return (await resolveEditorBlockData(options)).data;
|
|
367
|
+
}
|
|
368
|
+
async function resolveEditorLayoutBlockData({
|
|
364
369
|
groups,
|
|
365
370
|
blocks,
|
|
366
371
|
position,
|
|
@@ -373,7 +378,7 @@ async function resolveLayoutBlockData({
|
|
|
373
378
|
}) {
|
|
374
379
|
const group = groups.find((g) => g.position === position);
|
|
375
380
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
376
|
-
if (layoutBlocks.length === 0) return {};
|
|
381
|
+
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
377
382
|
const loaderMap = buildLoaderMap(blocks);
|
|
378
383
|
const context = core.buildBlockContext(
|
|
379
384
|
locale,
|
|
@@ -393,6 +398,9 @@ async function resolveLayoutBlockData({
|
|
|
393
398
|
);
|
|
394
399
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
395
400
|
}
|
|
401
|
+
async function resolveLayoutBlockData(options) {
|
|
402
|
+
return (await resolveEditorLayoutBlockData(options)).data;
|
|
403
|
+
}
|
|
396
404
|
async function CmssyServerLayout({
|
|
397
405
|
groups,
|
|
398
406
|
blocks,
|
|
@@ -443,6 +451,7 @@ function CmssyBlock({
|
|
|
443
451
|
patchedContent,
|
|
444
452
|
patchedStyle,
|
|
445
453
|
patchedAdvanced,
|
|
454
|
+
resolvedContent,
|
|
446
455
|
schema,
|
|
447
456
|
editable,
|
|
448
457
|
editMode,
|
|
@@ -489,9 +498,9 @@ function CmssyBlock({
|
|
|
489
498
|
)
|
|
490
499
|
);
|
|
491
500
|
}
|
|
492
|
-
const base = core.getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
501
|
+
const base = resolvedContent ? { ...resolvedContent } : core.getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
493
502
|
const content = patchedContent ? { ...base, ...patchedContent } : base;
|
|
494
|
-
if (schema) core.normalizeRelationContent(content, schema);
|
|
503
|
+
if (schema) core.normalizeRelationContent(content, schema, resolvedContent);
|
|
495
504
|
const style = patchedStyle ? { ...core.asBucket(block.style), ...patchedStyle } : core.asBucket(block.style);
|
|
496
505
|
const advanced = patchedAdvanced ? { ...core.asBucket(block.advanced), ...patchedAdvanced } : core.asBucket(block.advanced);
|
|
497
506
|
return wrap(
|
|
@@ -662,4 +671,6 @@ exports.blocksToSchemas = blocksToSchemas;
|
|
|
662
671
|
exports.buildBlockMap = buildBlockMap;
|
|
663
672
|
exports.defineBlock = defineBlock;
|
|
664
673
|
exports.resolveBlockData = resolveBlockData;
|
|
674
|
+
exports.resolveEditorBlockData = resolveEditorBlockData;
|
|
675
|
+
exports.resolveEditorLayoutBlockData = resolveEditorLayoutBlockData;
|
|
665
676
|
exports.resolveLayoutBlockData = resolveLayoutBlockData;
|
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,10 @@ interface CmssyServerPageProps {
|
|
|
34
34
|
*/
|
|
35
35
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
36
36
|
|
|
37
|
+
interface EditorBlockData {
|
|
38
|
+
data: Record<string, unknown>;
|
|
39
|
+
content: Record<string, Record<string, unknown>>;
|
|
40
|
+
}
|
|
37
41
|
interface ResolveBlockDataOptions {
|
|
38
42
|
page: CmssyPageData | null;
|
|
39
43
|
blocks: BlockDefinition[];
|
|
@@ -45,7 +49,8 @@ interface ResolveBlockDataOptions {
|
|
|
45
49
|
/** Workspace the relation records are read from. No config, no resolution. */
|
|
46
50
|
config?: CmssyClientConfig;
|
|
47
51
|
}
|
|
48
|
-
declare function
|
|
52
|
+
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
53
|
+
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
49
54
|
interface ResolveLayoutBlockDataOptions {
|
|
50
55
|
groups: CmssyLayoutGroup[];
|
|
51
56
|
blocks: BlockDefinition[];
|
|
@@ -58,7 +63,8 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
58
63
|
/** Workspace the relation records are read from. No config, no resolution. */
|
|
59
64
|
config?: CmssyClientConfig;
|
|
60
65
|
}
|
|
61
|
-
declare function
|
|
66
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
67
|
+
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
62
68
|
|
|
63
69
|
interface CmssyServerLayoutProps {
|
|
64
70
|
groups: CmssyLayoutGroup[];
|
|
@@ -91,6 +97,8 @@ interface CmssyBlockProps {
|
|
|
91
97
|
patchedContent?: Record<string, unknown>;
|
|
92
98
|
patchedStyle?: Record<string, unknown>;
|
|
93
99
|
patchedAdvanced?: Record<string, unknown>;
|
|
100
|
+
/** Server-resolved content for this block (locale flattened, relations resolved). */
|
|
101
|
+
resolvedContent?: Record<string, unknown>;
|
|
94
102
|
/** The block's field schema; lets the client render coerce raw relation values. */
|
|
95
103
|
schema?: Record<string, FieldDefinition>;
|
|
96
104
|
editable?: boolean;
|
|
@@ -99,11 +107,11 @@ interface CmssyBlockProps {
|
|
|
99
107
|
context?: CmssyBlockContext;
|
|
100
108
|
data?: unknown;
|
|
101
109
|
}
|
|
102
|
-
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, schema, editable, editMode, layoutPosition, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
110
|
+
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode, layoutPosition, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
103
111
|
|
|
104
112
|
interface UnknownBlockProps {
|
|
105
113
|
type: string;
|
|
106
114
|
}
|
|
107
115
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
108
116
|
|
|
109
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, UnknownBlock, type UnknownBlockProps, resolveBlockData, resolveLayoutBlockData };
|
|
117
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type EditorBlockData, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, UnknownBlock, type UnknownBlockProps, resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ interface CmssyServerPageProps {
|
|
|
34
34
|
*/
|
|
35
35
|
declare function CmssyServerPage({ page, blocks, locale: localeProp, defaultLocale: defaultLocaleProp, enabledLocales: enabledLocalesProp, config, forms, auth, workspace, editMode, }: CmssyServerPageProps): Promise<react_jsx_runtime.JSX.Element | null>;
|
|
36
36
|
|
|
37
|
+
interface EditorBlockData {
|
|
38
|
+
data: Record<string, unknown>;
|
|
39
|
+
content: Record<string, Record<string, unknown>>;
|
|
40
|
+
}
|
|
37
41
|
interface ResolveBlockDataOptions {
|
|
38
42
|
page: CmssyPageData | null;
|
|
39
43
|
blocks: BlockDefinition[];
|
|
@@ -45,7 +49,8 @@ interface ResolveBlockDataOptions {
|
|
|
45
49
|
/** Workspace the relation records are read from. No config, no resolution. */
|
|
46
50
|
config?: CmssyClientConfig;
|
|
47
51
|
}
|
|
48
|
-
declare function
|
|
52
|
+
declare function resolveEditorBlockData({ page, blocks, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveBlockDataOptions): Promise<EditorBlockData>;
|
|
53
|
+
declare function resolveBlockData(options: ResolveBlockDataOptions): Promise<Record<string, unknown>>;
|
|
49
54
|
interface ResolveLayoutBlockDataOptions {
|
|
50
55
|
groups: CmssyLayoutGroup[];
|
|
51
56
|
blocks: BlockDefinition[];
|
|
@@ -58,7 +63,8 @@ interface ResolveLayoutBlockDataOptions {
|
|
|
58
63
|
/** Workspace the relation records are read from. No config, no resolution. */
|
|
59
64
|
config?: CmssyClientConfig;
|
|
60
65
|
}
|
|
61
|
-
declare function
|
|
66
|
+
declare function resolveEditorLayoutBlockData({ groups, blocks, position, locale, defaultLocale, enabledLocales, forms, isPreview, config, }: ResolveLayoutBlockDataOptions): Promise<EditorBlockData>;
|
|
67
|
+
declare function resolveLayoutBlockData(options: ResolveLayoutBlockDataOptions): Promise<Record<string, unknown>>;
|
|
62
68
|
|
|
63
69
|
interface CmssyServerLayoutProps {
|
|
64
70
|
groups: CmssyLayoutGroup[];
|
|
@@ -91,6 +97,8 @@ interface CmssyBlockProps {
|
|
|
91
97
|
patchedContent?: Record<string, unknown>;
|
|
92
98
|
patchedStyle?: Record<string, unknown>;
|
|
93
99
|
patchedAdvanced?: Record<string, unknown>;
|
|
100
|
+
/** Server-resolved content for this block (locale flattened, relations resolved). */
|
|
101
|
+
resolvedContent?: Record<string, unknown>;
|
|
94
102
|
/** The block's field schema; lets the client render coerce raw relation values. */
|
|
95
103
|
schema?: Record<string, FieldDefinition>;
|
|
96
104
|
editable?: boolean;
|
|
@@ -99,11 +107,11 @@ interface CmssyBlockProps {
|
|
|
99
107
|
context?: CmssyBlockContext;
|
|
100
108
|
data?: unknown;
|
|
101
109
|
}
|
|
102
|
-
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, schema, editable, editMode, layoutPosition, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
110
|
+
declare function CmssyBlock({ block, locale, defaultLocale, blockMap, patchedContent, patchedStyle, patchedAdvanced, resolvedContent, schema, editable, editMode, layoutPosition, context, data, }: CmssyBlockProps): react_jsx_runtime.JSX.Element | null;
|
|
103
111
|
|
|
104
112
|
interface UnknownBlockProps {
|
|
105
113
|
type: string;
|
|
106
114
|
}
|
|
107
115
|
declare function UnknownBlock({ type }: UnknownBlockProps): react_jsx_runtime.JSX.Element;
|
|
108
116
|
|
|
109
|
-
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, UnknownBlock, type UnknownBlockProps, resolveBlockData, resolveLayoutBlockData };
|
|
117
|
+
export { BlockDefinition, BlockMap, CmssyBlock, type CmssyBlockProps, CmssyServerLayout, type CmssyServerLayoutProps, CmssyServerPage, type CmssyServerPageProps, type EditorBlockData, type ResolveBlockDataOptions, type ResolveLayoutBlockDataOptions, UnknownBlock, type UnknownBlockProps, resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
package/dist/index.js
CHANGED
|
@@ -318,18 +318,20 @@ async function CmssyServerPage({
|
|
|
318
318
|
}
|
|
319
319
|
function collectBlockData(blocks, resolved, isPreview) {
|
|
320
320
|
const data = {};
|
|
321
|
+
const content = {};
|
|
321
322
|
blocks.forEach((block, index) => {
|
|
322
323
|
const entry = resolved[index];
|
|
323
324
|
if (!entry) return;
|
|
325
|
+
content[block.id] = entry.content;
|
|
324
326
|
if (entry.error && isPreview) {
|
|
325
327
|
data[block.id] = markBlockError(entry.error);
|
|
326
328
|
} else if (entry.data !== void 0) {
|
|
327
329
|
data[block.id] = entry.data;
|
|
328
330
|
}
|
|
329
331
|
});
|
|
330
|
-
return data;
|
|
332
|
+
return { data, content };
|
|
331
333
|
}
|
|
332
|
-
async function
|
|
334
|
+
async function resolveEditorBlockData({
|
|
333
335
|
page,
|
|
334
336
|
blocks,
|
|
335
337
|
locale,
|
|
@@ -339,7 +341,7 @@ async function resolveBlockData({
|
|
|
339
341
|
isPreview = false,
|
|
340
342
|
config
|
|
341
343
|
}) {
|
|
342
|
-
if (!page) return {};
|
|
344
|
+
if (!page) return { data: {}, content: {} };
|
|
343
345
|
const loaderMap = buildLoaderMap(blocks);
|
|
344
346
|
const context = buildBlockContext(
|
|
345
347
|
locale,
|
|
@@ -359,7 +361,10 @@ async function resolveBlockData({
|
|
|
359
361
|
);
|
|
360
362
|
return collectBlockData(page.blocks, resolved, isPreview);
|
|
361
363
|
}
|
|
362
|
-
async function
|
|
364
|
+
async function resolveBlockData(options) {
|
|
365
|
+
return (await resolveEditorBlockData(options)).data;
|
|
366
|
+
}
|
|
367
|
+
async function resolveEditorLayoutBlockData({
|
|
363
368
|
groups,
|
|
364
369
|
blocks,
|
|
365
370
|
position,
|
|
@@ -372,7 +377,7 @@ async function resolveLayoutBlockData({
|
|
|
372
377
|
}) {
|
|
373
378
|
const group = groups.find((g) => g.position === position);
|
|
374
379
|
const layoutBlocks = group ? group.blocks.filter((b) => b.isActive).slice().sort((a, b) => a.order - b.order) : [];
|
|
375
|
-
if (layoutBlocks.length === 0) return {};
|
|
380
|
+
if (layoutBlocks.length === 0) return { data: {}, content: {} };
|
|
376
381
|
const loaderMap = buildLoaderMap(blocks);
|
|
377
382
|
const context = buildBlockContext(
|
|
378
383
|
locale,
|
|
@@ -392,6 +397,9 @@ async function resolveLayoutBlockData({
|
|
|
392
397
|
);
|
|
393
398
|
return collectBlockData(layoutBlocks, resolved, isPreview);
|
|
394
399
|
}
|
|
400
|
+
async function resolveLayoutBlockData(options) {
|
|
401
|
+
return (await resolveEditorLayoutBlockData(options)).data;
|
|
402
|
+
}
|
|
395
403
|
async function CmssyServerLayout({
|
|
396
404
|
groups,
|
|
397
405
|
blocks,
|
|
@@ -442,6 +450,7 @@ function CmssyBlock({
|
|
|
442
450
|
patchedContent,
|
|
443
451
|
patchedStyle,
|
|
444
452
|
patchedAdvanced,
|
|
453
|
+
resolvedContent,
|
|
445
454
|
schema,
|
|
446
455
|
editable,
|
|
447
456
|
editMode,
|
|
@@ -488,9 +497,9 @@ function CmssyBlock({
|
|
|
488
497
|
)
|
|
489
498
|
);
|
|
490
499
|
}
|
|
491
|
-
const base = getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
500
|
+
const base = resolvedContent ? { ...resolvedContent } : getBlockContentForLanguage(block.content, locale, defaultLocale);
|
|
492
501
|
const content = patchedContent ? { ...base, ...patchedContent } : base;
|
|
493
|
-
if (schema) normalizeRelationContent(content, schema);
|
|
502
|
+
if (schema) normalizeRelationContent(content, schema, resolvedContent);
|
|
494
503
|
const style = patchedStyle ? { ...asBucket(block.style), ...patchedStyle } : asBucket(block.style);
|
|
495
504
|
const advanced = patchedAdvanced ? { ...asBucket(block.advanced), ...patchedAdvanced } : asBucket(block.advanced);
|
|
496
505
|
return wrap(
|
|
@@ -512,4 +521,4 @@ function CmssyBlock({
|
|
|
512
521
|
);
|
|
513
522
|
}
|
|
514
523
|
|
|
515
|
-
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, blocksToMeta, blocksToSchemas, buildBlockMap, defineBlock, resolveBlockData, resolveLayoutBlockData };
|
|
524
|
+
export { CmssyBlock, CmssyServerLayout, CmssyServerPage, UnknownBlock, blocksToMeta, blocksToSchemas, buildBlockMap, defineBlock, resolveBlockData, resolveEditorBlockData, resolveEditorLayoutBlockData, resolveLayoutBlockData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/react",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.1",
|
|
4
4
|
"description": "React blocks, renderers, data client and editor bridge for cmssy headless sites",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@cmssy/types": "0.29.0",
|
|
65
|
-
"@cmssy/core": "9.
|
|
65
|
+
"@cmssy/core": "9.7.1"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsup",
|