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.

fix: Set correct tag when pasting a Block from webflow (#3762)

Oleg Isonenc994c689b974
diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/instances-properties.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/instances-properties.ts
index 7b3e1489ff..27ad7dac32 100644
--- a/apps/builder/app/shared/copy-paste/plugin-webflow/instances-properties.ts
+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/instances-properties.ts
@@ -110,6 +110,9 @@ const toFragment = (
}
case "Block": {
const component = wfNode.data?.text ? "Text" : "Box";
+ if (wfNode.tag !== "div") {
+ addProp("tag", wfNode.tag);
+ }
addInstance(component);
return fragment;
}
diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsx b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsx
index 78dce0d89f..78f0197370 100644
--- a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsx
+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsx
@@ -530,6 +530,38 @@ test("Section", async () => {
`);
});
+test("Figure", async () => {
+ const fragment = await toWebstudioFragment({
+ type: "@webflow/XscpData",
+ payload: {
+ nodes: [
+ {
+ _id: "7c6bc1fd-128d-514b-167b-605a910e435c",
+ type: "Block",
+ tag: "figure",
+ classes: [],
+ children: [],
+ },
+ ],
+ styles: [],
+ assets: [],
+ },
+ });
+
+ equalFragment(fragment, <$.Box tag="figure" />);
+ expect(toCss(fragment)).toMatchInlineSnapshot(`
+ "@media all {
+ figure {
+ display: block;
+ margin-top: 0;
+ margin-right: 0;
+ margin-bottom: 10px;
+ margin-left: 0
+ }
+ }"
+ `);
+});
+
test("BlockContainer", async () => {
const fragment = await toWebstudioFragment({
type: "@webflow/XscpData",