Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Replace meta.children with meta.template (#1676)

Bogdan Chadkin40e97a108621
diff --git a/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts b/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts
index 3d10dff320..8236e273ae 100644
--- a/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-markdown.test.ts
@@ -6,14 +6,14 @@ const parseInstanceData = (data?: ReturnType<typeof parse>) => {
if (data === undefined) {
return;
}
- const { rootIds, instances, props } = data;
+ const { children, instances, props } = data;
for (const instance of instances) {
Instance.parse(instance);
}
for (const prop of props) {
Prop.parse(prop);
}
- return { rootIds, instances, props };
+ return { children, instances, props };
};
const options = { generateId: () => "123" };
@@ -22,6 +22,12 @@ describe("Plugin Markdown", () => {
test("paragraph", () => {
expect(parseInstanceData(parse("xyz", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -36,9 +42,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -47,6 +50,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("# heading", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -69,9 +78,6 @@ describe("Plugin Markdown", () => {
"value": "h1",
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -80,6 +86,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("###### heading", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -102,9 +114,6 @@ describe("Plugin Markdown", () => {
"value": "h6",
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -113,6 +122,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("__bold__", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -138,9 +153,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -149,6 +161,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("**bold**", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -174,9 +192,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -185,6 +200,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("_italic_", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -210,9 +231,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -221,6 +239,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("*italic*", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -246,9 +270,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -257,6 +278,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse('[link](/uri "Title")', options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -297,9 +324,6 @@ describe("Plugin Markdown", () => {
"value": "Title",
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -308,6 +332,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse('![foo](/url "title")', options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [],
@@ -350,9 +380,6 @@ describe("Plugin Markdown", () => {
"value": "foo",
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -368,6 +395,12 @@ describe("Plugin Markdown", () => {
)
).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -386,9 +419,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -404,6 +434,12 @@ describe("Plugin Markdown", () => {
)
).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -419,9 +455,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -429,6 +462,12 @@ describe("Plugin Markdown", () => {
test("blockquote", () => {
expect(parseInstanceData(parse("> bar", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -454,9 +493,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -464,6 +500,12 @@ describe("Plugin Markdown", () => {
test("inline code", () => {
expect(parseInstanceData(parse("`foo`", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -497,9 +539,6 @@ describe("Plugin Markdown", () => {
"value": true,
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -508,6 +547,12 @@ describe("Plugin Markdown", () => {
expect(parseInstanceData(parse("```js meta\nfoo\n```", options)))
.toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -544,9 +589,6 @@ describe("Plugin Markdown", () => {
"value": "meta",
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -554,6 +596,12 @@ describe("Plugin Markdown", () => {
test("list unordered", () => {
expect(parseInstanceData(parse("- one", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -598,9 +646,6 @@ describe("Plugin Markdown", () => {
"value": false,
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -608,6 +653,12 @@ describe("Plugin Markdown", () => {
test("list ordered", () => {
expect(parseInstanceData(parse("3. one", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [
@@ -659,9 +710,6 @@ describe("Plugin Markdown", () => {
"value": 3,
},
],
- "rootIds": [
- "123",
- ],
}
`);
});
@@ -669,6 +717,12 @@ describe("Plugin Markdown", () => {
test("thematic break | separator", () => {
expect(parseInstanceData(parse("---", options))).toMatchInlineSnapshot(`
{
+ "children": [
+ {
+ "type": "id",
+ "value": "123",
+ },
+ ],
"instances": [
{
"children": [],
@@ -678,9 +732,6 @@ describe("Plugin Markdown", () => {
},
],
"props": [],
- "rootIds": [
- "123",
- ],
}
`);
});
diff --git a/apps/builder/app/shared/copy-paste/plugin-markdown.ts b/apps/builder/app/shared/copy-paste/plugin-markdown.ts
index 8e0b68ceb4..2bd51e44fc 100644
--- a/apps/builder/app/shared/copy-paste/plugin-markdown.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-markdown.ts
@@ -194,11 +194,7 @@ export const parse = (clipboardData: string, options?: Options) => {
const instances: Instance[] = [];
const props: Prop[] = [];
const children = toInstanceData(instances, props, ast, options);
- // assume text is not top level
- const rootIds = children.flatMap((child) =>
- child.type === "id" ? [child.value] : []
- );
- return { props, instances, rootIds };
+ return { props, instances, children };
};
export const onPaste = (clipboardData: string) => {
@@ -213,10 +209,12 @@ export const onPaste = (clipboardData: string) => {
];
const instances = instancesStore.get();
const dragComponents = [];
- for (const instanceId of data.rootIds) {
- const component = instances.get(instanceId)?.component;
- if (component !== undefined) {
- dragComponents.push(component);
+ for (const child of data.children) {
+ if (child.type === "id") {
+ const component = instances.get(child.value)?.component;
+ if (component !== undefined) {
+ dragComponents.push(component);
+ }
}
}
const dropTarget = findClosestDroppableTarget(
@@ -228,7 +226,12 @@ export const onPaste = (clipboardData: string) => {
return;
}
store.createTransaction([instancesStore, propsStore], (instances, props) => {
- insertInstancesMutable(instances, data.instances, data.rootIds, dropTarget);
+ insertInstancesMutable(
+ instances,
+ data.instances,
+ data.children,
+ dropTarget
+ );
for (const prop of data.props) {
props.set(prop.id, prop);
}
diff --git a/apps/builder/app/shared/instance-utils.ts b/apps/builder/app/shared/instance-utils.ts
index e8d44bd966..ef4fd426f9 100644
--- a/apps/builder/app/shared/instance-utils.ts
+++ b/apps/builder/app/shared/instance-utils.ts
@@ -1,5 +1,9 @@
import store from "immerhin";
import { findTreeInstanceIdsExcludingSlotDescendants } from "@webstudio-is/project-build";
+import {
+ generateDataFromEmbedTemplate,
+ getComponentMeta,
+} from "@webstudio-is/react-sdk";
import {
propsStore,
stylesStore,
@@ -14,7 +18,6 @@ import {
import {
type DroppableTarget,
type InstanceSelector,
- createComponentInstance,
findLocalStyleSourcesWithinInstances,
insertInstancesMutable,
reparentInstanceMutable,
@@ -34,16 +37,28 @@ export const insertNewComponentInstance = (
const breakpoints = breakpointsStore.get();
const breakpointValues = Array.from(breakpoints.values());
const baseBreakpoint = breakpointValues.find(isBaseBreakpoint);
+ const componentMeta = getComponentMeta(component);
if (baseBreakpoint === undefined) {
return;
}
const {
+ children,
instances: insertedInstances,
props: insertedProps,
styleSourceSelections: insertedStyleSourceSelections,
styleSources: insertedStyleSources,
styles: insertedStyles,
- } = createComponentInstance(component, baseBreakpoint.id);
+ } = generateDataFromEmbedTemplate(
+ // when template not specified fallback to template with the component
+ componentMeta?.template ?? [
+ {
+ type: "instance",
+ component,
+ children: [],
+ },
+ ],
+ baseBreakpoint.id
+ );
const rootInstanceId = insertedInstances[0].id;
store.createTransaction(
[
@@ -57,7 +72,7 @@ export const insertNewComponentInstance = (
insertInstancesMutable(
instances,
insertedInstances,
- [rootInstanceId],
+ children,
dropTarget
);
insertPropsCopyMutable(props, insertedProps, new Map());
diff --git a/apps/builder/app/shared/tree-utils.test.ts b/apps/builder/app/shared/tree-utils.test.ts
index 49bc0e68a0..a84ea9cf14 100644
--- a/apps/builder/app/shared/tree-utils.test.ts
+++ b/apps/builder/app/shared/tree-utils.test.ts
@@ -238,7 +238,7 @@ test("insert instances tree into target", () => {
createInstance("inserted1", "Box", [{ type: "id", value: "inserted2" }]),
createInstance("inserted2", "Box", []),
],
- ["inserted1"],
+ [{ type: "id", value: "inserted1" }],
{
parentSelector: ["box1", "root"],
position: 1,
@@ -267,7 +267,7 @@ test("insert instances tree into target", () => {
createInstance("inserted3", "Box", [{ type: "id", value: "inserted4" }]),
createInstance("inserted4", "Box", []),
],
- ["inserted3"],
+ [{ type: "id", value: "inserted3" }],
{
parentSelector: ["box1", "root"],
position: "end",
diff --git a/apps/builder/app/shared/tree-utils.ts b/apps/builder/app/shared/tree-utils.ts
index a3f369d0ad..a1caa89e66 100644
--- a/apps/builder/app/shared/tree-utils.ts
+++ b/apps/builder/app/shared/tree-utils.ts
@@ -18,11 +18,7 @@ import {
StyleSourceSelectionsList,
StyleSourcesList,
} from "@webstudio-is/project-build";
-import {
- canAcceptComponent,
- generateDataFromEmbedTemplate,
- getComponentMeta,
-} from "@webstudio-is/react-sdk";
+import { canAcceptComponent } from "@webstudio-is/react-sdk";
import { equalMedia } from "@webstudio-is/css-engine";
// slots can have multiple parents so instance should be addressed
@@ -54,32 +50,6 @@ export const areInstanceSelectorsEqual = (
return left.join(",") === right.join(",");
};
-export const createComponentInstance = (
- component: Instance["component"],
- defaultBreakpointId: Breakpoint["id"]
-) => {
- const componentMeta = getComponentMeta(component);
- const {
- children,
- instances,
- props,
- styleSourceSelections,
- styleSources,
- styles,
- } = generateDataFromEmbedTemplate(
- componentMeta?.children ?? [],
- defaultBreakpointId
- );
- // put first to be interpreted as root
- instances.unshift({
- type: "instance",
- id: nanoid(),
- component,
- children,
- });
- return { instances, props, styleSourceSelections, styleSources, styles };
-};
-
export type DroppableTarget = {
parentSelector: InstanceSelector;
position: number | "end";
@@ -283,7 +253,7 @@ export const findLocalStyleSourcesWithinInstances = (
export const insertInstancesMutable = (
instances: Instances,
insertedInstances: Instance[],
- rootIds: Instance["id"][],
+ children: Instance["children"],
dropTarget: DroppableTarget
) => {
const parentInstance = getInstanceOrCreateFragmentIfNecessary(
@@ -306,16 +276,10 @@ export const insertInstancesMutable = (
}
const { position } = dropTarget;
- const dropTargetChildren: Instance["children"] = rootIds.map(
- (instanceId) => ({
- type: "id",
- value: instanceId,
- })
- );
if (position === "end") {
- parentInstance.children.push(...dropTargetChildren);
+ parentInstance.children.push(...children);
} else {
- parentInstance.children.splice(position, 0, ...dropTargetChildren);
+ parentInstance.children.splice(position, 0, ...children);
}
};
@@ -385,8 +349,13 @@ export const insertInstancesCopyMutable = (
insertInstancesMutable(
instances,
copiedInstancesWithNewIds,
- // consider the first instance as the root
- [copiedInstancesWithNewIds[0].id],
+ // consider the first instance as child
+ [
+ {
+ type: "id",
+ value: copiedInstancesWithNewIds[0].id,
+ },
+ ],
dropTarget
);
diff --git a/packages/react-sdk/src/app/custom-components/form.ws.tsx b/packages/react-sdk/src/app/custom-components/form.ws.tsx
index 96f373506d..ef08c7d01c 100644
--- a/packages/react-sdk/src/app/custom-components/form.ws.tsx
+++ b/packages/react-sdk/src/app/custom-components/form.ws.tsx
@@ -25,55 +25,63 @@ export const meta: WsComponentMeta = {
{ selector: "[data-state=error]", label: "Error" },
{ selector: "[data-state=success]", label: "Success" },
],
- children: [
+ template: [
{
type: "instance",
- component: "Label",
- children: [{ type: "text", value: "Name" }],
- },
- {
- type: "instance",
- component: "Input",
- props: [{ type: "string", name: "name", value: "name" }],
- children: [],
- },
- {
- type: "instance",
- component: "Label",
- children: [{ type: "text", value: "Email" }],
- },
- {
- type: "instance",
- component: "Input",
- props: [{ type: "string", name: "name", value: "email" }],
- children: [],
- },
- {
- type: "instance",
- component: "Button",
- children: [{ type: "text", value: "Submit" }],
- },
- {
- type: "instance",
- component: "SuccessMessage",
+ component: "Form",
children: [
{
type: "instance",
- component: "TextBlock",
+ component: "Label",
+ children: [{ type: "text", value: "Name" }],
+ },
+ {
+ type: "instance",
+ component: "Input",
+ props: [{ type: "string", name: "name", value: "name" }],
+ children: [],
+ },
+ {
+ type: "instance",
+ component: "Label",
+ children: [{ type: "text", value: "Email" }],
+ },
+ {
+ type: "instance",
+ component: "Input",
+ props: [{ type: "string", name: "name", value: "email" }],
+ children: [],
+ },
+ {
+ type: "instance",
+ component: "Button",
+ children: [{ type: "text", value: "Submit" }],
+ },
+ {
+ type: "instance",
+ component: "SuccessMessage",
children: [
- { type: "text", value: "Thank you for getting in touch!" },
+ {
+ type: "instance",
+ component: "TextBlock",
+ children: [
+ { type: "text", value: "Thank you for getting in touch!" },
+ ],
+ },
],
},
- ],
- },
- {
- type: "instance",
- component: "ErrorMessage",
- children: [
{
type: "instance",
- component: "TextBlock",
- children: [{ type: "text", value: "Sorry, something went wrong." }],
+ component: "ErrorMessage",
+ children: [
+ {
+ type: "instance",
+ component: "TextBlock",
+ children: [
+ { type: "text", value: "Sorry, something went wrong." },
+ ],
+ },
+ ],
},
],
},
diff --git a/packages/react-sdk/src/components/blockquote.ws.tsx b/packages/react-sdk/src/components/blockquote.ws.tsx
index 27d5b36e20..1e4d42c9ea 100644
--- a/packages/react-sdk/src/components/blockquote.ws.tsx
+++ b/packages/react-sdk/src/components/blockquote.ws.tsx
@@ -66,7 +66,13 @@ export const meta: WsComponentMeta = {
icon: BlockquoteIcon,
states: defaultStates,
presetStyle,
- children: [{ type: "text", value: "Blockquote you can edit" }],
+ template: [
+ {
+ type: "instance",
+ component: "Blockquote",
+ children: [{ type: "text", value: "Blockquote you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/checkbox-field.ws.tsx b/packages/react-sdk/src/components/checkbox-field.ws.tsx
index 69f7156cd8..456a3dc10e 100644
--- a/packages/react-sdk/src/components/checkbox-field.ws.tsx
+++ b/packages/react-sdk/src/components/checkbox-field.ws.tsx
@@ -23,14 +23,20 @@ export const meta: WsComponentMeta = {
icon: CheckboxCheckedIcon,
states: defaultStates,
presetStyle,
- children: [
- { type: "instance", component: "Checkbox", props: [], children: [] },
+ template: [
{
type: "instance",
- component: "TextBlock",
- label: "Checkbox Label",
- props: [],
- children: [{ type: "text", value: "Checkbox" }],
+ component: "CheckboxField",
+ children: [
+ { type: "instance", component: "Checkbox", children: [] },
+ {
+ type: "instance",
+ component: "TextBlock",
+ label: "Checkbox Label",
+ props: [],
+ children: [{ type: "text", value: "Checkbox" }],
+ },
+ ],
},
],
};
diff --git a/packages/react-sdk/src/components/code-text.ws.tsx b/packages/react-sdk/src/components/code-text.ws.tsx
index 949828fd14..ee0010797f 100644
--- a/packages/react-sdk/src/components/code-text.ws.tsx
+++ b/packages/react-sdk/src/components/code-text.ws.tsx
@@ -42,7 +42,13 @@ export const meta: WsComponentMeta = {
icon: CodeTextIcon,
states: defaultStates,
presetStyle,
- children: [{ type: "text", value: "Code you can edit" }],
+ template: [
+ {
+ type: "instance",
+ component: "CodeText",
+ children: [{ type: "text", value: "Code you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/component-meta.ts b/packages/react-sdk/src/components/component-meta.ts
index 003ea0e99f..885406b79e 100644
--- a/packages/react-sdk/src/components/component-meta.ts
+++ b/packages/react-sdk/src/components/component-meta.ts
@@ -60,7 +60,7 @@ const WsComponentMeta = z.object({
icon: z.string(),
presetStyle: z.optional(z.record(z.string(), EmbedTemplateStyleDecl)),
states: z.optional(z.array(ComponentState)),
- children: z.optional(WsEmbedTemplate),
+ template: z.optional(WsEmbedTemplate),
});
export type WsComponentMeta = Omit<
diff --git a/packages/react-sdk/src/components/form.ws.tsx b/packages/react-sdk/src/components/form.ws.tsx
index 3ebab6fd3f..6b6ce411f7 100644
--- a/packages/react-sdk/src/components/form.ws.tsx
+++ b/packages/react-sdk/src/components/form.ws.tsx
@@ -23,33 +23,39 @@ export const meta: WsComponentMeta = {
icon: FormIcon,
states: defaultStates,
presetStyle,
- children: [
+ template: [
{
type: "instance",
- component: "Label",
- children: [{ type: "text", value: "Name" }],
- },
- {
- type: "instance",
- component: "Input",
- props: [{ type: "string", name: "name", value: "name" }],
- children: [],
- },
- {
- type: "instance",
- component: "Label",
- children: [{ type: "text", value: "Email" }],
- },
- {
- type: "instance",
- component: "Input",
- props: [{ type: "string", name: "name", value: "email" }],
- children: [],
- },
- {
- type: "instance",
- component: "Button",
- children: [{ type: "text", value: "Submit" }],
+ component: "Form",
+ children: [
+ {
+ type: "instance",
+ component: "Label",
+ children: [{ type: "text", value: "Name" }],
+ },
+ {
+ type: "instance",
+ component: "Input",
+ props: [{ type: "string", name: "name", value: "name" }],
+ children: [],
+ },
+ {
+ type: "instance",
+ component: "Label",
+ children: [{ type: "text", value: "Email" }],
+ },
+ {
+ type: "instance",
+ component: "Input",
+ props: [{ type: "string", name: "name", value: "email" }],
+ children: [],
+ },
+ {
+ type: "instance",
+ component: "Button",
+ children: [{ type: "text", value: "Submit" }],
+ },
+ ],
},
],
};
diff --git a/packages/react-sdk/src/components/heading.ws.tsx b/packages/react-sdk/src/components/heading.ws.tsx
index 7d6a0a1353..663b8577be 100644
--- a/packages/react-sdk/src/components/heading.ws.tsx
+++ b/packages/react-sdk/src/components/heading.ws.tsx
@@ -26,9 +26,15 @@ export const meta: WsComponentMeta = {
type: "rich-text",
label: "Heading",
icon: HeadingIcon,
- children: [{ type: "text", value: "Heading you can edit" }],
states: defaultStates,
presetStyle,
+ template: [
+ {
+ type: "instance",
+ component: "Heading",
+ children: [{ type: "text", value: "Heading you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/label.ws.tsx b/packages/react-sdk/src/components/label.ws.tsx
index 98cc713eb9..d0fe2a641e 100644
--- a/packages/react-sdk/src/components/label.ws.tsx
+++ b/packages/react-sdk/src/components/label.ws.tsx
@@ -23,7 +23,13 @@ export const meta: WsComponentMeta = {
icon: TextBlockIcon,
states: defaultStates,
presetStyle,
- children: [{ type: "text", value: "Form Label" }],
+ template: [
+ {
+ type: "instance",
+ component: "Label",
+ children: [{ type: "text", value: "Form Label" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/link.ws.tsx b/packages/react-sdk/src/components/link.ws.tsx
index 2ff8797ea6..ad73714fe8 100644
--- a/packages/react-sdk/src/components/link.ws.tsx
+++ b/packages/react-sdk/src/components/link.ws.tsx
@@ -41,7 +41,13 @@ export const meta: WsComponentMeta = {
label: "Current page",
},
],
- children: [{ type: "text", value: "Link text you can edit" }],
+ template: [
+ {
+ type: "instance",
+ component: "Link",
+ children: [{ type: "text", value: "Link text you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/list-item.ws.tsx b/packages/react-sdk/src/components/list-item.ws.tsx
index 32c822e14b..4b4b20dd27 100644
--- a/packages/react-sdk/src/components/list-item.ws.tsx
+++ b/packages/react-sdk/src/components/list-item.ws.tsx
@@ -19,9 +19,15 @@ export const meta: WsComponentMeta = {
acceptedParents: ["List"],
label: "List Item",
icon: ListItemIcon,
- children: [{ type: "text", value: "List Item you can edit" }],
states: defaultStates,
presetStyle,
+ template: [
+ {
+ type: "instance",
+ component: "ListItem",
+ children: [{ type: "text", value: "List Item you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/list.ws.tsx b/packages/react-sdk/src/components/list.ws.tsx
index 79b7ae83f6..c833decc7c 100644
--- a/packages/react-sdk/src/components/list.ws.tsx
+++ b/packages/react-sdk/src/components/list.ws.tsx
@@ -49,7 +49,6 @@ export const meta: WsComponentMeta = {
icon: ListIcon,
states: defaultStates,
presetStyle,
- children: [],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/paragraph.ws.tsx b/packages/react-sdk/src/components/paragraph.ws.tsx
index 8be2584b2e..9a4d8e08bd 100644
--- a/packages/react-sdk/src/components/paragraph.ws.tsx
+++ b/packages/react-sdk/src/components/paragraph.ws.tsx
@@ -18,9 +18,15 @@ export const meta: WsComponentMeta = {
type: "rich-text",
label: "Paragraph",
icon: TextAlignLeftIcon,
- children: [{ type: "text", value: "Pragraph you can edit" }],
states: defaultStates,
presetStyle,
+ template: [
+ {
+ type: "instance",
+ component: "Paragraph",
+ children: [{ type: "text", value: "Pragraph you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/radio-button-field.ws.tsx b/packages/react-sdk/src/components/radio-button-field.ws.tsx
index ba54a41f26..b2d88d8791 100644
--- a/packages/react-sdk/src/components/radio-button-field.ws.tsx
+++ b/packages/react-sdk/src/components/radio-button-field.ws.tsx
@@ -23,14 +23,20 @@ export const meta: WsComponentMeta = {
icon: RadioCheckedIcon,
states: defaultStates,
presetStyle,
- children: [
- { type: "instance", component: "RadioButton", props: [], children: [] },
+ template: [
{
type: "instance",
- component: "TextBlock",
- label: "Radio Label",
- props: [],
- children: [{ type: "text", value: "Radio" }],
+ component: "RadioButtonField",
+ children: [
+ { type: "instance", component: "RadioButton", props: [], children: [] },
+ {
+ type: "instance",
+ component: "TextBlock",
+ label: "Radio Label",
+ props: [],
+ children: [{ type: "text", value: "Radio" }],
+ },
+ ],
},
],
};
diff --git a/packages/react-sdk/src/components/rich-text-link.ws.tsx b/packages/react-sdk/src/components/rich-text-link.ws.tsx
index 5a1378ce0b..9cf8c64d0c 100644
--- a/packages/react-sdk/src/components/rich-text-link.ws.tsx
+++ b/packages/react-sdk/src/components/rich-text-link.ws.tsx
@@ -7,7 +7,7 @@ const { category, ...linkMetaRest } = linkMeta;
export const meta: WsComponentMeta = {
...linkMetaRest,
type: "rich-text-child",
- children: [],
+ template: [],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/separator.ws.tsx b/packages/react-sdk/src/components/separator.ws.tsx
index c49978d591..8347d4ac7e 100644
--- a/packages/react-sdk/src/components/separator.ws.tsx
+++ b/packages/react-sdk/src/components/separator.ws.tsx
@@ -47,7 +47,6 @@ export const meta: WsComponentMeta = {
icon: DashIcon,
states: defaultStates,
presetStyle,
- children: [],
};
export const propsMeta: WsComponentPropsMeta = {
diff --git a/packages/react-sdk/src/components/text-block.ws.tsx b/packages/react-sdk/src/components/text-block.ws.tsx
index 3f5b0811bf..fcf85bdf11 100644
--- a/packages/react-sdk/src/components/text-block.ws.tsx
+++ b/packages/react-sdk/src/components/text-block.ws.tsx
@@ -26,7 +26,13 @@ export const meta: WsComponentMeta = {
icon: TextBlockIcon,
states: defaultStates,
presetStyle,
- children: [{ type: "text", value: "Block of text you can edit" }],
+ template: [
+ {
+ type: "instance",
+ component: "TextBlock",
+ children: [{ type: "text", value: "Block of text you can edit" }],
+ },
+ ],
};
export const propsMeta: WsComponentPropsMeta = {