Skip to content

Commit a742a11

Browse files
committed
feat: support _label in Webflow data
1 parent dcdf13d commit a742a11

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

apps/builder/app/shared/copy-paste/plugin-webflow/instances-properties.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,20 @@ const toFragment = (
5858
}
5959
};
6060

61+
const customLabel = wfNode._label;
6162
const addInstance = (
6263
component: Instance["component"],
6364
children: Instance["children"] = [],
64-
label?: string
65+
defaultLabel?: string
6566
) => {
6667
fragment.instances.push({
6768
id: instanceId,
6869
type: "instance",
6970
component,
7071
children,
71-
...(label ? { label } : undefined),
72+
...((customLabel || defaultLabel) && {
73+
label: customLabel || defaultLabel,
74+
}),
7275
});
7376
};
7477

apps/builder/app/shared/copy-paste/plugin-webflow/schema.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,19 @@ const WfNodeData = z.object({
3333
.optional(),
3434
});
3535

36-
const WfBaseNode = z.object({
36+
const coreNodeProperties = {
3737
_id: z.string(),
38+
/**
39+
* A layer name.
40+
*
41+
* @note This is never actually set by Webflow, but was added to support a better UX for custom
42+
* tooling that outputs Webflow data.
43+
*/
44+
_label: z.string().optional(),
45+
};
46+
47+
const WfBaseNode = z.object({
48+
...coreNodeProperties,
3849
tag: z.string(),
3950
children: z.array(z.string()),
4051
classes: z.array(z.string()),
@@ -43,7 +54,7 @@ const WfBaseNode = z.object({
4354
});
4455

4556
const WfTextNode = z.object({
46-
_id: z.string(),
57+
...coreNodeProperties,
4758
v: z.string(),
4859
text: z.boolean(),
4960
});

0 commit comments

Comments
 (0)