@contentstack/studio-react-editor 1.3.0 → 1.3.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 -6
- package/dist/components/EditableRenderer.js.map +1 -1
- package/dist/components/Element.js +52 -25
- package/dist/components/Element.js.map +1 -1
- package/dist/components/PreviewRenderer.js +4 -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 +33 -0
- package/dist/components/WelcomeState.js.map +1 -0
- package/dist/components/elements/ConditionBlock.js +4 -0
- package/dist/components/elements/ConditionBlock.js.map +1 -1
- package/dist/components/elements/Repeater.js +8 -38
- package/dist/components/elements/Repeater.js.map +1 -1
- package/dist/components/elements/SectionComposition.js +94 -0
- package/dist/components/elements/SectionComposition.js.map +1 -0
- package/dist/components/elements/SectionSlot.js +154 -0
- package/dist/components/elements/SectionSlot.js.map +1 -0
- package/dist/components/elements/Symbol.js +6 -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/renderer.provider.js +1 -0
- package/dist/contexts/providers/renderer.provider.js.map +1 -1
- package/dist/contexts/providers/symbol-ui.provider.js +18 -6
- package/dist/contexts/providers/symbol-ui.provider.js.map +1 -1
- package/dist/hooks/use-active-node-path.hook.js +5 -1
- package/dist/hooks/use-active-node-path.hook.js.map +1 -1
- package/dist/hooks/use-canvas-events.hook.js +5 -2
- package/dist/hooks/use-canvas-events.hook.js.map +1 -1
- package/dist/hooks/use-condition-block-context.js +5 -1
- package/dist/hooks/use-condition-block-context.js.map +1 -1
- package/dist/hooks/use-design-preview.hook.js +5 -1
- package/dist/hooks/use-design-preview.hook.js.map +1 -1
- package/dist/hooks/use-preview-mode.hook.js +5 -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 +5 -1
- package/dist/hooks/use-renderer.hook.js.map +1 -1
- package/dist/hooks/use-repeater.hook.js +5 -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 +8 -1
- package/dist/hooks/use-should-show-design.hook.js.map +1 -1
- package/dist/hooks/use-spec-data-listener.hook.js +335 -10
- 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/package.json +10 -10
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { ELEMENT_TO_NODE, COMPOSABLE_DATA_ATTRIBUTES, NODE_TO_PARENT, NODE_TO_PATH_NODE } from '@contentstack/studio-client';
|
|
3
|
+
import { SectionInstanceSlotsCtx, DataCtxProvider, CurrentNodeContext } from '@contentstack/studio-react-components/contexts';
|
|
4
|
+
import { useCurrentNode, useData } from '@contentstack/studio-react-components/hooks';
|
|
5
|
+
import { css } from 'goober';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { useContext, useCallback, useMemo } from 'react';
|
|
8
|
+
import { styleFactory } from '../styles.js';
|
|
9
|
+
import { SelectedNodeProvider } from '../../contexts/providers/selected-node.provider.js';
|
|
10
|
+
import { PreviewModeContext } from '../../contexts/providers/preview-mode.provider.js';
|
|
11
|
+
import MemoizedElement from '../Element.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Editor variant of section-slot. Two modes:
|
|
15
|
+
*
|
|
16
|
+
* 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section
|
|
17
|
+
* composition is being authored. Render a labelled drop-zone-style
|
|
18
|
+
* placeholder; not droppable into (section slots only accept drops when
|
|
19
|
+
* the section is consumed in a page composition).
|
|
20
|
+
*
|
|
21
|
+
* 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section
|
|
22
|
+
* is being rendered inside a page composition. Look up the page-side
|
|
23
|
+
* slots map by this slot's stable uid (== this node's uid). If filled,
|
|
24
|
+
* transclude the children via <Element> with their paths anchored to
|
|
25
|
+
* the page-side section-composition node, and lift them out of preview
|
|
26
|
+
* mode so they're individually selectable / hover-targetable / draggable
|
|
27
|
+
* like any other page-tree node. If empty, render a labelled drop
|
|
28
|
+
* target that itself acts as a builder node (attributes mapped to the
|
|
29
|
+
* page-side section-composition parent), so hover highlights only the
|
|
30
|
+
* slot zone — not the whole section.
|
|
31
|
+
*/
|
|
32
|
+
function SectionSlot({ studioAttributes, label, _uid, }) {
|
|
33
|
+
// ALL hooks unconditionally at the top — React doesn't allow conditional
|
|
34
|
+
// hook calls and the component returns early for authoring/empty modes.
|
|
35
|
+
const sectionCtx = useContext(SectionInstanceSlotsCtx);
|
|
36
|
+
const { currentNodePath: parentNodePath = [] } = useCurrentNode();
|
|
37
|
+
// Current section-local data (template scoped to section, in-section
|
|
38
|
+
// repeater item if surrounding, etc.). Slot children inherit this as
|
|
39
|
+
// their *default* context — the user's authored bindings on slot
|
|
40
|
+
// children resolve against this by default.
|
|
41
|
+
const sectionLocalData = useData();
|
|
42
|
+
const slotDomRef = useCallback((el) => {
|
|
43
|
+
if (el && sectionCtx?.sectionNode) {
|
|
44
|
+
ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);
|
|
45
|
+
}
|
|
46
|
+
}, [sectionCtx?.sectionNode]);
|
|
47
|
+
// Slot child's data context namespace:
|
|
48
|
+
//
|
|
49
|
+
// dataSources.template = section-local scoped template; if the
|
|
50
|
+
// slot sits inside an in-section
|
|
51
|
+
// Repeater that's currently iterating,
|
|
52
|
+
// this is the active iteration item.
|
|
53
|
+
// Matches what the Data Picker writes
|
|
54
|
+
// when authoring against fields from
|
|
55
|
+
// the slot's surrounding section scope.
|
|
56
|
+
// dataSources.repeater[uid] = in-section Repeater map (full
|
|
57
|
+
// per-uid context). Inherited from
|
|
58
|
+
// sectionLocal via {...sectionDS}.
|
|
59
|
+
// dataSources.static_value = section's persisted static values.
|
|
60
|
+
// dataSources.page = OUTERMOST page-level namespace
|
|
61
|
+
// ({ template, contentstack,
|
|
62
|
+
// contentstack_queries, ... }).
|
|
63
|
+
// Always points to the real page even
|
|
64
|
+
// across recursive slot nesting — see
|
|
65
|
+
// `truePageNamespace` below.
|
|
66
|
+
//
|
|
67
|
+
// Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.
|
|
68
|
+
// retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under
|
|
69
|
+
// `dataSources.page.<src>.X` so page-level bindings authored on slot
|
|
70
|
+
// children still resolve.
|
|
71
|
+
const slotChildData = useMemo(() => {
|
|
72
|
+
const sectionLocal = sectionLocalData || {};
|
|
73
|
+
const pageOuter = sectionCtx?.pageOuterData || {};
|
|
74
|
+
const pageDS = pageOuter?.dataSources || {};
|
|
75
|
+
const sectionDS = sectionLocal?.dataSources || {};
|
|
76
|
+
const repeaterMap = (sectionDS.repeater || {});
|
|
77
|
+
const repeaterUids = Object.keys(repeaterMap);
|
|
78
|
+
const activeRepeaterUid = repeaterUids.length > 0
|
|
79
|
+
? repeaterUids[repeaterUids.length - 1]
|
|
80
|
+
: undefined;
|
|
81
|
+
const activeItem = activeRepeaterUid
|
|
82
|
+
? repeaterMap[activeRepeaterUid]?.context
|
|
83
|
+
: undefined;
|
|
84
|
+
const sectionLocalTemplate = activeItem ?? sectionDS.template;
|
|
85
|
+
// Slot child's default namespace = section-local context AS IS (template,
|
|
86
|
+
// repeater, static_value, …). Page-level sources are nested under `page.*`
|
|
87
|
+
// as the explicit escape. This matches what the Data Picker writes when
|
|
88
|
+
// authoring a slot child (picker shows the slot child's surrounding
|
|
89
|
+
// scope, so its `template.X` / `repeater[uid].context.X` paths resolve
|
|
90
|
+
// natively without rewriting).
|
|
91
|
+
//
|
|
92
|
+
// For nested cases (Section B in Section A's slot), `page` must always
|
|
93
|
+
// point to the OUTERMOST page context — not to Section A's slot-local
|
|
94
|
+
// view. Otherwise each nesting level shadows `page` with the surrounding
|
|
95
|
+
// section's local, and `dataSources.page.template.title` would resolve
|
|
96
|
+
// to a modular_block item instead of the page entry. So: if the outer
|
|
97
|
+
// dataSources already has its own `page` key (because the section we're
|
|
98
|
+
// inside is itself in another slot), inherit THAT — it's the real page.
|
|
99
|
+
const outerPage = pageDS?.page;
|
|
100
|
+
const truePageNamespace = outerPage ?? pageDS;
|
|
101
|
+
return {
|
|
102
|
+
...sectionLocal,
|
|
103
|
+
dataSources: {
|
|
104
|
+
...sectionDS,
|
|
105
|
+
template: sectionLocalTemplate,
|
|
106
|
+
page: truePageNamespace,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}, [sectionLocalData, sectionCtx?.pageOuterData]);
|
|
110
|
+
// ALL hooks above are unconditional. From here, branch based on mode.
|
|
111
|
+
const styles = styleFactory(css);
|
|
112
|
+
const text = label && label.trim().length > 0 ? label : "Drop Here";
|
|
113
|
+
const slotUid = _uid ||
|
|
114
|
+
studioAttributes?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||
|
|
115
|
+
"section-slot";
|
|
116
|
+
// Authoring mode: section is the top-level composition being edited.
|
|
117
|
+
if (!sectionCtx) {
|
|
118
|
+
return (jsx("div", { [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,
|
|
119
|
+
[COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid, ...studioAttributes, className: classNames(styles.slotStyle), children: jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " ", text] }) }));
|
|
120
|
+
}
|
|
121
|
+
// Consumption mode.
|
|
122
|
+
const filled = (sectionCtx.slotsMap[slotUid] || []);
|
|
123
|
+
const dropZoneAttrs = {
|
|
124
|
+
[COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,
|
|
125
|
+
[COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,
|
|
126
|
+
[COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,
|
|
127
|
+
[COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,
|
|
128
|
+
[COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,
|
|
129
|
+
};
|
|
130
|
+
if (filled.length === 0) {
|
|
131
|
+
return (jsx("div", { ref: slotDomRef, ...dropZoneAttrs, ...studioAttributes, className: classNames(styles.slotStyle), children: jsxs("span", { className: styles.slotDropText, children: [jsx(AddIcon, {}), " ", text] }) }));
|
|
132
|
+
}
|
|
133
|
+
// Transclude filled children. Anchor each child's slate path under the
|
|
134
|
+
// page-side section-composition node + this slot's uid, exit preview
|
|
135
|
+
// mode so Element's internalAttributes get applied — making each child
|
|
136
|
+
// selectable, hover-highlightable, and draggable like a normal node.
|
|
137
|
+
return (jsx(DataCtxProvider, { value: slotChildData, children: jsx(PreviewModeContext.Provider, { value: false, children: jsx("div", { ref: slotDomRef, ...dropZoneAttrs, ...studioAttributes, style: { display: "contents" }, children: filled.map((child, idx) => {
|
|
138
|
+
if (!child || typeof child !== "object")
|
|
139
|
+
return null;
|
|
140
|
+
NODE_TO_PARENT.set(child, sectionCtx.sectionNode);
|
|
141
|
+
NODE_TO_PATH_NODE.set(child, [slotUid, idx]);
|
|
142
|
+
const childPath = [...parentNodePath, [slotUid, idx]];
|
|
143
|
+
return (jsx(CurrentNodeContext.Provider, { value: {
|
|
144
|
+
currentNodeUid: child.uid,
|
|
145
|
+
currentNodePath: childPath,
|
|
146
|
+
}, children: jsx(SelectedNodeProvider, { children: jsx(MemoizedElement, { node: child, renderError: () => null }) }) }, child.uid));
|
|
147
|
+
}) }) }) }));
|
|
148
|
+
}
|
|
149
|
+
const AddIcon = () => {
|
|
150
|
+
return (jsxs("svg", { width: "22", height: "22", viewBox: "0 0 22 22", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", fill: "white" }), jsx("rect", { x: "0.5", y: "0.5", width: "21", height: "21", rx: "4.5", stroke: "#475161" }), jsx("path", { d: "M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z", fill: "#475161" })] }));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export { SectionSlot };
|
|
154
|
+
//# sourceMappingURL=SectionSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionSlot.js","sources":["../../../src/components/elements/SectionSlot.tsx"],"sourcesContent":["import {\n COMPOSABLE_DATA_ATTRIBUTES,\n ELEMENT_TO_NODE,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n} from \"@contentstack/studio-client\";\nimport { Node, Path } from \"@contentstack/studio-internal\";\nimport {\n CurrentNodeContext,\n DataCtxProvider,\n SectionInstanceSlotsCtx,\n} from \"@contentstack/studio-react-components/contexts\";\nimport {\n useCurrentNode,\n useData,\n} from \"@contentstack/studio-react-components/hooks\";\nimport { css } from \"goober\";\nimport classNames from \"classnames\";\nimport { useCallback, useContext, useMemo } from \"react\";\nimport { styleFactory } from \"../styles\";\nimport { StudioAttributes } from \"../../types\";\nimport { SelectedNodeProvider } from \"../../contexts/providers/selected-node.provider\";\nimport { PreviewModeContext } from \"../../contexts/providers/preview-mode.provider\";\nimport Element from \"../Element\";\n\ninterface SectionSlotEditorProps extends StudioAttributes {\n label?: string;\n _uid?: string;\n}\n\n/**\n * Editor variant of section-slot. Two modes:\n *\n * 1. **Authoring mode** (no SectionInstanceSlotsCtx in scope) — the section\n * composition is being authored. Render a labelled drop-zone-style\n * placeholder; not droppable into (section slots only accept drops when\n * the section is consumed in a page composition).\n *\n * 2. **Consumption mode** (SectionInstanceSlotsCtx present) — the section\n * is being rendered inside a page composition. Look up the page-side\n * slots map by this slot's stable uid (== this node's uid). If filled,\n * transclude the children via <Element> with their paths anchored to\n * the page-side section-composition node, and lift them out of preview\n * mode so they're individually selectable / hover-targetable / draggable\n * like any other page-tree node. If empty, render a labelled drop\n * target that itself acts as a builder node (attributes mapped to the\n * page-side section-composition parent), so hover highlights only the\n * slot zone — not the whole section.\n */\nexport function SectionSlot({\n studioAttributes,\n label,\n _uid,\n}: SectionSlotEditorProps) {\n // ALL hooks unconditionally at the top — React doesn't allow conditional\n // hook calls and the component returns early for authoring/empty modes.\n const sectionCtx = useContext(SectionInstanceSlotsCtx);\n const { currentNodePath: parentNodePath = [] } = useCurrentNode();\n // Current section-local data (template scoped to section, in-section\n // repeater item if surrounding, etc.). Slot children inherit this as\n // their *default* context — the user's authored bindings on slot\n // children resolve against this by default.\n const sectionLocalData = useData();\n const slotDomRef = useCallback(\n (el: HTMLElement | null) => {\n if (el && sectionCtx?.sectionNode) {\n ELEMENT_TO_NODE.set(el, sectionCtx.sectionNode);\n }\n },\n [sectionCtx?.sectionNode],\n );\n // Slot child's data context namespace:\n //\n // dataSources.template = section-local scoped template; if the\n // slot sits inside an in-section\n // Repeater that's currently iterating,\n // this is the active iteration item.\n // Matches what the Data Picker writes\n // when authoring against fields from\n // the slot's surrounding section scope.\n // dataSources.repeater[uid] = in-section Repeater map (full\n // per-uid context). Inherited from\n // sectionLocal via {...sectionDS}.\n // dataSources.static_value = section's persisted static values.\n // dataSources.page = OUTERMOST page-level namespace\n // ({ template, contentstack,\n // contentstack_queries, ... }).\n // Always points to the real page even\n // across recursive slot nesting — see\n // `truePageNamespace` below.\n //\n // Until Phase 8 lands, picker emits `dataSources.<src>.X` paths only.\n // retrieve-data.ts retries unresolved `dataSources.<src>.X` lookups under\n // `dataSources.page.<src>.X` so page-level bindings authored on slot\n // children still resolve.\n const slotChildData = useMemo(() => {\n const sectionLocal: any = sectionLocalData || {};\n const pageOuter: any = sectionCtx?.pageOuterData || {};\n const pageDS = pageOuter?.dataSources || {};\n const sectionDS = sectionLocal?.dataSources || {};\n\n const repeaterMap = (sectionDS.repeater || {}) as Record<string, any>;\n const repeaterUids = Object.keys(repeaterMap);\n const activeRepeaterUid =\n repeaterUids.length > 0\n ? repeaterUids[repeaterUids.length - 1]\n : undefined;\n const activeItem = activeRepeaterUid\n ? repeaterMap[activeRepeaterUid]?.context\n : undefined;\n const sectionLocalTemplate = activeItem ?? sectionDS.template;\n\n // Slot child's default namespace = section-local context AS IS (template,\n // repeater, static_value, …). Page-level sources are nested under `page.*`\n // as the explicit escape. This matches what the Data Picker writes when\n // authoring a slot child (picker shows the slot child's surrounding\n // scope, so its `template.X` / `repeater[uid].context.X` paths resolve\n // natively without rewriting).\n //\n // For nested cases (Section B in Section A's slot), `page` must always\n // point to the OUTERMOST page context — not to Section A's slot-local\n // view. Otherwise each nesting level shadows `page` with the surrounding\n // section's local, and `dataSources.page.template.title` would resolve\n // to a modular_block item instead of the page entry. So: if the outer\n // dataSources already has its own `page` key (because the section we're\n // inside is itself in another slot), inherit THAT — it's the real page.\n const outerPage = (pageDS as any)?.page;\n const truePageNamespace = outerPage ?? pageDS;\n return {\n ...sectionLocal,\n dataSources: {\n ...sectionDS,\n template: sectionLocalTemplate,\n page: truePageNamespace,\n },\n };\n }, [sectionLocalData, sectionCtx?.pageOuterData]);\n\n // ALL hooks above are unconditional. From here, branch based on mode.\n const styles = styleFactory(css);\n const text = label && label.trim().length > 0 ? label : \"Drop Here\";\n const slotUid =\n _uid ||\n (studioAttributes as any)?.[COMPOSABLE_DATA_ATTRIBUTES.ID] ||\n \"section-slot\";\n\n // Authoring mode: section is the top-level composition being edited.\n if (!sectionCtx) {\n return (\n <div\n {...{\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n }}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span className={styles.slotDropText}>\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Consumption mode.\n const filled = (sectionCtx.slotsMap[slotUid] || []) as Node[];\n const dropZoneAttrs = {\n [COMPOSABLE_DATA_ATTRIBUTES.BUILDER]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.NODE]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.ID]: sectionCtx.sectionInstanceUid,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT]: true,\n [COMPOSABLE_DATA_ATTRIBUTES.SLOT_UID]: slotUid,\n };\n\n if (filled.length === 0) {\n return (\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n className={classNames(styles.slotStyle)}\n >\n <span className={styles.slotDropText}>\n <AddIcon /> {text}\n </span>\n </div>\n );\n }\n\n // Transclude filled children. Anchor each child's slate path under the\n // page-side section-composition node + this slot's uid, exit preview\n // mode so Element's internalAttributes get applied — making each child\n // selectable, hover-highlightable, and draggable like a normal node.\n return (\n <DataCtxProvider value={slotChildData}>\n <PreviewModeContext.Provider value={false}>\n <div\n ref={slotDomRef as any}\n {...dropZoneAttrs}\n {...studioAttributes}\n style={{ display: \"contents\" }}\n >\n {filled.map((child, idx) => {\n if (!child || typeof child !== \"object\") return null;\n NODE_TO_PARENT.set(child, sectionCtx.sectionNode);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx]);\n const childPath: Path = [...parentNodePath, [slotUid, idx]];\n return (\n <CurrentNodeContext.Provider\n key={child.uid}\n value={{\n currentNodeUid: child.uid,\n currentNodePath: childPath,\n }}\n >\n <SelectedNodeProvider>\n <Element node={child} renderError={() => null as any} />\n </SelectedNodeProvider>\n </CurrentNodeContext.Provider>\n );\n })}\n </div>\n </PreviewModeContext.Provider>\n </DataCtxProvider>\n );\n}\n\nconst AddIcon: React.FC = () => {\n return (\n <svg\n width=\"22\"\n height=\"22\"\n viewBox=\"0 0 22 22\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" fill=\"white\" />\n <rect x=\"0.5\" y=\"0.5\" width=\"21\" height=\"21\" rx=\"4.5\" stroke=\"#475161\" />\n <path\n d=\"M11.2808 6.78125C11.2808 6.62592 11.1548 6.5 10.9995 6.5C10.8442 6.5 10.7183 6.62592 10.7183 6.78125V10.7184H6.78125C6.62592 10.7184 6.5 10.8443 6.5 10.9996C6.5 11.155 6.62592 11.2809 6.78125 11.2809H10.7183V15.218C10.7183 15.3733 10.8442 15.4993 10.9995 15.4993C11.1548 15.4993 11.2808 15.3733 11.2808 15.218V11.2809H15.218C15.3733 11.2809 15.4993 11.155 15.4993 10.9996C15.4993 10.8443 15.3733 10.7184 15.218 10.7184H11.2808V6.78125Z\"\n fill=\"#475161\"\n />\n </svg>\n );\n};\n"],"names":["_jsx","_jsxs","Element"],"mappings":";;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,WAAW,CAAC,EAC1B,gBAAgB,EAChB,KAAK,EACL,IAAI,GACmB,EAAA;;;AAGvB,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,uBAAuB,CAAC;IACtD,MAAM,EAAE,eAAe,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,cAAc,EAAE;;;;;AAKjE,IAAA,MAAM,gBAAgB,GAAG,OAAO,EAAE;AAClC,IAAA,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,EAAsB,KAAI;AACzB,QAAA,IAAI,EAAE,IAAI,UAAU,EAAE,WAAW,EAAE;YAC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AAC,EAAA,CACE,EAAA,CACsB,EAAA,CACd;AAEtB;AAEA,MAAM,OAAO,GAAa,MAAK;AAC7B,IAAA,QACED,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAElCD,cAAM,CAAC,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,IAAI,EAAC,OAAO,EAAA,CAAG,EACrEA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,KAAK,EAAC,CAAC,EAAC,KAAK,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,KAAK,EAAC,MAAM,EAAC,SAAS,GAAG,EACzEA,GAAA,CAAA,MAAA,EAAA,EACE,CAAC,EAAC,qbAAqb,EACvb,IAAI,EAAC,SAAS,EAAA,CACd,CAAA,EAAA,CACE;AAEV,CAAC;;;;"}
|
|
@@ -4,15 +4,19 @@ import { useData } from '@contentstack/studio-react-components/hooks';
|
|
|
4
4
|
import { DATA_SOURCES } from '@contentstack/studio-registry';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import '@contentstack/studio-client';
|
|
7
|
+
import '@contentstack/studio-messenger';
|
|
8
|
+
import '@contentstack/studio-internal';
|
|
9
|
+
import '@contentstack/studio-core';
|
|
10
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
11
|
+
import 'goober';
|
|
12
|
+
import { PreviewRenderer } from '../PreviewRenderer.js';
|
|
7
13
|
import '../../contexts/providers/renderer.provider.js';
|
|
8
14
|
import '../../contexts/providers/active-node.provider.js';
|
|
9
|
-
import '@contentstack/studio-messenger';
|
|
10
15
|
import 'immer';
|
|
11
16
|
import '../../contexts/providers/use-design-preview.provider.js';
|
|
12
17
|
import '../../contexts/providers/use-repeater.provider.js';
|
|
13
18
|
import '../../contexts/providers/use-condition-block.provider.js';
|
|
14
19
|
import '../../contexts/providers/preview-mode.provider.js';
|
|
15
|
-
import { PreviewRenderer } from '../PreviewRenderer.js';
|
|
16
20
|
import { useSymbolUIListener } from '../../hooks/use-symbol-ui-listener.hook.js';
|
|
17
21
|
|
|
18
22
|
function EditSymbolRenderer({ ui, studioAttributes, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Symbol.js","sources":["../../../src/components/elements/Symbol.tsx"],"sourcesContent":["/**\n * Symbol component will be used to render when a symbol is in edit mode.\n * @param props:\n * @returns\n */\n\nimport { StudioSpec } from \"@contentstack/studio-client\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport { DATA_SOURCES } from \"@contentstack/studio-registry\";\nimport { useMemo } from \"react\";\nimport { useSymbolUIListener } from \"../../hooks\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\n\n/*\n * SymbolEditRenderer is used by the renderer when symbol is in edit mode\n */\ninterface EditSymbolRendererProps {\n ui: React.ReactElement;\n [key: string]: any;\n}\n\nexport function EditSymbolRenderer({\n ui,\n studioAttributes,\n}: EditSymbolRendererProps) {\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {ui}\n </div>\n );\n}\n\n/*\n * SymbolRenderer is used by the renderer when symbol is in view mode\n */\ninterface ViewOnlySymbolRendererProps {\n ui: null;\n spec: Omit<StudioSpec, \"compositionEntry\">;\n symbolUID: string;\n studioAttributes: Record<string, any>;\n [key: string]: any;\n}\n\nexport function ViewOnlySymbolRenderer({\n symbolUID,\n spec,\n studioAttributes,\n}: ViewOnlySymbolRendererProps) {\n const activeSpec = useSymbolUIListener(spec, symbolUID);\n const data = useData();\n // This was required as two nested symbols were added because of this this component itself was rendered for type symbol and again it was rendering it for same json\n const activeSpecWithoutSymbolWrapper = useMemo(() => {\n const ui = activeSpec.ui;\n const uiWithFragment = {\n ...ui,\n type: \"fragment\",\n slots: ui.slots,\n };\n return {\n ...activeSpec,\n data,\n ui: uiWithFragment,\n };\n }, [activeSpec, data]);\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n <PreviewRenderer spec={activeSpecWithoutSymbolWrapper} />\n </div>\n );\n}\n\ntype SymbolProps = ViewOnlySymbolRendererProps | EditSymbolRendererProps;\n\nfunction WithSymbolPropsData(props: SymbolProps) {\n const data = useData();\n // Can't memoize it because data doesn't change when symbol changes\n const dataWithSymbol = {\n ...data,\n [DATA_SOURCES.SYMBOL_PROPS]: {\n ...(data[DATA_SOURCES.SYMBOL_PROPS] || {}),\n ...(props.symbol_props || {}),\n },\n };\n return (\n <DataCtxProvider value={dataWithSymbol}>{props.children}</DataCtxProvider>\n );\n}\nexport function Symbol(props: SymbolProps) {\n const isEditing = props.symbol_internal_props?.isEditing;\n return (\n <WithSymbolPropsData {...props}>\n {!isEditing ? (\n <ViewOnlySymbolRenderer {...(props as ViewOnlySymbolRendererProps)} />\n ) : (\n <EditSymbolRenderer {...(props as EditSymbolRendererProps)} />\n )}\n </WithSymbolPropsData>\n );\n}\n"],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Symbol.js","sources":["../../../src/components/elements/Symbol.tsx"],"sourcesContent":["/**\n * Symbol component will be used to render when a symbol is in edit mode.\n * @param props:\n * @returns\n */\n\nimport { StudioSpec } from \"@contentstack/studio-client\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport { DATA_SOURCES } from \"@contentstack/studio-registry\";\nimport { useMemo } from \"react\";\nimport { useSymbolUIListener } from \"../../hooks\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\n\n/*\n * SymbolEditRenderer is used by the renderer when symbol is in edit mode\n */\ninterface EditSymbolRendererProps {\n ui: React.ReactElement;\n [key: string]: any;\n}\n\nexport function EditSymbolRenderer({\n ui,\n studioAttributes,\n}: EditSymbolRendererProps) {\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {ui}\n </div>\n );\n}\n\n/*\n * SymbolRenderer is used by the renderer when symbol is in view mode\n */\ninterface ViewOnlySymbolRendererProps {\n ui: null;\n spec: Omit<StudioSpec, \"compositionEntry\">;\n symbolUID: string;\n studioAttributes: Record<string, any>;\n [key: string]: any;\n}\n\nexport function ViewOnlySymbolRenderer({\n symbolUID,\n spec,\n studioAttributes,\n}: ViewOnlySymbolRendererProps) {\n const activeSpec = useSymbolUIListener(spec, symbolUID);\n const data = useData();\n // This was required as two nested symbols were added because of this this component itself was rendered for type symbol and again it was rendering it for same json\n const activeSpecWithoutSymbolWrapper = useMemo(() => {\n const ui = activeSpec.ui;\n const uiWithFragment = {\n ...ui,\n type: \"fragment\",\n slots: ui.slots,\n };\n return {\n ...activeSpec,\n data,\n ui: uiWithFragment,\n };\n }, [activeSpec, data]);\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n <PreviewRenderer spec={activeSpecWithoutSymbolWrapper} />\n </div>\n );\n}\n\ntype SymbolProps = ViewOnlySymbolRendererProps | EditSymbolRendererProps;\n\nfunction WithSymbolPropsData(props: SymbolProps) {\n const data = useData();\n // Can't memoize it because data doesn't change when symbol changes\n const dataWithSymbol = {\n ...data,\n [DATA_SOURCES.SYMBOL_PROPS]: {\n ...(data[DATA_SOURCES.SYMBOL_PROPS] || {}),\n ...(props.symbol_props || {}),\n },\n };\n return (\n <DataCtxProvider value={dataWithSymbol}>{props.children}</DataCtxProvider>\n );\n}\nexport function Symbol(props: SymbolProps) {\n const isEditing = props.symbol_internal_props?.isEditing;\n return (\n <WithSymbolPropsData {...props}>\n {!isEditing ? (\n <ViewOnlySymbolRenderer {...(props as ViewOnlySymbolRendererProps)} />\n ) : (\n <EditSymbolRenderer {...(props as EditSymbolRendererProps)} />\n )}\n </WithSymbolPropsData>\n );\n}\n"],"names":["_js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AI,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;AAC9B,SAAA;KACF;AACD,IAAA,QACEA,GAAA,CAAC,eAAe,EAAA,EAAC,KAAK,EAAE,cAAc,EAAA,QAAA,EAAG,KAAK,CAAC,QAAQ,EAAA,CAAmB;AAE9E;AACM,SAAU,MAAM,CAAC,KAAkB,EAAA;AACvC,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,qBAAqB,EAAE,SAAS;AACxD,IAAA,QACEA,GAAA,CAAC,mBAAmB,EAAA,EAAA,GAAK,KAAK,EAAA,QAAA,EAC3B,CAAC,SAAS,IACTA,IAAC,sBAAsB,EAAA,EAAA,GAAM,KAAqC,EAAA,CAAI,KAEtEA,GAAA,CAAC,kBAAkB,EAAA,EAAA,GAAM,KAAiC,EAAA,CAAI,CAC/D,EAAA,CACmB;AAE1B;;;;"}
|
|
@@ -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,OAAO;AACnB,QAAA,aAAa,EAAE,MAAM;AACrB,QAAA,YAAY,EAAE,MAAM;AACpB,QAAA,UAAU,EAAE,4BAA4B;KACzC,CAAC;IACF,gBAAgB,EAAE,GAAG,CAAC;AACpB,QAAA,YAAY,EAAE,CAAC;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E,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\",\n lineHeight: \"1.4\",\n },\n }),\n activeWelcomeStep: css({\n backgroundColor: \"#F9F8FF\",\n border: \"1px solid #6C5CE7\",\n }),\n});\n"],"names":[],"mappings":"MAEa,YAAY,GAAG,CAAC,GAAqB,MAAM;IACtD,UAAU,E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AAQ,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;;;;"}
|
|
@@ -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;;;;"}
|
|
@@ -4,14 +4,20 @@ 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 '@contentstack/studio-internal';
|
|
8
|
+
import '@contentstack/studio-core';
|
|
9
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
10
|
+
import '@contentstack/studio-react-components/hooks';
|
|
11
|
+
import 'goober';
|
|
12
|
+
import '../../components/Element.js';
|
|
9
13
|
import './renderer.provider.js';
|
|
10
14
|
import './active-node.provider.js';
|
|
11
15
|
import './use-design-preview.provider.js';
|
|
12
16
|
import './use-repeater.provider.js';
|
|
13
17
|
import './use-condition-block.provider.js';
|
|
14
18
|
import './preview-mode.provider.js';
|
|
19
|
+
import { useRenderer } from '../../hooks/use-renderer.hook.js';
|
|
20
|
+
import { registerSymbolComponent } from '../../hooks/use-register-symbol.hook.js';
|
|
15
21
|
|
|
16
22
|
const SymbolUIProvider = ({ symbols, children, }) => {
|
|
17
23
|
const { componentRegistry } = useRenderer();
|
|
@@ -20,11 +26,17 @@ const SymbolUIProvider = ({ symbols, children, }) => {
|
|
|
20
26
|
return acc;
|
|
21
27
|
}, {}));
|
|
22
28
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
acc
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
if (symbols.length > 0) {
|
|
30
|
+
setSymbolUIs(symbols.reduce((acc, symbol) => {
|
|
31
|
+
acc[symbol.uid] = symbol;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {}));
|
|
34
|
+
}
|
|
27
35
|
}, [symbols]);
|
|
36
|
+
// UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,
|
|
37
|
+
// which updates `state.symbols` — that flows down here as the `symbols`
|
|
38
|
+
// prop and is picked up by the useEffect above. Registering another
|
|
39
|
+
// listener here just produced a duplicate-registration warning.
|
|
28
40
|
useEffect(() => {
|
|
29
41
|
const handleApplySymbolOperation = (data) => {
|
|
30
42
|
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,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAI;AAC7B,gBAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AACxB,gBAAA,OAAO,GAAG;AACZ,YAAA,CAAC,EAAE,EAAsB,CAAC,CAC3B;QACH;AACF,IAAA,CAAC,EAAE,CAA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AAE,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;;;;"}
|
|
@@ -6,9 +6,13 @@ import 'react/jsx-runtime';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '@contentstack/studio-registry';
|
|
12
16
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
17
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
18
|
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,10 +1,13 @@
|
|
|
1
|
-
import { isCompositionBeingEdited, addHighlightNodeEventListeners, addUrlChangeListeners, addHighlightSpacingEventListeners, addContextMenuEventListeners, addBreakpointEventListeners, dndEventListener, updateStyleOnStyleNodeChange, hiddenElementNotificationEventEmitter, getNodeScreenshotEvent, isInsideVisualBuilderFrame, compositionSaveEventListener } from '@contentstack/studio-client';
|
|
1
|
+
import { isCompositionBeingEdited, clientRendererModeUtil, addHighlightNodeEventListeners, addUrlChangeListeners, addHighlightSpacingEventListeners, addContextMenuEventListeners, addBreakpointEventListeners, dndEventListener, updateStyleOnStyleNodeChange, hiddenElementNotificationEventEmitter, getNodeScreenshotEvent, isInsideVisualBuilderFrame, compositionSaveEventListener } from '@contentstack/studio-client';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
const useCanvasEvents = (composableUid) => {
|
|
5
5
|
// HOOK TO ADD HIGHLIGHT NODE EVENT LISTENERS
|
|
6
6
|
useEffect(() => {
|
|
7
|
-
|
|
7
|
+
// 🎯 STUDIO CONTEXT CHECK: Only add event listeners when inside Studio, not standalone
|
|
8
|
+
const shouldAddStudioEventListeners = isCompositionBeingEdited(composableUid || "") &&
|
|
9
|
+
clientRendererModeUtil.isInsideStudioFrame();
|
|
10
|
+
if (!shouldAddStudioEventListeners)
|
|
8
11
|
return;
|
|
9
12
|
const highlightNodeEventListener = addHighlightNodeEventListeners();
|
|
10
13
|
const urlChangeEventListener = addUrlChangeListeners();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-canvas-events.hook.js","sources":["../../src/hooks/use-canvas-events.hook.ts"],"sourcesContent":["import {\n addBreakpointEventListeners,\n addContextMenuEventListeners,\n addHighlightNodeEventListeners,\n addHighlightSpacingEventListeners,\n addUrlChangeListeners,\n compositionSaveEventListener,\n dndEventListener,\n getNodeScreenshotEvent,\n hiddenElementNotificationEventEmitter,\n isCompositionBeingEdited,\n isInsideVisualBuilderFrame,\n updateStyleOnStyleNodeChange,\n} from \"@contentstack/studio-client\";\nimport { useEffect } from \"react\";\n\nexport const useCanvasEvents = (composableUid?: string) => {\n // HOOK TO ADD HIGHLIGHT NODE EVENT LISTENERS\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"use-canvas-events.hook.js","sources":["../../src/hooks/use-canvas-events.hook.ts"],"sourcesContent":["import {\n addBreakpointEventListeners,\n addContextMenuEventListeners,\n addHighlightNodeEventListeners,\n addHighlightSpacingEventListeners,\n addUrlChangeListeners,\n compositionSaveEventListener,\n dndEventListener,\n getNodeScreenshotEvent,\n hiddenElementNotificationEventEmitter,\n isCompositionBeingEdited,\n clientRendererModeUtil,\n isInsideVisualBuilderFrame,\n updateStyleOnStyleNodeChange,\n} from \"@contentstack/studio-client\";\nimport { useEffect } from \"react\";\n\nexport const useCanvasEvents = (composableUid?: string) => {\n // HOOK TO ADD HIGHLIGHT NODE EVENT LISTENERS\n useEffect(() => {\n // 🎯 STUDIO CONTEXT CHECK: Only add event listeners when inside Studio, not standalone\n const shouldAddStudioEventListeners =\n isCompositionBeingEdited(composableUid || \"\") &&\n clientRendererModeUtil.isInsideStudioFrame();\n if (!shouldAddStudioEventListeners) return;\n const highlightNodeEventListener = addHighlightNodeEventListeners();\n const urlChangeEventListener = addUrlChangeListeners();\n const highlightSpacingEventListener = addHighlightSpacingEventListeners();\n const contextMenuEventListener = addContextMenuEventListeners();\n const breakpointEventListener = addBreakpointEventListeners();\n const dndListener = dndEventListener();\n const updatedStyleEventListener = updateStyleOnStyleNodeChange();\n const hiddenElementNotificationEventListener =\n hiddenElementNotificationEventEmitter();\n const getNodeScreenshotEventListener = getNodeScreenshotEvent();\n\n return () => {\n highlightNodeEventListener?.removeEventListeners();\n urlChangeEventListener?.removeEventListeners();\n highlightSpacingEventListener?.removeEventListeners();\n contextMenuEventListener?.removeEventListeners();\n breakpointEventListener?.removeEventListeners();\n dndListener?.removeEventListeners();\n updatedStyleEventListener?.removeEventListeners();\n hiddenElementNotificationEventListener?.unregister();\n getNodeScreenshotEventListener?.unregister();\n };\n }, [composableUid]);\n\n useEffect(() => {\n if (!isInsideVisualBuilderFrame()) return;\n const cleanup = compositionSaveEventListener();\n return () => {\n cleanup?.unregister();\n };\n }, []);\n};\n"],"names":[],"mappings":";;;AAiBO,MAAM,eAAe,GAAG,CAAC,aAAsB,KAAI;;IAExD,SAAS,CAAC,MAAK;;AAEb,QAAA,MAAM,6BAA6B,GACjC,wBAAwB,CAAC,aAAa,IAAI,EA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/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '@contentstack/studio-registry';
|
|
12
16
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
17
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
18
|
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;;;;"}
|
|
@@ -6,9 +6,13 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '@contentstack/studio-registry';
|
|
12
16
|
import { DesignPreviewContext } from '../contexts/providers/use-design-preview.provider.js';
|
|
13
17
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
18
|
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;;;;"}
|
|
@@ -6,9 +6,13 @@ import '@contentstack/studio-client';
|
|
|
6
6
|
import '@contentstack/studio-messenger';
|
|
7
7
|
import '@contentstack/studio-react-components/contexts';
|
|
8
8
|
import 'immer';
|
|
9
|
+
import '@contentstack/studio-internal';
|
|
10
|
+
import '@contentstack/studio-core';
|
|
11
|
+
import '@contentstack/studio-react-components/basic-components';
|
|
9
12
|
import '@contentstack/studio-react-components/hooks';
|
|
10
|
-
import '
|
|
13
|
+
import 'goober';
|
|
11
14
|
import '../components/Element.js';
|
|
15
|
+
import '@contentstack/studio-registry';
|
|
12
16
|
import '../contexts/providers/use-design-preview.provider.js';
|
|
13
17
|
import '../contexts/providers/use-repeater.provider.js';
|
|
14
18
|
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;;;;"}
|