@contentstack/studio-react-editor 1.4.0 → 1.5.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/components/BuildingIllustration.js +8 -0
- package/dist/components/BuildingIllustration.js.map +1 -0
- package/dist/components/EditableRenderer.js +29 -4
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +70 -22
- package/dist/components/Element.js.map +1 -1
- package/dist/components/PreviewRenderer.js +7 -0
- package/dist/components/PreviewRenderer.js.map +1 -1
- package/dist/components/Slot.js +26 -4
- package/dist/components/Slot.js.map +1 -1
- package/dist/components/WelcomeState.js +67 -0
- package/dist/components/WelcomeState.js.map +1 -0
- package/dist/components/elements/ConditionBlock.js +7 -0
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/Repeater.js +11 -38
- package/dist/components/elements/Repeater.js.map +1 -1
- package/dist/components/elements/SectionComposition.js +226 -0
- package/dist/components/elements/SectionComposition.js.map +1 -0
- package/dist/components/elements/SectionSlot.js +199 -0
- package/dist/components/elements/SectionSlot.js.map +1 -0
- package/dist/components/elements/Symbol.js +9 -2
- package/dist/components/elements/Symbol.js.map +1 -1
- package/dist/components/styles.js +72 -0
- package/dist/components/styles.js.map +1 -1
- package/dist/contexts/providers/edit-context.provider.js +14 -0
- package/dist/contexts/providers/edit-context.provider.js.map +1 -0
- package/dist/contexts/providers/renderer.provider.js +1 -0
- package/dist/contexts/providers/renderer.provider.js.map +1 -1
- package/dist/contexts/providers/section-mode.provider.js +15 -0
- package/dist/contexts/providers/section-mode.provider.js.map +1 -0
- package/dist/contexts/providers/symbol-ui.provider.js +21 -6
- package/dist/contexts/providers/symbol-ui.provider.js.map +1 -1
- package/dist/hooks/use-active-node-path.hook.js +8 -1
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-condition-block-context.js +8 -1
- package/dist/hooks/use-condition-block-context.js.map +1 -1
- package/dist/hooks/use-design-preview.hook.js +8 -1
- package/dist/hooks/use-design-preview.hook.js.map +1 -1
- package/dist/hooks/use-edit-context-listener.hook.js +48 -0
- package/dist/hooks/use-edit-context-listener.hook.js.map +1 -0
- package/dist/hooks/use-preview-mode.hook.js +8 -1
- package/dist/hooks/use-preview-mode.hook.js.map +1 -1
- package/dist/hooks/use-register-section.hook.js +110 -0
- package/dist/hooks/use-register-section.hook.js.map +1 -0
- package/dist/hooks/use-renderer.hook.js +8 -1
- package/dist/hooks/use-renderer.hook.js.map +1 -1
- package/dist/hooks/use-repeater.hook.js +8 -1
- package/dist/hooks/use-repeater.hook.js.map +1 -1
- package/dist/hooks/use-section-events.hook.js +63 -0
- package/dist/hooks/use-section-events.hook.js.map +1 -0
- package/dist/hooks/use-should-show-design.hook.js +48 -2
- package/dist/hooks/use-should-show-design.hook.js.map +1 -1
- package/dist/hooks/use-spec-data-listener.hook.js +402 -12
- package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
- package/dist/hooks/use-symbol-events.hook.js +13 -0
- package/dist/hooks/use-symbol-events.hook.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +11 -15
|
@@ -50,6 +50,23 @@ const styleFactory = (css) => ({
|
|
|
50
50
|
textAlign: "center",
|
|
51
51
|
margin: 0,
|
|
52
52
|
}),
|
|
53
|
+
embeddedSectionHost: css({
|
|
54
|
+
position: "relative",
|
|
55
|
+
".cs-embedded-section-edit-btn": {
|
|
56
|
+
display: "none",
|
|
57
|
+
},
|
|
58
|
+
"&:hover": {
|
|
59
|
+
".cs-embedded-section-edit-btn": {
|
|
60
|
+
display: "flex",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
embeddedSectionButton: css({
|
|
65
|
+
position: "absolute",
|
|
66
|
+
top: "0.75rem",
|
|
67
|
+
right: "0.75rem",
|
|
68
|
+
zIndex: 2,
|
|
69
|
+
}),
|
|
53
70
|
rendererErrorComponent: css({
|
|
54
71
|
boxSizing: "border-box",
|
|
55
72
|
backgroundColor: "#fff0ed",
|
|
@@ -84,6 +101,61 @@ const styleFactory = (css) => ({
|
|
|
84
101
|
margin: 0,
|
|
85
102
|
},
|
|
86
103
|
}),
|
|
104
|
+
welcomeContainer: css({
|
|
105
|
+
display: "flex",
|
|
106
|
+
flexDirection: "column",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
justifyContent: "center",
|
|
109
|
+
padding: "40px 20px",
|
|
110
|
+
textAlign: "center",
|
|
111
|
+
minHeight: "400px",
|
|
112
|
+
}),
|
|
113
|
+
welcomeTitle: css({
|
|
114
|
+
fontSize: "20px",
|
|
115
|
+
fontWeight: "600",
|
|
116
|
+
color: "#475161",
|
|
117
|
+
margin: "20px 0 10px 0",
|
|
118
|
+
fontFamily: "Inter, sans-serif",
|
|
119
|
+
}),
|
|
120
|
+
welcomeSubtitle: css({
|
|
121
|
+
fontSize: "14px",
|
|
122
|
+
color: "#6E6B86",
|
|
123
|
+
margin: "0 0 30px 0",
|
|
124
|
+
maxWidth: "400px",
|
|
125
|
+
fontFamily: "Inter, sans-serif",
|
|
126
|
+
lineHeight: "1.5",
|
|
127
|
+
}),
|
|
128
|
+
welcomeSteps: css({
|
|
129
|
+
display: "flex",
|
|
130
|
+
flexDirection: "column",
|
|
131
|
+
gap: "16px",
|
|
132
|
+
maxWidth: "1000px",
|
|
133
|
+
width: "100%",
|
|
134
|
+
}),
|
|
135
|
+
welcomeStep: css({
|
|
136
|
+
padding: "16px",
|
|
137
|
+
border: "1px solid #DDE3EE",
|
|
138
|
+
borderRadius: "8px",
|
|
139
|
+
textAlign: "left",
|
|
140
|
+
"& h3": {
|
|
141
|
+
fontSize: "16px",
|
|
142
|
+
fontWeight: "600",
|
|
143
|
+
color: "#475161",
|
|
144
|
+
margin: "0 0 8px 0",
|
|
145
|
+
fontFamily: "Inter, sans-serif",
|
|
146
|
+
},
|
|
147
|
+
"& p": {
|
|
148
|
+
fontSize: "14px",
|
|
149
|
+
color: "#6E6B86",
|
|
150
|
+
margin: 0,
|
|
151
|
+
fontFamily: "Inter, sans-serif",
|
|
152
|
+
lineHeight: "1.4",
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
activeWelcomeStep: css({
|
|
156
|
+
backgroundColor: "#F9F8FF",
|
|
157
|
+
border: "1px solid #6C5CE7",
|
|
158
|
+
}),
|
|
87
159
|
});
|
|
88
160
|
|
|
89
161
|
export { styleFactory };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../src/components/styles.ts"],"sourcesContent":["import { css as gooberCss } from \"goober\";\n\nexport const styleFactory = (css: typeof gooberCss) => ({\n embedStyle: css({\n height: \"100%\",\n width: \"100%\",\n display: \"grid\",\n placeItems: \"center\",\n padding: \"1rem\",\n border: \"1px solid #dde3ee\",\n }),\n embedIconStyle: css({\n opacity: 0.5,\n }),\n pageStyle: css({\n height: \"100%\",\n }),\n slotStyle: css({\n boxSizing: \"border-box\",\n // width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n gap: \"4px\",\n alignItems: \"center\",\n justifyContent: \"center\",\n border: \"1px dashed #6c5ce7\",\n color: \"#475161\",\n fontSize: \"14px\",\n fontStyle: \"normal\",\n fontWeight: 400,\n lineHeight: \"24px\",\n userSelect: \"none\",\n fontFamily: \"Inter\",\n paddingInline: \"2rem\",\n paddingBlock: \"1rem\",\n transition: \"background-color 0.3s ease\",\n }),\n slotContentStyle: css({\n marginBottom: 0,\n marginTop: 0,\n }),\n slotColumnStyle: css({\n flexDirection: \"column\",\n gap: \"4px\",\n }),\n slotDropText: css({\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n }),\n slotHintStyle: css({\n textAlign: \"center\",\n margin: 0,\n }),\n rendererErrorComponent: css({\n boxSizing: \"border-box\",\n backgroundColor: \"#fff0ed\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"#fdafa3\",\n boxShadow: `0px 2px 4px rgba(0, 0, 0, 0.14),\n 0px 5px 5px rgba(0, 0, 0, 0.12),\n 0px 1px 10px rgba(108, 92, 231, 0.2)`,\n borderRadius: \"4px\",\n padding: \"1rem\",\n color: \"#475161\",\n fontFamily: \"Inter, sans-serif\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"1rem\",\n \".header\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n },\n h3: {\n fontSize: \"14px\",\n fontWeight: 600,\n margin: 0,\n },\n p: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: \"24px\",\n letterSpacing: \"1%\",\n margin: 0,\n },\n }),\n});\n"],"names":[],"mappings":"MAEa,YAAY,GAAG,CAAC,GAAqB,MAAM;IACtD,UAAU,EAAE,GAAG,CAAC;AACd,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;IACF,cAAc,EAAE,GAAG,CAAC;AAClB,QAAA,OAAO,EAAE,GAAG;KACb,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,MAAM,EAAE,MAAM;KACf,CAAC;IACF,SAAS,EAAE,GAAG,CAAC;AACb,QAAA,SAAS,EAAE,YAAY;;AAEvB,QAAA,MAAM,EAAE,MAAM;AACd,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,GAAG,EAAE,KAAK;AACV,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,cAAc,EAAE,QAAQ;AACxB,QAAA,MAAM,EAAE,oBAAoB;AAC5B,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,SAAS,EAAE,QAAQ;AACnB,QAAA,UAAU,EAAE,GAAG;AACf,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,UAAU,EAAE,MAAM;AAClB,QAAA,UAAU,EAAE,OAA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AAA;AACD,QAAA,CAAC,EAAE;AACD,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,UAAU,EAAE,MAAM;AAClB,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,MAAM,EAAE,CAAC;AACV,SAAA;KACF,CAAC;AACH,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../src/components/styles.ts"],"sourcesContent":["import { css as gooberCss } from \"goober\";\n\nexport const styleFactory = (css: typeof gooberCss) => ({\n embedStyle: css({\n height: \"100%\",\n width: \"100%\",\n display: \"grid\",\n placeItems: \"center\",\n padding: \"1rem\",\n border: \"1px solid #dde3ee\",\n }),\n embedIconStyle: css({\n opacity: 0.5,\n }),\n pageStyle: css({\n height: \"100%\",\n }),\n slotStyle: css({\n boxSizing: \"border-box\",\n // width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n gap: \"4px\",\n alignItems: \"center\",\n justifyContent: \"center\",\n border: \"1px dashed #6c5ce7\",\n color: \"#475161\",\n fontSize: \"14px\",\n fontStyle: \"normal\",\n fontWeight: 400,\n lineHeight: \"24px\",\n userSelect: \"none\",\n fontFamily: \"Inter\",\n paddingInline: \"2rem\",\n paddingBlock: \"1rem\",\n transition: \"background-color 0.3s ease\",\n }),\n slotContentStyle: css({\n marginBottom: 0,\n marginTop: 0,\n }),\n slotColumnStyle: css({\n flexDirection: \"column\",\n gap: \"4px\",\n }),\n slotDropText: css({\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: \"4px\",\n }),\n slotHintStyle: css({\n textAlign: \"center\",\n margin: 0,\n }),\n embeddedSectionHost: css({\n position: \"relative\",\n \".cs-embedded-section-edit-btn\": {\n display: \"none\",\n },\n \"&:hover\": {\n \".cs-embedded-section-edit-btn\": {\n display: \"flex\",\n },\n },\n }),\n embeddedSectionButton: css({\n position: \"absolute\",\n top: \"0.75rem\",\n right: \"0.75rem\",\n zIndex: 2,\n }),\n rendererErrorComponent: css({\n boxSizing: \"border-box\",\n backgroundColor: \"#fff0ed\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"#fdafa3\",\n boxShadow: `0px 2px 4px rgba(0, 0, 0, 0.14),\n 0px 5px 5px rgba(0, 0, 0, 0.12),\n 0px 1px 10px rgba(108, 92, 231, 0.2)`,\n borderRadius: \"4px\",\n padding: \"1rem\",\n color: \"#475161\",\n fontFamily: \"Inter, sans-serif\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"1rem\",\n \".header\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"0.5rem\",\n },\n h3: {\n fontSize: \"14px\",\n fontWeight: 600,\n margin: 0,\n },\n p: {\n fontSize: \"1rem\",\n fontWeight: 400,\n lineHeight: \"24px\",\n letterSpacing: \"1%\",\n margin: 0,\n },\n }),\n welcomeContainer: css({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: \"40px 20px\",\n textAlign: \"center\",\n minHeight: \"400px\",\n }),\n welcomeTitle: css({\n fontSize: \"20px\",\n fontWeight: \"600\",\n color: \"#475161\",\n margin: \"20px 0 10px 0\",\n fontFamily: \"Inter, sans-serif\",\n }),\n welcomeSubtitle: css({\n fontSize: \"14px\",\n color: \"#6E6B86\",\n margin: \"0 0 30px 0\",\n maxWidth: \"400px\",\n fontFamily: \"Inter, sans-serif\",\n lineHeight: \"1.5\",\n }),\n welcomeSteps: css({\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"16px\",\n maxWidth: \"1000px\",\n width: \"100%\",\n }),\n welcomeStep: css({\n padding: \"16px\",\n border: \"1px solid #DDE3EE\",\n borderRadius: \"8px\",\n textAlign: \"left\",\n \"& h3\": {\n fontSize: \"16px\",\n fontWeight: \"600\",\n color: \"#475161\",\n margin: \"0 0 8px 0\",\n fontFamily: \"Inter, sans-serif\",\n },\n \"& p\": {\n fontSize: \"14px\",\n color: \"#6E6B86\",\n margin: 0,\n fontFamily: \"Inter, sans-serif\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AAG,CAAC;AACf,QAAA,OAAO,EAAE,MAAM;AACf,QAAA,MAAM,EAAE,mBAAmB;AAC3B,QAAA,YAAY,EAAE,KAAK;AACnB,QAAA,SAAS,EAAE,MAAM;AACjB,QAAA,MAAM,EAAE;AACN,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,WAAW;AACnB,YAAA,UAAU,EAAE,mBAAmB;AAChC,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,UAAU,EAAE,mBAAmB;AAC/B,YAAA,UAAU,EAAE,KAAK;AAClB,SAAA;KACF,CAAC;IACF,iBAAiB,EAAE,GAAG,CAAC;AACrB,QAAA,eAAe,EAAE,SAAS;AAC1B,QAAA,MAAM,EAAE,mBAAmB;KAC5B,CAAC;AACH,CAAA;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { DataStepMode } from '@contentstack/studio-messenger';
|
|
3
|
+
export { DataStepMode } from '@contentstack/studio-messenger';
|
|
4
|
+
import { createContext } from 'react';
|
|
5
|
+
|
|
6
|
+
const editContext = createContext({
|
|
7
|
+
dataStepMode: DataStepMode.SchemaOrPin,
|
|
8
|
+
});
|
|
9
|
+
const EditContextProvider = ({ value, children }) => {
|
|
10
|
+
return jsx(editContext.Provider, { value: value, children: children });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { EditContextProvider, editContext };
|
|
14
|
+
//# sourceMappingURL=edit-context.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-context.provider.js","sources":["../../../src/contexts/providers/edit-context.provider.tsx"],"sourcesContent":["import { DataStepMode } from \"@contentstack/studio-messenger\";\nimport { createContext, FC } from \"react\";\n\n// Re-exported so editor-internal consumers keep importing from the providers\n// barrel; the enum's single source of truth is @contentstack/studio-messenger.\nexport { DataStepMode };\n\n/**\n * Per-composition editor context that Studio computes and pushes into the\n * iframe (pulled via `GET_EDIT_CONTEXT`, updated live via `SET_EDIT_CONTEXT`).\n * Read directly by descendants such as `WelcomeState` — it must live INSIDE\n * `EditableRenderer` (which owns the stateful spec), not the outer\n * `RendererProvider` (which is fed the one-shot initial spec).\n */\nexport interface EditContextValue {\n /**\n * Defaults to `schema-or-pin` so older Studio / anything that can't answer\n * keeps the existing \"Connect a schema or pin data\" copy.\n */\n dataStepMode: DataStepMode;\n}\n\nexport const editContext = createContext<EditContextValue>({\n dataStepMode: DataStepMode.SchemaOrPin,\n});\n\nexport const EditContextProvider: FC<{\n value: EditContextValue;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return <editContext.Provider value={value}>{children}</editContext.Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;;AAsBO,MAAM,WAAW,GAAG,aAAa,CAAmB;IACzD,YAAY,EAAE,YAAY,CAAC,WAAW;AACvC,CAAA;AAEM,MAAM,mBAAmB,GAG3B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAI;IAC3B,OAAOA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAC9E;;;;"}
|
|
@@ -13,6 +13,7 @@ const RendererProvider = (props) => {
|
|
|
13
13
|
return {
|
|
14
14
|
isCompositionBeingEdited: isCompositionEdited,
|
|
15
15
|
componentRegistry,
|
|
16
|
+
compositionPlacement: spec?.compositionEntry?.place_composition_as,
|
|
16
17
|
};
|
|
17
18
|
}, [spec, componentRegistry]);
|
|
18
19
|
return jsx(Provider, { value: value, children: children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.provider.js","sources":["../../../src/contexts/providers/renderer.provider.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n} from \"@contentstack/studio-client\";\nimport { createContext, FC, useMemo } from \"react\";\nimport { ComponentRegistryType } from \"../../types/renderer.type\";\n\ninterface RendererContext {\n isCompositionBeingEdited: boolean;\n componentRegistry: ComponentRegistryType;\n}\n\ninterface RendererProviderProps {\n componentRegistry: ComponentRegistryType;\n spec: StudioSpec;\n children: React.ReactNode;\n}\n\nexport const rendererContext = createContext<RendererContext>({\n isCompositionBeingEdited: false,\n} as RendererContext);\n\nconst { Provider } = rendererContext;\n\nexport const RendererProvider: FC<RendererProviderProps> = (props) => {\n const { children, spec, componentRegistry } = props;\n const value = useMemo(() => {\n const isCompositionEdited = isCompositionBeingEdited(\n spec?.compositionEntry?.composable_uid ?? \"\",\n );\n return {\n isCompositionBeingEdited: isCompositionEdited,\n componentRegistry,\n };\n }, [spec, componentRegistry]);\n return <Provider value={value}>{children}</Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"renderer.provider.js","sources":["../../../src/contexts/providers/renderer.provider.tsx"],"sourcesContent":["import {\n StudioSpec,\n isCompositionBeingEdited,\n type CompositionPlacement,\n} from \"@contentstack/studio-client\";\nimport { createContext, FC, useMemo } from \"react\";\nimport { ComponentRegistryType } from \"../../types/renderer.type\";\n\ninterface RendererContext {\n isCompositionBeingEdited: boolean;\n componentRegistry: ComponentRegistryType;\n compositionPlacement?: CompositionPlacement;\n}\n\ninterface RendererProviderProps {\n componentRegistry: ComponentRegistryType;\n spec: StudioSpec;\n children: React.ReactNode;\n}\n\nexport const rendererContext = createContext<RendererContext>({\n isCompositionBeingEdited: false,\n} as RendererContext);\n\nconst { Provider } = rendererContext;\n\nexport const RendererProvider: FC<RendererProviderProps> = (props) => {\n const { children, spec, componentRegistry } = props;\n const value = useMemo(() => {\n const isCompositionEdited = isCompositionBeingEdited(\n spec?.compositionEntry?.composable_uid ?? \"\",\n );\n return {\n isCompositionBeingEdited: isCompositionEdited,\n componentRegistry,\n compositionPlacement: spec?.compositionEntry?.place_composition_as,\n };\n }, [spec, componentRegistry]);\n return <Provider value={value}>{children}</Provider>;\n};\n"],"names":["_jsx"],"mappings":";;;;AAoBO,MAAM,eAAe,GAAG,aAAa,CAAkB;AAC5D,IAAA,wBAAwB,EAAE,KAAK;AACb,CAAA;AAEpB,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe;AAE7B,MAAM,gBAAgB,GAA8B,CAAC,KAAK,KAAI;IACnE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,KAAK;AACnD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,MAAK;AACzB,QAAA,MAAM,mBAAmB,GAAG,wBAAwB,CAClD,IAAI,EAAE,gBAAgB,EAAE,cAAc,IAAI,EAAE,CAC7C;QACD,OAAO;AACL,YAAA,wBAAwB,EAAE,mBAAmB;YAC7C,iBAAiB;AACjB,YAAA,oBAAoB,EAAE,IAAI,EAAE,gBAAgB,EAAE,oBAAoB;SACnE;AACH,IAAA,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC7B,OAAOA,GAAA,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAY;AACtD;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Forced design/preview mode contributed by an enclosing placed section.
|
|
5
|
+
*
|
|
6
|
+
* A placed section-composition node carries its own `metadata.mode`. When set,
|
|
7
|
+
* every repeater, condition-block, and section-slot rendered inside that section
|
|
8
|
+
* follows this mode instead of its own — a single per-placement switch derives
|
|
9
|
+
* all inner modes. `null` means "no enclosing section forcing a mode" (the inner
|
|
10
|
+
* node falls back to its own `mode`). Editor-only; production never forces.
|
|
11
|
+
*/
|
|
12
|
+
const SectionModeContext = createContext(null);
|
|
13
|
+
|
|
14
|
+
export { SectionModeContext };
|
|
15
|
+
//# sourceMappingURL=section-mode.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-mode.provider.js","sources":["../../../src/contexts/providers/section-mode.provider.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\n/**\n * Forced design/preview mode contributed by an enclosing placed section.\n *\n * A placed section-composition node carries its own `metadata.mode`. When set,\n * every repeater, condition-block, and section-slot rendered inside that section\n * follows this mode instead of its own — a single per-placement switch derives\n * all inner modes. `null` means \"no enclosing section forcing a mode\" (the inner\n * node falls back to its own `mode`). Editor-only; production never forces.\n */\nexport const SectionModeContext = createContext<\"design\" | \"preview\" | null>(\n null,\n);\n"],"names":[],"mappings":";;AAEA;;;;;;;;AAQG;MACU,kBAAkB,GAAG,aAAa,CAC7C,IAAI;;;;"}
|
|
@@ -4,14 +4,23 @@ import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack
|
|
|
4
4
|
import { SymbolUICtx } from '@contentstack/studio-react-components/contexts';
|
|
5
5
|
import { produce } from 'immer';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import '../../hooks/use-edit-context-listener.hook.js';
|
|
8
|
+
import '@contentstack/studio-internal';
|
|
9
|
+
import '@contentstack/studio-core';
|
|
10
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
11
|
+
import '@contentstack/studio-react-components/hooks';
|
|
12
|
+
import 'goober';
|
|
13
|
+
import '../../components/Element.js';
|
|
9
14
|
import './renderer.provider.js';
|
|
15
|
+
import './edit-context.provider.js';
|
|
10
16
|
import './active-node.provider.js';
|
|
11
17
|
import './use-design-preview.provider.js';
|
|
12
18
|
import './use-repeater.provider.js';
|
|
13
19
|
import './use-condition-block.provider.js';
|
|
14
20
|
import './preview-mode.provider.js';
|
|
21
|
+
import './section-mode.provider.js';
|
|
22
|
+
import { useRenderer } from '../../hooks/use-renderer.hook.js';
|
|
23
|
+
import { registerSymbolComponent } from '../../hooks/use-register-symbol.hook.js';
|
|
15
24
|
|
|
16
25
|
const SymbolUIProvider = ({ symbols, children, }) => {
|
|
17
26
|
const { componentRegistry } = useRenderer();
|
|
@@ -20,11 +29,17 @@ const SymbolUIProvider = ({ symbols, children, }) => {
|
|
|
20
29
|
return acc;
|
|
21
30
|
}, {}));
|
|
22
31
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
acc
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
if (symbols.length > 0) {
|
|
33
|
+
setSymbolUIs(symbols.reduce((acc, symbol) => {
|
|
34
|
+
acc[symbol.uid] = symbol;
|
|
35
|
+
return acc;
|
|
36
|
+
}, {}));
|
|
37
|
+
}
|
|
27
38
|
}, [symbols]);
|
|
39
|
+
// UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,
|
|
40
|
+
// which updates `state.symbols` — that flows down here as the `symbols`
|
|
41
|
+
// prop and is picked up by the useEffect above. Registering another
|
|
42
|
+
// listener here just produced a duplicate-registration warning.
|
|
28
43
|
useEffect(() => {
|
|
29
44
|
const handleApplySymbolOperation = (data) => {
|
|
30
45
|
const { uid, operations } = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-ui.provider.js","sources":["../../../src/contexts/providers/symbol-ui.provider.tsx"],"sourcesContent":["import { applyOperation, SymbolEntry } from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { SymbolUICtx } from \"@contentstack/studio-react-components/contexts\";\nimport { produce } from \"immer\";\nimport { useEffect, useState } from \"react\";\nimport { registerSymbolComponent, useRenderer } from \"../../hooks\";\n\nexport interface SymbolUIProvider {\n [uid: string]: SymbolEntry;\n}\ninterface SymbolUIProviderProps {\n children: React.ReactNode;\n symbols: SymbolEntry[];\n}\nexport const SymbolUIProvider = ({\n symbols,\n children,\n}: SymbolUIProviderProps) => {\n const { componentRegistry } = useRenderer();\n const [symbolUIs, setSymbolUIs] = useState<SymbolUIProvider>(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n\n useEffect(() => {\n setSymbolUIs(\n
|
|
1
|
+
{"version":3,"file":"symbol-ui.provider.js","sources":["../../../src/contexts/providers/symbol-ui.provider.tsx"],"sourcesContent":["import { applyOperation, SymbolEntry } from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { SymbolUICtx } from \"@contentstack/studio-react-components/contexts\";\nimport { produce } from \"immer\";\nimport { useEffect, useState } from \"react\";\nimport { registerSymbolComponent, useRenderer } from \"../../hooks\";\n\nexport interface SymbolUIProvider {\n [uid: string]: SymbolEntry;\n}\ninterface SymbolUIProviderProps {\n children: React.ReactNode;\n symbols: SymbolEntry[];\n}\nexport const SymbolUIProvider = ({\n symbols,\n children,\n}: SymbolUIProviderProps) => {\n const { componentRegistry } = useRenderer();\n const [symbolUIs, setSymbolUIs] = useState<SymbolUIProvider>(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n\n useEffect(() => {\n if (symbols.length > 0) {\n setSymbolUIs(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n }\n }, [symbols]);\n\n // UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,\n // which updates `state.symbols` — that flows down here as the `symbols`\n // prop and is picked up by the useEffect above. Registering another\n // listener here just produced a duplicate-registration warning.\n\n useEffect(() => {\n const handleApplySymbolOperation = (data: {\n operations: Operation[];\n uid: string;\n }) => {\n const { uid, operations } = data;\n setSymbolUIs((symbolUIs) => {\n if (!symbolUIs[uid]) return symbolUIs;\n const newSymbolUIs = produce(symbolUIs, (draft) => {\n const symbol = draft[uid];\n if (!symbol) return;\n const newSymbol = applyOperation(symbol.ui, operations);\n symbol.ui = newSymbol;\n draft[uid] = {\n ...symbol,\n };\n });\n registerSymbolComponent([newSymbolUIs[uid]], componentRegistry);\n return newSymbolUIs;\n });\n };\n\n const applySymbolOperationListener = composableStudioEventManager?.on<{\n operations: Operation[];\n uid: string;\n }>(POST_MESSAGE_EVENTS.APPLY_SYMBOL_OPERATION, (event) => {\n handleApplySymbolOperation(event.data);\n });\n return () => {\n applySymbolOperationListener?.unregister();\n };\n }, []);\n\n useEffect(() => {\n const newSymbolListener = composableStudioEventManager?.on<{\n symbol: SymbolEntry;\n }>(POST_MESSAGE_EVENTS.ADD_NEW_SYMBOL, (event) => {\n const { symbol } = event.data;\n registerSymbolComponent([symbol], componentRegistry);\n setSymbolUIs((symbolUIs) => {\n return produce(symbolUIs, (draft) => {\n draft[symbol.uid] = symbol;\n });\n });\n });\n return () => {\n newSymbolListener?.unregister();\n };\n }, []);\n return (\n <SymbolUICtx.Provider value={symbolUIs}>{children}</SymbolUICtx.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,QAAQ,GACc,KAAI;AAC1B,IAAA,MAAM,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;AAC3C,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACxC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAI;AAC7B,QAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AACxB,QAAA,OAAO,GAAG;AACZ,IAAA,CAAC,EAAE,EAAsB,CAAC,CAC3B;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,YAAY,CACV,OAAO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AAE;AAC5C,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,iBAAiB,GAAG,4BAA4B,EAAE,EAAE,CAEvD,mBAAmB,CAAC,cAAc,EAAE,CAAC,KAAK,KAAI;AAC/C,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI;AAC7B,YAAA,uBAAuB,CAAC,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;AACpD,YAAA,YAAY,CAAC,CAAC,SAAS,KAAI;AACzB,gBAAA,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAClC,oBAAA,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AAC5B,gBAAA,CAAC,CAAC;AACJ,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;AACF,QAAA,OAAO,MAAK;YACV,iBAAiB,EAAE,UAAU,EAAE;AACjC,QAAA,CAAC;IACH,CAAC,EAAE,EAAE,CAAC;AACN,IAAA,QACEA,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,SAAS,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB;AAE7E;;;;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { highlightNodeManager } from '@contentstack/studio-client';
|
|
2
2
|
import { useContext, useState, useEffect } from 'react';
|
|
3
3
|
import '../contexts/providers/renderer.provider.js';
|
|
4
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
4
5
|
import { ActiveComponentPathContext } from '../contexts/providers/active-node.provider.js';
|
|
5
6
|
import 'react/jsx-runtime';
|
|
6
7
|
import '@contentstack/studio-messenger';
|
|
7
8
|
import '@contentstack/studio-react-components/contexts';
|
|
8
9
|
import 'immer';
|
|
10
|
+
import './use-edit-context-listener.hook.js';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
14
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
15
|
+
import 'goober';
|
|
11
16
|
import '../components/Element.js';
|
|
17
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
12
19
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
20
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
21
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec, highlightNodeManager } from \"@contentstack/studio-client\";\nimport { Path } from \"@contentstack/studio-internal\";\nimport { useContext, useEffect, useState } from \"react\";\nimport {\n ActiveComponentPathContext,\n ActiveComponentPathContextType,\n} from \"../contexts/providers\";\n\nexport function useActiveComponentPath() {\n const activeComponentPath = useContext(ActiveComponentPathContext);\n return activeComponentPath;\n}\n\nexport function useGetActiveComponentPathContext(\n spec: StudioSpec,\n): ActiveComponentPathContextType {\n const [activeComponentPath, setActiveComponentPath] =\n useState<ActiveComponentPathContextType>({\n activeNodeUid: null,\n activeNodePath: null,\n });\n\n useEffect(() => {\n function getActiveNodeCallback(\n activeNodeUid: string,\n activeNodePath: Path,\n ) {\n if (!spec) return;\n\n setActiveComponentPath({\n activeNodeUid,\n activeNodePath,\n });\n }\n\n highlightNodeManager.onActiveNodeChange(getActiveNodeCallback, {\n syncToExistingValue: true,\n });\n\n return () => {\n highlightNodeManager.unsubscribeFromActiveNodeChange(\n getActiveNodeCallback,\n );\n };\n }, [spec]);\n\n return activeComponentPath;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-active-node-path.hook.js","sources":["../../src/hooks/use-active-node-path.hook.ts"],"sourcesContent":["import { StudioSpec, highlightNodeManager } from \"@contentstack/studio-client\";\nimport { Path } from \"@contentstack/studio-internal\";\nimport { useContext, useEffect, useState } from \"react\";\nimport {\n ActiveComponentPathContext,\n ActiveComponentPathContextType,\n} from \"../contexts/providers\";\n\nexport function useActiveComponentPath() {\n const activeComponentPath = useContext(ActiveComponentPathContext);\n return activeComponentPath;\n}\n\nexport function useGetActiveComponentPathContext(\n spec: StudioSpec,\n): ActiveComponentPathContextType {\n const [activeComponentPath, setActiveComponentPath] =\n useState<ActiveComponentPathContextType>({\n activeNodeUid: null,\n activeNodePath: null,\n });\n\n useEffect(() => {\n function getActiveNodeCallback(\n activeNodeUid: string,\n activeNodePath: Path,\n ) {\n if (!spec) return;\n\n setActiveComponentPath({\n activeNodeUid,\n activeNodePath,\n });\n }\n\n highlightNodeManager.onActiveNodeChange(getActiveNodeCallback, {\n syncToExistingValue: true,\n });\n\n return () => {\n highlightNodeManager.unsubscribeFromActiveNodeChange(\n getActiveNodeCallback,\n );\n };\n }, [spec]);\n\n return activeComponentPath;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;SAQgB,sBAAsB,GAAA;AACpC,IAAA,MAAM,mBAAmB,GAAG,UAAU,CAAC,0BAA0B,CAAC;AAClE,IAAA,OAAO,mBAAmB;AAC5B;AAEM,SAAU,gCAAgC,CAC9C,IAAgB,EAAA;AAEhB,IAAA,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,QAAQ,CAAiC;AACvC,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,cAAc,EAAE,IAAI;AACrB,KAAA,CAAC;IAEJ,SAAS,CAAC,MAAK;AACb,QAAA,SAAS,qBAAqB,CAC5B,aAAqB,EACrB,cAAoB,EAAA;AAEpB,YAAA,IAAI,CAAC,IAAI;gBAAE;AAEX,YAAA,sBAAsB,CAAC;gBACrB,aAAa;gBACb,cAAc;AACf,aAAA,CAAC;QACJ;AAEA,QAAA,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,EAAE;AAC7D,YAAA,mBAAmB,EAAE,IAAI;AAC1B,SAAA,CAAC;AAEF,QAAA,OAAO,MAAK;AACV,YAAA,oBAAoB,CAAC,+BAA+B,CAClD,qBAAqB,CACtB;AACH,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AAEV,IAAA,OAAO,mBAAmB;AAC5B;;;;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import '../contexts/providers/renderer.provider.js';
|
|
3
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
3
4
|
import '../contexts/providers/active-node.provider.js';
|
|
4
5
|
import 'react/jsx-runtime';
|
|
5
6
|
import '@contentstack/studio-client';
|
|
6
7
|
import '@contentstack/studio-messenger';
|
|
7
8
|
import '@contentstack/studio-react-components/contexts';
|
|
8
9
|
import 'immer';
|
|
10
|
+
import './use-edit-context-listener.hook.js';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
14
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
15
|
+
import 'goober';
|
|
11
16
|
import '../components/Element.js';
|
|
17
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
12
19
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
20
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
21
|
import { ConditionBlockContext } from '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-condition-block-context.js","sources":["../../src/hooks/use-condition-block-context.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ConditionBlockContext } from \"../contexts/providers\";\n\nexport const useConditionBlockContext = () => useContext(ConditionBlockContext);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-condition-block-context.js","sources":["../../src/hooks/use-condition-block-context.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ConditionBlockContext } from \"../contexts/providers\";\n\nexport const useConditionBlockContext = () => useContext(ConditionBlockContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,wBAAwB,GAAG,MAAM,UAAU,CAAC,qBAAqB;;;;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import '../contexts/providers/renderer.provider.js';
|
|
3
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
3
4
|
import '../contexts/providers/active-node.provider.js';
|
|
4
5
|
import 'react/jsx-runtime';
|
|
5
6
|
import '@contentstack/studio-client';
|
|
6
7
|
import '@contentstack/studio-messenger';
|
|
7
8
|
import '@contentstack/studio-react-components/contexts';
|
|
8
9
|
import 'immer';
|
|
10
|
+
import './use-edit-context-listener.hook.js';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
14
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
15
|
+
import 'goober';
|
|
11
16
|
import '../components/Element.js';
|
|
17
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
12
19
|
import { DesignPreviewContext } from '../contexts/providers/use-design-preview.provider.js';
|
|
13
20
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
21
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-design-preview.hook.js","sources":["../../src/hooks/use-design-preview.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { DesignPreviewContext } from \"../contexts/providers\";\n\nexport const useDesignPreviewContext = () => useContext(DesignPreviewContext);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-design-preview.hook.js","sources":["../../src/hooks/use-design-preview.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { DesignPreviewContext } from \"../contexts/providers\";\n\nexport const useDesignPreviewContext = () => useContext(DesignPreviewContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,uBAAuB,GAAG,MAAM,UAAU,CAAC,oBAAoB;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { clientRendererModeUtil } from '@contentstack/studio-client';
|
|
2
|
+
import { DataStepMode, composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
5
|
+
|
|
6
|
+
const DATA_STEP_MODES = Object.values(DataStepMode);
|
|
7
|
+
const isDataStepMode = (v) => DATA_STEP_MODES.includes(v);
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the per-composition editor context Studio owns (currently just
|
|
10
|
+
* `dataStepMode` — see composable-studio ADR 0008).
|
|
11
|
+
*
|
|
12
|
+
* Init is a PULL: once this effect runs (our handlers are mounted) we request
|
|
13
|
+
* the value from Studio, so it can never race an init-time push. A separate
|
|
14
|
+
* `SET_EDIT_CONTEXT` listener applies later live changes (e.g. the Freeform
|
|
15
|
+
* plan toggled mid-session). Defaults to `schema-or-pin` so anything that can't
|
|
16
|
+
* answer keeps the existing copy.
|
|
17
|
+
*/
|
|
18
|
+
const useEditContextListener = (composableUid) => {
|
|
19
|
+
const [dataStepMode, setDataStepMode] = useState(DataStepMode.SchemaOrPin);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!clientRendererModeUtil.isInsideStudioFrame())
|
|
22
|
+
return;
|
|
23
|
+
let cancelled = false;
|
|
24
|
+
composableStudioEventManager
|
|
25
|
+
?.send(POST_MESSAGE_EVENTS.GET_EDIT_CONTEXT, { composableUid })
|
|
26
|
+
.then((res) => {
|
|
27
|
+
if (!cancelled && isDataStepMode(res?.dataStepMode)) {
|
|
28
|
+
setDataStepMode(res.dataStepMode);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
.catch(() => {
|
|
32
|
+
// Older Studio has no responder — keep the default.
|
|
33
|
+
});
|
|
34
|
+
const listener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.SET_EDIT_CONTEXT, (event) => {
|
|
35
|
+
if (isDataStepMode(event?.data?.dataStepMode)) {
|
|
36
|
+
setDataStepMode(event.data.dataStepMode);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
listener?.unregister();
|
|
42
|
+
};
|
|
43
|
+
}, [composableUid]);
|
|
44
|
+
return { dataStepMode };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { useEditContextListener };
|
|
48
|
+
//# sourceMappingURL=use-edit-context-listener.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-edit-context-listener.hook.js","sources":["../../src/hooks/use-edit-context-listener.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { useEffect, useState } from \"react\";\nimport { DataStepMode } from \"../contexts/providers/edit-context.provider\";\n\nconst DATA_STEP_MODES = Object.values(DataStepMode) as DataStepMode[];\nconst isDataStepMode = (v: unknown): v is DataStepMode =>\n DATA_STEP_MODES.includes(v as DataStepMode);\n\n/**\n * Resolves the per-composition editor context Studio owns (currently just\n * `dataStepMode` — see composable-studio ADR 0008).\n *\n * Init is a PULL: once this effect runs (our handlers are mounted) we request\n * the value from Studio, so it can never race an init-time push. A separate\n * `SET_EDIT_CONTEXT` listener applies later live changes (e.g. the Freeform\n * plan toggled mid-session). Defaults to `schema-or-pin` so anything that can't\n * answer keeps the existing copy.\n */\nexport const useEditContextListener = (\n composableUid?: string,\n): { dataStepMode: DataStepMode } => {\n const [dataStepMode, setDataStepMode] = useState<DataStepMode>(\n DataStepMode.SchemaOrPin,\n );\n\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n\n let cancelled = false;\n\n composableStudioEventManager\n ?.send<{ dataStepMode?: DataStepMode }>(\n POST_MESSAGE_EVENTS.GET_EDIT_CONTEXT,\n { composableUid },\n )\n .then((res) => {\n if (!cancelled && isDataStepMode(res?.dataStepMode)) {\n setDataStepMode(res.dataStepMode);\n }\n })\n .catch(() => {\n // Older Studio has no responder — keep the default.\n });\n\n const listener = composableStudioEventManager?.on<{\n dataStepMode?: DataStepMode;\n }>(POST_MESSAGE_EVENTS.SET_EDIT_CONTEXT, (event) => {\n if (isDataStepMode(event?.data?.dataStepMode)) {\n setDataStepMode(event.data.dataStepMode as DataStepMode);\n }\n });\n\n return () => {\n cancelled = true;\n listener?.unregister();\n };\n }, [composableUid]);\n\n return { dataStepMode };\n};\n"],"names":[],"mappings":";;;;;AAQA,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAmB;AACrE,MAAM,cAAc,GAAG,CAAC,CAAU,KAChC,eAAe,CAAC,QAAQ,CAAC,CAAiB,CAAC;AAE7C;;;;;;;;;AASG;AACI,MAAM,sBAAsB,GAAG,CACpC,aAAsB,KACY;AAClC,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,YAAY,CAAC,WAAW,CACzB;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE;YAAE;QAEnD,IAAI,SAAS,GAAG,KAAK;QAErB;cACI,IAAI,CACJ,mBAAmB,CAAC,gBAAgB,EACpC,EAAE,aAAa,EAAE;AAElB,aAAA,IAAI,CAAC,CAAC,GAAG,KAAI;YACZ,IAAI,CAAC,SAAS,IAAI,cAAc,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE;AACnD,gBAAA,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;YACnC;AACF,QAAA,CAAC;aACA,KAAK,CAAC,MAAK;;AAEZ,QAAA,CAAC,CAAC;AAEJ,QAAA,MAAM,QAAQ,GAAG,4BAA4B,EAAE,EAAE,CAE9C,mBAAmB,CAAC,gBAAgB,EAAE,CAAC,KAAK,KAAI;YACjD,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE;AAC7C,gBAAA,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,YAA4B,CAAC;YAC1D;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,MAAK;YACV,SAAS,GAAG,IAAI;YAChB,QAAQ,EAAE,UAAU,EAAE;AACxB,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEnB,OAAO,EAAE,YAAY,EAAE;AACzB;;;;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import '../contexts/providers/renderer.provider.js';
|
|
3
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
3
4
|
import '../contexts/providers/active-node.provider.js';
|
|
4
5
|
import 'react/jsx-runtime';
|
|
5
6
|
import '@contentstack/studio-client';
|
|
6
7
|
import '@contentstack/studio-messenger';
|
|
7
8
|
import '@contentstack/studio-react-components/contexts';
|
|
8
9
|
import 'immer';
|
|
10
|
+
import './use-edit-context-listener.hook.js';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
14
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
15
|
+
import 'goober';
|
|
11
16
|
import '../components/Element.js';
|
|
17
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
12
19
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
20
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
21
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-preview-mode.hook.js","sources":["../../src/hooks/use-preview-mode.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport const usePreviewMode = () => {\n return useContext(PreviewModeContext);\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-preview-mode.hook.js","sources":["../../src/hooks/use-preview-mode.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { PreviewModeContext } from \"../contexts/providers\";\n\nexport const usePreviewMode = () => {\n return useContext(PreviewModeContext);\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,cAAc,GAAG,MAAK;AACjC,IAAA,OAAO,UAAU,CAAC,kBAAkB,CAAC;AACvC;;;;"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { preProcessStaticValues } from '@contentstack/studio-client';
|
|
3
|
+
import { Node } from '@contentstack/studio-internal';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { SectionComposition } from '../components/elements/SectionComposition.js';
|
|
6
|
+
import { useRenderer } from './use-renderer.hook.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reads sectionExposedProps from the section's UI metadata and converts them
|
|
10
|
+
* into the Props format that the component registry understands.
|
|
11
|
+
*
|
|
12
|
+
* This is what makes retrievePropValue resolve exposed-prop bindings on the
|
|
13
|
+
* page-level section-composition node — without these registered props the
|
|
14
|
+
* resolver skips them entirely and the override values never reach the section.
|
|
15
|
+
*
|
|
16
|
+
* Each exposed prop is enriched with the FULL schema of the internal component
|
|
17
|
+
* prop it was exposed from (looked up via the internal node's registered
|
|
18
|
+
* component). Registering only { type, displayName } loses `placeholder` and
|
|
19
|
+
* `defaultValue`, so a CLEARED exposed prop resolves to an empty value instead
|
|
20
|
+
* of the component's editor placeholder (e.g. "Your text here"). With the full
|
|
21
|
+
* schema, a cleared exposed prop resolves exactly like a normal unbound node —
|
|
22
|
+
* showing the placeholder in Studio — and the override carries it down to the
|
|
23
|
+
* internal node. The editor panel registration enriches the same way.
|
|
24
|
+
*/
|
|
25
|
+
function buildRegisteredProps(section, componentRegistry) {
|
|
26
|
+
const exposedPropDefs = section.ui?.metadata?.sectionExposedProps ?? [];
|
|
27
|
+
// Index the section's internal nodes by uid so each exposed prop can recover
|
|
28
|
+
// its originating component prop schema.
|
|
29
|
+
const nodeByUid = new Map();
|
|
30
|
+
if (section.ui) {
|
|
31
|
+
for (const [node] of Node.nodes(section.ui)) {
|
|
32
|
+
if (node?.uid)
|
|
33
|
+
nodeByUid.set(node.uid, node);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const props = Object.fromEntries(exposedPropDefs.map((ep) => {
|
|
37
|
+
const internalNode = nodeByUid.get(ep.nodeUid);
|
|
38
|
+
const fullProp = internalNode
|
|
39
|
+
? componentRegistry.getComponentByNode(internalNode)?.props?.[ep.propKey]
|
|
40
|
+
: undefined;
|
|
41
|
+
return [
|
|
42
|
+
ep.uid,
|
|
43
|
+
{
|
|
44
|
+
...(fullProp ?? {}),
|
|
45
|
+
type: ep.propType,
|
|
46
|
+
displayName: ep.displayName,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}));
|
|
50
|
+
return props;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Registers section composition entries as React components in the component registry.
|
|
54
|
+
* Each section is registered with its exposed props so the page-level binding
|
|
55
|
+
* resolver can resolve override values and pass them down to SectionComposition.
|
|
56
|
+
*/
|
|
57
|
+
const registerSectionComponents = (sections, componentRegistry) => {
|
|
58
|
+
const sectionConfigs = sections.map((section) => {
|
|
59
|
+
// Section entries store `static_value` in raw shape (`{ text: [...] }`).
|
|
60
|
+
// The data binder expects the pre-processed flat shape (`{ key: value }`),
|
|
61
|
+
// so transform here before handing the section's spec to the renderer.
|
|
62
|
+
// Without this, every string prop on the section (e.g. SectionSlot's
|
|
63
|
+
// `label`) resolves to empty in consumption mode.
|
|
64
|
+
const rawStaticValue = (section?.static_value ?? {});
|
|
65
|
+
const sectionSpec = {
|
|
66
|
+
ui: section.ui,
|
|
67
|
+
data: {
|
|
68
|
+
dataSources: {},
|
|
69
|
+
static_value: preProcessStaticValues(rawStaticValue),
|
|
70
|
+
},
|
|
71
|
+
compositionEntry: section,
|
|
72
|
+
symbols: [],
|
|
73
|
+
sectionCompositions: sections,
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
type: section.uid,
|
|
77
|
+
displayName: section.title,
|
|
78
|
+
thumbnailUrl: section?.ui_preview?.url,
|
|
79
|
+
wrap: false,
|
|
80
|
+
// Exposed props registered here so retrievePropValue resolves their
|
|
81
|
+
// page-level bindings and passes the values to SectionComposition.
|
|
82
|
+
props: buildRegisteredProps(section, componentRegistry),
|
|
83
|
+
component: (props) => {
|
|
84
|
+
return (jsx(SectionComposition, { ...props, compositionUID: section.uid, spec: sectionSpec }));
|
|
85
|
+
},
|
|
86
|
+
metadata: {
|
|
87
|
+
uid: section.uid,
|
|
88
|
+
type: "section-composition",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
componentRegistry.registerSectionComponent(sectionConfigs);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* React hook that registers section components when sections array changes.
|
|
96
|
+
* Automatically handles component registration lifecycle in React components.
|
|
97
|
+
*
|
|
98
|
+
* @param sections - Optional array of section composition entries
|
|
99
|
+
*/
|
|
100
|
+
const useRegisterSectionComponents = (sections) => {
|
|
101
|
+
const { componentRegistry } = useRenderer();
|
|
102
|
+
useMemo(() => {
|
|
103
|
+
if (!sections?.length)
|
|
104
|
+
return;
|
|
105
|
+
registerSectionComponents(sections, componentRegistry);
|
|
106
|
+
}, [sections, componentRegistry]);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { registerSectionComponents, useRegisterSectionComponents };
|
|
110
|
+
//# sourceMappingURL=use-register-section.hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-register-section.hook.js","sources":["../../src/hooks/use-register-section.hook.tsx"],"sourcesContent":["import {\n SectionCompositionEntry,\n StudioSpec,\n preProcessStaticValues,\n} from \"@contentstack/studio-client\";\nimport {\n ComponentRegistry,\n Props,\n RegisterComponentOptionsInput,\n} from \"@contentstack/studio-registry\";\nimport { Node, NodePropType } from \"@contentstack/studio-internal\";\nimport { ReactNode, useMemo } from \"react\";\nimport { SectionComposition } from \"../components/elements/SectionComposition\";\nimport { useRenderer } from \"./use-renderer.hook\";\n\ninterface ExposedPropDef {\n uid: string;\n nodeUid: string;\n propKey: string;\n propType: string;\n displayName: string;\n}\n\ntype SectionRegistryConfig = RegisterComponentOptionsInput<\n (props?: any) => ReactNode\n>;\n\n/**\n * Reads sectionExposedProps from the section's UI metadata and converts them\n * into the Props format that the component registry understands.\n *\n * This is what makes retrievePropValue resolve exposed-prop bindings on the\n * page-level section-composition node — without these registered props the\n * resolver skips them entirely and the override values never reach the section.\n *\n * Each exposed prop is enriched with the FULL schema of the internal component\n * prop it was exposed from (looked up via the internal node's registered\n * component). Registering only { type, displayName } loses `placeholder` and\n * `defaultValue`, so a CLEARED exposed prop resolves to an empty value instead\n * of the component's editor placeholder (e.g. \"Your text here\"). With the full\n * schema, a cleared exposed prop resolves exactly like a normal unbound node —\n * showing the placeholder in Studio — and the override carries it down to the\n * internal node. The editor panel registration enriches the same way.\n */\nfunction buildRegisteredProps(\n section: SectionCompositionEntry,\n componentRegistry: ComponentRegistry<unknown>,\n): Props {\n const exposedPropDefs: ExposedPropDef[] =\n (section.ui?.metadata?.sectionExposedProps as\n | ExposedPropDef[]\n | undefined) ?? [];\n\n // Index the section's internal nodes by uid so each exposed prop can recover\n // its originating component prop schema.\n const nodeByUid = new Map<string, Node>();\n if (section.ui) {\n for (const [node] of Node.nodes(section.ui as Node)) {\n if (node?.uid) nodeByUid.set(node.uid, node as Node);\n }\n }\n\n const props = Object.fromEntries(\n exposedPropDefs.map((ep) => {\n const internalNode = nodeByUid.get(ep.nodeUid);\n const fullProp = internalNode\n ? componentRegistry.getComponentByNode(internalNode)?.props?.[\n ep.propKey\n ]\n : undefined;\n return [\n ep.uid,\n {\n ...(fullProp ?? {}),\n type: ep.propType as NodePropType,\n displayName: ep.displayName,\n } as Props[string],\n ];\n }),\n );\n\n return props;\n}\n\n/**\n * Registers section composition entries as React components in the component registry.\n * Each section is registered with its exposed props so the page-level binding\n * resolver can resolve override values and pass them down to SectionComposition.\n */\nexport const registerSectionComponents = (\n sections: SectionCompositionEntry[],\n componentRegistry: ComponentRegistry<unknown>,\n) => {\n const sectionConfigs: SectionRegistryConfig[] = sections.map((section) => {\n // Section entries store `static_value` in raw shape (`{ text: [...] }`).\n // The data binder expects the pre-processed flat shape (`{ key: value }`),\n // so transform here before handing the section's spec to the renderer.\n // Without this, every string prop on the section (e.g. SectionSlot's\n // `label`) resolves to empty in consumption mode.\n const rawStaticValue = ((section as any)?.static_value ?? {}) as any;\n const sectionSpec: StudioSpec = {\n ui: section.ui,\n data: {\n dataSources: {},\n static_value: preProcessStaticValues(rawStaticValue),\n },\n compositionEntry: section,\n symbols: [],\n sectionCompositions: sections,\n };\n\n return {\n type: section.uid,\n displayName: section.title,\n thumbnailUrl: section?.ui_preview?.url,\n wrap: false,\n // Exposed props registered here so retrievePropValue resolves their\n // page-level bindings and passes the values to SectionComposition.\n props: buildRegisteredProps(section, componentRegistry),\n component: (props) => {\n return (\n <SectionComposition\n {...props}\n compositionUID={section.uid}\n spec={sectionSpec}\n />\n );\n },\n metadata: {\n uid: section.uid,\n type: \"section-composition\",\n },\n };\n });\n\n componentRegistry.registerSectionComponent(sectionConfigs);\n};\n\n/**\n * React hook that registers section components when sections array changes.\n * Automatically handles component registration lifecycle in React components.\n *\n * @param sections - Optional array of section composition entries\n */\nexport const useRegisterSectionComponents = (\n sections?: SectionCompositionEntry[],\n) => {\n const { componentRegistry } = useRenderer();\n\n useMemo(() => {\n if (!sections?.length) return;\n registerSectionComponents(sections, componentRegistry);\n }, [sections, componentRegistry]);\n};\n"],"names":["_jsx"],"mappings":";;;;;;;AA2BA;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,oBAAoB,CAC3B,OAAgC,EAChC,iBAA6C,EAAA;IAE7C,MAAM,eAAe,GAClB,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,mBAET,IAAI,EAAE;;;AAItB,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgB;AACzC,IAAA,IAAI,OAAO,CAAC,EAAE,EAAE;AACd,QAAA,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAU,CAAC,EAAE;YACnD,IAAI,IAAI,EAAE,GAAG;gBAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAY,CAAC;QACtD;IACF;AAEA,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,KAAI;QACzB,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC;QAC9C,MAAM,QAAQ,GAAG;AACf,cAAE,iBAAiB,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,KAAK,GACvD,EAAE,CAAC,OAAO;cAEZ,SAAS;QACb,OAAO;AACL,YAAA,EAAE,CAAC,GAAG;AACN,YAAA;AACE,gBAAA,IAAI,QAAQ,IAAI,EAAE,CAAC;gBACnB,IAAI,EAAE,EAAE,CAAC,QAAwB;gBACjC,WAAW,EAAE,EAAE,CAAC,WAAW;AACX,aAAA;SACnB;IACH,CAAC,CAAC,CACH;AAED,IAAA,OAAO,KAAK;AACd;AAEA;;;;AAIG;MACU,yBAAyB,GAAG,CACvC,QAAmC,EACnC,iBAA6C,KAC3C;IACF,MAAM,cAAc,GAA4B,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,KAAI;;;;;;QAM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QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACnC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { rendererContext } from '../contexts/providers/renderer.provider.js';
|
|
2
|
+
import '../contexts/providers/edit-context.provider.js';
|
|
2
3
|
import '../contexts/providers/active-node.provider.js';
|
|
3
4
|
import 'react/jsx-runtime';
|
|
4
5
|
import '@contentstack/studio-client';
|
|
@@ -6,9 +7,15 @@ import '@contentstack/studio-messenger';
|
|
|
6
7
|
import '@contentstack/studio-react-components/contexts';
|
|
7
8
|
import 'immer';
|
|
8
9
|
import { useContext } from 'react';
|
|
10
|
+
import './use-edit-context-listener.hook.js';
|
|
11
|
+
import '@contentstack/studio-internal';
|
|
12
|
+
import '@contentstack/studio-core';
|
|
13
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
14
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
15
|
+
import 'goober';
|
|
11
16
|
import '../components/Element.js';
|
|
17
|
+
import '../contexts/providers/section-mode.provider.js';
|
|
18
|
+
import '@contentstack/studio-registry';
|
|
12
19
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
20
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
21
|
import '../contexts/providers/use-condition-block.provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-renderer.hook.js","sources":["../../src/hooks/use-renderer.hook.ts"],"sourcesContent":["import { rendererContext } from \"../contexts/providers\";\nimport { useContext } from \"react\";\n\nexport const useRenderer = () => {\n const context = useContext(rendererContext);\n return context;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-renderer.hook.js","sources":["../../src/hooks/use-renderer.hook.ts"],"sourcesContent":["import { rendererContext } from \"../contexts/providers\";\nimport { useContext } from \"react\";\n\nexport const useRenderer = () => {\n const context = useContext(rendererContext);\n return context;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,WAAW,GAAG,MAAK;AAC9B,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC;AAC3C,IAAA,OAAO,OAAO;AAChB;;;;"}
|