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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
experimental: Paste from webflow 8 (#3572)
Oleg Isonenf8635a6691d8
diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.tsindex a3948cc9b6..1f62670cd2 100644--- a/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/__generated__/style-presets.ts@@ -1,6 +1,6 @@/* eslint-disable *//* This file was generated by css-to-ws.ts */-export default {+export const styles = {html: [{property: "webkitTextSizeAdjust",@@ -793,7 +793,14 @@ export default {],pre: [{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "auto",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "auto",@@ -889,7 +896,7 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantCaps",value: {type: "keyword",value: "initial",@@ -963,7 +970,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "visible",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "visible",@@ -1127,7 +1141,7 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantCaps",value: {type: "keyword",value: "initial",@@ -1365,7 +1379,7 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantCaps",value: {type: "keyword",value: "initial",@@ -1455,7 +1469,7 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantCaps",value: {type: "keyword",value: "initial",@@ -1552,7 +1566,7 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantCaps",value: {type: "keyword",value: "initial",@@ -1626,7 +1640,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "auto",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "auto",@@ -2314,18 +2335,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -2659,10 +2736,52 @@ export default {},},{- property: "fontVariant",+ property: "fontVariantLigatures",value: {type: "keyword",- value: "inherit",+ value: "normal",+ },+ },+ {+ property: "fontVariantCaps",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "fontVariantAlternates",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "fontVariantNumeric",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "fontVariantEastAsian",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "fontVariantPosition",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "fontVariantEmoji",+ value: {+ type: "invalid",+ value: "normal",},},{@@ -2888,12 +3007,42 @@ export default {},},{- property: "transition",+ property: "transitionProperty",value: {- type: "invalid",+ type: "keyword",value: "none",},},+ {+ property: "transitionDuration",+ value: {+ type: "unit",+ unit: "s",+ value: 0,+ },+ },+ {+ property: "transitionTimingFunction",+ value: {+ type: "keyword",+ value: "ease",+ },+ },+ {+ property: "transitionDelay",+ value: {+ type: "unit",+ unit: "s",+ value: 0,+ },+ },+ {+ property: "transitionBehavior",+ value: {+ type: "invalid",+ value: "normal",+ },+ },{property: "whiteSpace",value: {@@ -2912,7 +3061,7 @@ export default {property: "boxShadow",value: {type: "unparsed",- value: "0 0 0 1px rgba(0,0,0,0.1),0 1px 3px rgba(0,0,0,0.1)",+ value: "0 0 0 1px rgba(0,0,0,.1),0 1px 3px rgba(0,0,0,.1)",},},{@@ -3142,7 +3291,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "visible",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "visible",@@ -3548,10 +3704,24 @@ export default {},},{- property: "listStyle",+ property: "listStylePosition",value: {- type: "invalid",- value: "",+ type: "keyword",+ value: "initial",+ },+ },+ {+ property: "listStyleImage",+ value: {+ type: "keyword",+ value: "none",+ },+ },+ {+ property: "listStyleType",+ value: {+ type: "keyword",+ value: "initial",},},],@@ -3573,18 +3743,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -4628,51 +4854,107 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":after",},{- property: "display",+ property: "gridColumnStart",value: {- type: "keyword",- value: "table",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "display",+ property: "gridColumnStart",value: {- type: "keyword",- value: "table",+ type: "unit",+ unit: "number",+ value: 1,},state: ":after",},{- property: "clear",+ property: "gridRowEnd",value: {- type: "keyword",- value: "both",+ type: "unit",+ unit: "number",+ value: 2,},- state: ":after",+ state: ":before",},- ],- "w-radio-input": [{- property: "float",+ property: "gridRowEnd",value: {- type: "keyword",+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "display",+ value: {+ type: "keyword",+ value: "table",+ },+ state: ":before",+ },+ {+ property: "display",+ value: {+ type: "keyword",+ value: "table",+ },+ state: ":after",+ },+ {+ property: "clear",+ value: {+ type: "keyword",+ value: "both",+ },+ state: ":after",+ },+ ],+ "w-radio-input": [+ {+ property: "float",+ value: {+ type: "keyword",value: "left",},},@@ -4774,7 +5056,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -5730,18 +6019,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -5795,18 +6140,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -6482,7 +6883,14 @@ export default {],"w-widget-twitter": [{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -7186,7 +7594,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -7380,7 +7795,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -7627,7 +8049,7 @@ export default {property: "boxShadow",value: {type: "unparsed",- value: "0 0 3px rgba(51,51,51,0.4)",+ value: "0 0 3px rgba(51,51,51,.4)",},},],@@ -7719,39 +8141,38 @@ export default {},},{- property: "transition",- value: {- type: "layers",- value: [- {- type: "tuple",- value: [- {- type: "keyword",- value: "background-color",- },- {- type: "unit",- value: 0.1,- unit: "s",- },- ],- },- {- type: "tuple",- value: [- {- type: "keyword",- value: "color",- },- {- type: "unit",- value: 0.1,- unit: "s",- },- ],- },- ],+ property: "transitionProperty",+ value: {+ type: "unparsed",+ value: "background-color,color",+ },+ },+ {+ property: "transitionDuration",+ value: {+ type: "unparsed",+ value: ".1s,.1s",+ },+ },+ {+ property: "transitionTimingFunction",+ value: {+ type: "unparsed",+ value: "ease,ease",+ },+ },+ {+ property: "transitionDelay",+ value: {+ type: "unparsed",+ value: ".1s,.1s",+ },+ },+ {+ property: "transitionBehavior",+ value: {+ type: "invalid",+ value: "normal,normal",},},{@@ -7943,7 +8364,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -8122,7 +8550,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -8350,7 +8785,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -9175,25 +9617,39 @@ export default {},},{- property: "listStyle",+ property: "listStylePosition",value: {- type: "invalid",- value: "",+ type: "keyword",+ value: "initial",},},{- property: "position",+ property: "listStyleImage",value: {type: "keyword",- value: "fixed",+ value: "initial",},},{- property: "top",+ property: "listStyleType",value: {- type: "unit",- unit: "number",- value: 0,+ type: "keyword",+ value: "disc",+ },+ },+ {+ property: "position",+ value: {+ type: "keyword",+ value: "fixed",+ },+ },+ {+ property: "top",+ value: {+ type: "unit",+ unit: "number",+ value: 0,},},{@@ -9243,7 +9699,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "auto",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "auto",@@ -9267,7 +9730,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "auto",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "auto",@@ -9283,7 +9753,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -9595,7 +10072,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -9698,25 +10182,40 @@ export default {},},{- property: "transition",+ property: "transitionProperty",+ value: {+ type: "keyword",+ value: "all",+ },+ },+ {+ property: "transitionDuration",+ value: {+ type: "unit",+ unit: "s",+ value: 0.3,+ },+ },+ {+ property: "transitionTimingFunction",+ value: {+ type: "keyword",+ value: "ease",+ },+ },+ {+ property: "transitionDelay",+ value: {+ type: "unit",+ unit: "s",+ value: 0.3,+ },+ },+ {+ property: "transitionBehavior",value: {- type: "layers",- value: [- {- type: "tuple",- value: [- {- type: "keyword",- value: "all",- },- {- type: "unit",- value: 0.3,- unit: "s",- },- ],- },- ],+ type: "invalid",+ value: "normal",},},{@@ -10076,7 +10575,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -10273,10 +10779,82 @@ export default {},},{- property: "animation",+ property: "animationDuration",+ value: {+ type: "unit",+ unit: "s",+ value: 0.8,+ },+ },+ {+ property: "animationTimingFunction",+ value: {+ type: "keyword",+ value: "linear",+ },+ },+ {+ property: "animationDelay",+ value: {+ type: "unit",+ unit: "s",+ value: 0,+ },+ },+ {+ property: "animationIterationCount",+ value: {+ type: "keyword",+ value: "infinite",+ },+ },+ {+ property: "animationDirection",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ {+ property: "animationFillMode",+ value: {+ type: "keyword",+ value: "none",+ },+ },+ {+ property: "animationPlayState",+ value: {+ type: "keyword",+ value: "running",+ },+ },+ {+ property: "animationName",value: {type: "unparsed",- value: "0.8s linear infinite spin",+ value: "spin",+ },+ },+ {+ property: "animationTimeline",+ value: {+ type: "invalid",+ value: "",+ },+ },+ {+ property: "animationRangeStart",+ value: {+ type: "invalid",+ value: "normal",+ },+ },+ {+ property: "animationRangeEnd",+ value: {+ type: "invalid",+ value: "normal",},},{@@ -10505,7 +11083,14 @@ export default {],"w-lightbox-noscroll": [{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -10549,18 +11134,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -10816,18 +11457,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -11087,7 +11784,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -11299,18 +12003,74 @@ export default {state: ":after",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,},state: ":before",},{- property: "gridArea",+ property: "gridRowStart",value: {- type: "unparsed",- value: "1/1/2/2",+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,},state: ":after",},@@ -11499,7 +12259,14 @@ export default {},},{- property: "overflow",+ property: "overflowX",+ value: {+ type: "keyword",+ value: "hidden",+ },+ },+ {+ property: "overflowY",value: {type: "keyword",value: "hidden",@@ -11621,4 +12388,651 @@ export default {},},],+ "w-checkbox": [+ {+ property: "marginBottom",+ value: {+ type: "unit",+ unit: "px",+ value: 5,+ },+ },+ {+ property: "paddingLeft",+ value: {+ type: "unit",+ unit: "px",+ value: 20,+ },+ },+ {+ property: "display",+ value: {+ type: "keyword",+ value: "block",+ },+ },+ {+ property: "content",+ value: {+ type: "unparsed",+ value: '" "',+ },+ state: ":before",+ },+ {+ property: "gridRowStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":before",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":before",+ },+ {+ property: "display",+ value: {+ type: "keyword",+ value: "table",+ },+ state: ":before",+ },+ {+ property: "content",+ value: {+ type: "unparsed",+ value: '" "',+ },+ state: ":after",+ },+ {+ property: "clear",+ value: {+ type: "keyword",+ value: "both",+ },+ state: ":after",+ },+ {+ property: "gridRowStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridColumnStart",+ value: {+ type: "unit",+ unit: "number",+ value: 1,+ },+ state: ":after",+ },+ {+ property: "gridRowEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "gridColumnEnd",+ value: {+ type: "unit",+ unit: "number",+ value: 2,+ },+ state: ":after",+ },+ {+ property: "display",+ value: {+ type: "keyword",+ value: "table",+ },+ state: ":after",+ },+ ],+ "w-checkbox-input": [+ {+ property: "float",+ value: {+ type: "keyword",+ value: "left",+ },+ },+ {+ property: "marginTop",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "marginRight",+ value: {+ type: "unit",+ unit: "number",+ value: 0,+ },+ },+ {+ property: "marginBottom",+ value: {+ type: "unit",+ unit: "number",+ value: 0,+ },+ },+ {+ property: "marginLeft",+ value: {+ type: "unit",+ unit: "px",+ value: -20,+ },+ },+ {+ property: "lineHeight",+ value: {+ type: "keyword",+ value: "normal",+ },+ },+ ],+ "w-checkbox-input--inputType-custom": [+ {+ property: "borderTopWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 1,+ },+ },+ {+ property: "borderRightWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 1,+ },+ },+ {+ property: "borderBottomWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 1,+ },+ },+ {+ property: "borderLeftWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 1,+ },+ },+ {+ property: "borderTopStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderRightStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderBottomStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderLeftStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderTopLeftRadius",+ value: {+ type: "unit",+ unit: "px",+ value: 2,+ },+ },+ {+ property: "borderTopRightRadius",+ value: {+ type: "unit",+ unit: "px",+ value: 2,+ },+ },+ {+ property: "borderBottomRightRadius",+ value: {+ type: "unit",+ unit: "px",+ value: 2,+ },+ },+ {+ property: "width",+ value: {+ type: "unit",+ unit: "px",+ value: 12,+ },+ },+ {+ property: "height",+ value: {+ type: "unit",+ unit: "px",+ value: 12,+ },+ },+ {+ property: "backgroundColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "backgroundImage",+ value: {+ type: "unparsed",+ value:+ "url(https://d3e54v103j8qbb.cloudfront.net/static/custom-checkbox-checkmark.589d534424.svg)",+ },+ },+ {+ property: "backgroundPosition",+ value: {+ type: "unit",+ unit: "%",+ value: 50,+ },+ },+ {+ property: "backgroundRepeat",+ value: {+ type: "keyword",+ value: "no-repeat",+ },+ },+ {+ property: "backgroundSize",+ value: {+ type: "keyword",+ value: "cover",+ },+ },+ {+ property: "borderTopColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderRightColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderBottomColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderLeftColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "boxShadow",+ value: {+ type: "unparsed",+ value: "0 0 3px 1px #3898ec",+ },+ },+ ],+ "w--redirected-checked": [+ {+ property: "backgroundColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "backgroundImage",+ value: {+ type: "unparsed",+ value:+ "url(https://d3e54v103j8qbb.cloudfront.net/static/custom-checkbox-checkmark.589d534424.svg)",+ },+ },+ {+ property: "backgroundPosition",+ value: {+ type: "unit",+ unit: "%",+ value: 50,+ },+ },+ {+ property: "backgroundRepeat",+ value: {+ type: "keyword",+ value: "no-repeat",+ },+ },+ {+ property: "backgroundSize",+ value: {+ type: "keyword",+ value: "cover",+ },+ },+ {+ property: "borderTopWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderRightWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderBottomWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderLeftWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderTopColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderRightColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderBottomColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderLeftColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ ],+ "w--redirected-focus": [+ {+ property: "boxShadow",+ value: {+ type: "unparsed",+ value: "0 0 3px 1px #3898ec",+ },+ },+ ],+ "w-form-formradioinput--inputType-custom": [+ {+ property: "borderTopStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderRightStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderBottomStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderLeftStyle",+ value: {+ type: "keyword",+ value: "solid",+ },+ },+ {+ property: "borderTopLeftRadius",+ value: {+ type: "unit",+ unit: "%",+ value: 50,+ },+ },+ {+ property: "borderTopRightRadius",+ value: {+ type: "unit",+ unit: "%",+ value: 50,+ },+ },+ {+ property: "borderBottomRightRadius",+ value: {+ type: "unit",+ unit: "%",+ value: 50,+ },+ },+ {+ property: "width",+ value: {+ type: "unit",+ unit: "px",+ value: 12,+ },+ },+ {+ property: "height",+ value: {+ type: "unit",+ unit: "px",+ value: 12,+ },+ },+ {+ property: "boxShadow",+ value: {+ type: "unparsed",+ value: "0 0 3px 1px #3898ec",+ },+ },+ {+ property: "borderTopWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderRightWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderBottomWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderLeftWidth",+ value: {+ type: "unit",+ unit: "px",+ value: 4,+ },+ },+ {+ property: "borderTopColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderRightColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderBottomColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ {+ property: "borderLeftColor",+ value: {+ type: "rgb",+ alpha: 1,+ r: 56,+ g: 152,+ b: 236,+ },+ },+ ],};+export type Styles = typeof styles;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.tsindex 5600f93a39..38aa2246b1 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@@ -2,140 +2,188 @@ import { nanoid } from "nanoid";import type { Instance, Prop, WebstudioFragment } from "@webstudio-is/sdk";import type { WfElementNode, WfNode } from "./schema";-const mapComponentAndProperties = (+const toFragment = (wfNode: WfElementNode,- instanceId: Instance["id"]-) => {- const props: Array<Prop> = [];+ instanceId: Instance["id"],+ wfNodes: Map<WfNode["_id"], WfNode>+): WebstudioFragment | undefined => {+ const fragment: WebstudioFragment = {+ children: [],+ instances: [],+ props: [],+ dataSources: [],+ styleSourceSelections: [],+ styleSources: [],+ styles: [],+ assets: [],+ breakpoints: [],+ resources: [],+ };const component = wfNode.type;+ const addProp = (+ name: Prop["name"],+ value: Prop["value"],+ type: Prop["type"] = "string"+ ) => {+ const prop = { id: nanoid(), instanceId };++ if (type === "string" && typeof value === "string") {+ fragment.props.push({+ ...prop,+ type,+ name,+ value,+ });+ return;+ }+ if (type === "number" && typeof value === "number") {+ fragment.props.push({+ ...prop,+ type,+ name,+ value,+ });+ return;+ }++ if (type === "boolean" && typeof value === "boolean") {+ fragment.props.push({+ ...prop,+ type,+ name,+ value,+ });+ return;+ }+ };++ const addInstance = (+ component: Instance["component"],+ children: Instance["children"] = [],+ label?: string+ ) => {+ fragment.instances.push({+ id: instanceId,+ type: "instance",+ component,+ children,+ ...(label ? { label } : undefined),+ });+ };++ if (wfNode.data?.attr?.id) {+ addProp("id", wfNode.data.attr.id);+ }+switch (component) {- case "Heading":- case "List":+ case "Heading": {+ addProp("tag", wfNode.tag);+ addInstance(component);+ return fragment;+ }+ case "List": {+ if (wfNode.tag === "ol") {+ addProp("ordered", true, "boolean");+ }+ addInstance(component);+ return fragment;+ }case "ListItem":case "Paragraph":case "Superscript":case "Subscript":case "Blockquote": {- return { component, props };+ addInstance(component);+ return fragment;}case "Block": {const component = wfNode.data?.text ? "Text" : "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Link": {const data = wfNode.data;- if (data.link.url) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "href",- value: data.link.url,- });- }- if (data.link.target) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "target",- value: data.link.target,- });- }- return { component, props };+ addProp("href", data.link.url);+ addProp("target", data.link.target);+ addInstance(component);+ return fragment;}case "Section": {const component = "Box";- return { component, props };+ addProp("tag", wfNode.tag);+ addInstance(component);+ return fragment;}case "RichText": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Strong": {const component = "Bold";- return { component, props };+ addInstance(component);+ return fragment;}case "Emphasized": {const component = "Italic";- return { component, props };+ addInstance(component);+ return fragment;}case "BlockContainer": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Layout": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Cell": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "VFlex": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "HFlex": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Grid": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Row": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "Column": {const component = "Box";- return { component, props };+ addInstance(component);+ return fragment;}case "CodeBlock": {const component = "CodeText";const data = wfNode.data;-- if (data.language) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "lang",- value: data.language,- });- }-- if (data.code) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "code",- value: data.code,- });- }- return { component, props };+ addProp("lang", data.language);+ addProp("code", data.code);+ addInstance(component);+ return fragment;}case "HtmlEmbed": {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "code",- value: wfNode.v,- });- props.push({- type: "boolean",- id: nanoid(),- instanceId,- name: "clientOnly",- value: true,- });-- return { component, props };+ addProp("code", wfNode.v);+ addProp("clientOnly", true, "boolean");+ addInstance(component);+ return fragment;}case "Image": {const data = wfNode.data;@@ -147,75 +195,126 @@ const mapComponentAndProperties = (// This is how they tell it to use alt="", which is our default anywaysdata.attr.alt !== "__wf_reserved_decorative") {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "alt",- value: data.attr.alt,- });+ addProp("alt", data.attr.alt);}if (data.attr.loading === "eager" || data.attr.loading === "lazy") {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "loading",- value: data.attr.loading,- });+ addProp("loading", data.attr.loading);}if (data.attr.width && data.attr.width !== "auto") {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "width",- value: data.attr.width,- });+ addProp("width", data.attr.width);}if (data.attr.height && data.attr.height !== "auto") {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "height",- value: data.attr.height,- });+ addProp("height", data.attr.height);}if (data.attr.src) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "src",- value: data.attr.src,- });+ addProp("src", data.attr.src);}- return { component, props };+ addInstance(component);+ return fragment;+ }+ case "FormWrapper": {+ const component = "Box";+ addInstance(component);+ return fragment;+ }+ case "FormForm": {+ const component = "Box";+ addInstance(component);+ return fragment;+ }+ case "FormErrorMessage":+ case "FormSuccessMessage": {+ return;+ }+ case "FormButton": {+ const component = "Button";+ const data = wfNode.data;+ addInstance(component, [+ {+ type: "text" as const,+ value: data.attr.value,+ },+ ]);+ return fragment;+ }+ case "FormTextInput": {+ const data = wfNode.data;+ const component = "Input";+ addProp("name", data.attr.name);+ addProp("maxLength", data.attr.maxlength, "number");+ addProp("placeholder", data.attr.placeholder);+ addProp("disabled", data.attr.disabled, "boolean");+ addProp("type", data.attr.type);+ addProp("required", data.attr.required, "boolean");+ addProp("autoFocus", data.attr.autofocus, "boolean");+ addInstance(component);+ return fragment;+ }+ case "FormTextarea": {+ const data = wfNode.data;+ const component = "Textarea";+ addProp("name", data.attr.name);+ addProp("maxLength", data.attr.maxlength, "number");+ addProp("placeholder", data.attr.placeholder);+ addProp("required", data.attr.required, "boolean");+ addProp("autoFocus", data.attr.autofocus, "boolean");+ addInstance(component);+ return fragment;+ }+ case "FormBlockLabel": {+ const data = wfNode.data;+ const component = "Label";+ addProp("htmlFor", data.attr.for);+ addInstance(component);+ return fragment;+ }+ case "FormCheckboxWrapper": {+ const component = "Label";+ addInstance(component, [], "Checkbox Field");+ return fragment;+ }+ case "FormCheckboxInput": {+ const component = "Checkbox";+ const data = wfNode.data;+ addProp("name", data.attr.name);+ addProp("required", data.attr.required, "boolean");+ addProp("defaultChecked", data.attr.checked, "boolean");+ addInstance(component);+ return fragment;+ }+ case "FormInlineLabel": {+ const component = "Text";+ addProp("tag", "span");+ addInstance(component, [], "Label");+ return fragment;+ }+ case "FormRadioWrapper": {+ const component = "Label";+ addInstance(component, [], "Radio Field");+ return fragment;+ }+ case "FormRadioInput": {+ const component = "RadioButton";+ const data = wfNode.data;+ addProp("name", data.attr.name);+ addProp("required", data.attr.required, "boolean");+ addProp("value", data.attr.value);+ addInstance(component);+ return fragment;}}(component) satisfies never;};-const addAttributes = (+const addCustomAttributes = (wfNode: WfElementNode,instanceId: Instance["id"],props: Array<Prop>) => {- if ("tag" in wfNode) {- props.push({- type: "string",- id: nanoid(),- instanceId,- name: "tag",- value: wfNode.tag,- });- }-if (wfNode.data?.xattr) {for (const attribute of wfNode.data.xattr) {props.push({@@ -231,15 +330,30 @@ const addAttributes = (export const addInstanceAndProperties = (wfNode: WfNode,- added: Map<WfNode["_id"], Instance["id"]>,+ doneNodes: Map<WfNode["_id"], Instance["id"] | false>,wfNodes: Map<WfNode["_id"], WfNode>,fragment: WebstudioFragment) => {- if (added.get(wfNode._id) || "text" in wfNode || "type" in wfNode === false) {+ if (+ doneNodes.has(wfNode._id) ||+ "text" in wfNode ||+ "type" in wfNode === false+ ) {return;}- const children: Instance["children"] = [];const instanceId = nanoid();+ const nextFragment = toFragment(wfNode, instanceId, wfNodes);++ if (nextFragment === undefined) {+ // Skip this node and its children.+ doneNodes.set(wfNode._id, false);+ for (const childId of wfNode.children) {+ doneNodes.set(childId, false);+ }+ return;+ }++ const children: Instance["children"] = [];for (const wfChildId of wfNode.children) {const wfChildNode = wfNodes.get(wfChildId);if (wfChildNode === undefined) {@@ -250,13 +364,13 @@ export const addInstanceAndProperties = (type: "text",value: wfChildNode.v,});- added.set(wfChildId, instanceId);+ doneNodes.set(wfChildId, instanceId);continue;}const childInstanceId = addInstanceAndProperties(wfChildNode,- added,+ doneNodes,wfNodes,fragment);@@ -268,17 +382,18 @@ export const addInstanceAndProperties = (}}- const { component, props } = mapComponentAndProperties(wfNode, instanceId);+ fragment.instances.push(...nextFragment.instances);+ fragment.props.push(...nextFragment.props);+ const instance = fragment.instances.find(+ (instance) => instance.id === instanceId+ );- fragment.instances.push({- id: instanceId,- type: "instance",- component,- children,- });- added.set(wfNode._id, instanceId);- addAttributes(wfNode, instanceId, props);- fragment.props.push(...props);+ if (instance === undefined) {+ return;+ }+ instance.children.push(...children);+ doneNodes.set(wfNode._id, instanceId);+ addCustomAttributes(wfNode, instanceId, fragment.props);return instanceId;};diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsdeleted file mode 100644index 60c5d8f8f3..0000000000--- a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.ts+++ /dev/null@@ -1,1372 +0,0 @@-import { test, expect, describe } from "@jest/globals";-import { __testing__ } from "./plugin-webflow";-import { $breakpoints } from "../../nano-states";-import {- type StyleRule,- createRegularStyleSheet,-} from "@webstudio-is/css-engine";-import type { WebstudioFragment } from "@webstudio-is/sdk";--const { toWebstudioFragment } = __testing__;--$breakpoints.set(new Map([["0", { id: "0", label: "base" }]]));--const toCss = (fragment: WebstudioFragment) => {- const sheet = createRegularStyleSheet();-- for (const breakpoint of fragment.breakpoints) {- sheet.addMediaRule(breakpoint.id, breakpoint);- }- const rulesMap = new Map<string, StyleRule>();- for (const style of fragment.styles) {- const token = fragment.styleSources.find(- (source) => source.id === style.styleSourceId- );- const name = token && "name" in token ? token.name : "Local";- let styleRule = rulesMap.get(name);- if (styleRule === undefined) {- styleRule = sheet.addStyleRule(- {- style: { [style.property]: style.value },- breakpoint: style.breakpointId,- },- name- );- rulesMap.set(name, styleRule);- continue;- }- styleRule.styleMap.set(style.property, style.value);- }- return sheet.cssText;-};--test("Heading", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "97d91be2-3bba-d340-0f13-a84e975b7497",- type: "Heading",- tag: "h1",- children: ["97d91be2-3bba-d340-0f13-a84e975b7498"],- classes: [],- },- {- _id: "97d91be2-3bba-d340-0f13-a84e975b7498",- v: "Turtle in the sea",- text: true,- },- ],- styles: [],- },- });- expect(fragment.children).toEqual([- {- type: "id",- value: expect.any(String),- },- ]);- expect(fragment.instances).toEqual([- {- children: [- {- type: "text",- value: "Turtle in the sea",- },- ],- component: "Heading",- id: expect.any(String),- type: "instance",- },- ]);- expect(fragment.props).toEqual([- {- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- type: "string",- value: "h1",- },- ]);-});--test("Link Block, Button, Text Link", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "97539676-c2ca-2e8f-55f3-6c4a3104a5c0",- type: "Link",- tag: "a",- classes: [],- children: [],- data: {- link: {- url: "https://webstudio.is",- target: "_blank",- },- },- },- ],- styles: [],- },- });- expect(fragment.children).toEqual([- {- type: "id",- value: expect.any(String),- },- ]);-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Link",- children: [],- },- ]);-- expect(fragment.props).toEqual([- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "href",- value: "https://webstudio.is",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "target",- value: "_blank",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- value: "a",- },- ]);-});--test("List and ListItem", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "7e11a800-c8e2-9b14-37cf-09a9e94754ad",- type: "List",- tag: "ul",- classes: [],- children: [- "7e11a800-c8e2-9b14-37cf-09a9e94754ae",- "7e11a800-c8e2-9b14-37cf-09a9e94754af",- "7e11a800-c8e2-9b14-37cf-09a9e94754b0",- ],- },- {- _id: "7e11a800-c8e2-9b14-37cf-09a9e94754ae",- type: "ListItem",- tag: "li",- classes: [],- children: [],- },- {- _id: "7e11a800-c8e2-9b14-37cf-09a9e94754af",- type: "ListItem",- tag: "li",- classes: [],- children: [],- },- {- _id: "7e11a800-c8e2-9b14-37cf-09a9e94754b0",- type: "ListItem",- tag: "li",- classes: [],- children: [],- },- ],- styles: [],- },- });- expect(fragment.children).toEqual([- {- type: "id",- value: expect.any(String),- },- ]);-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "ListItem",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "ListItem",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "ListItem",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "List",- children: [- { type: "id", value: expect.any(String) },- { type: "id", value: expect.any(String) },- { type: "id", value: expect.any(String) },- ],- },- ]);-});--test("Paragraph", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "dfab64ae-6624-b6db-a909-b85588aa3f8d",- type: "Paragraph",- tag: "p",- classes: [],- children: ["dfab64ae-6624-b6db-a909-b85588aa3f8e"],- },- {- _id: "dfab64ae-6624-b6db-a909-b85588aa3f8e",- text: true,- v: "Text in a paragraph",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Paragraph",- children: [- {- type: "text",- value: "Text in a paragraph",- },- ],- },- ]);- expect(fragment.props).toEqual([- {- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- type: "string",- value: "p",- },- ]);-});--test("Text", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "adea2109-96eb-63e0-c27f-632a7f40bce8",- type: "Block",- tag: "div",- classes: [],- children: ["adea2109-96eb-63e0-c27f-632a7f40bce9"],- data: {- text: true,- },- },- {- _id: "adea2109-96eb-63e0-c27f-632a7f40bce9",- text: true,- v: "This is some text inside of a div block.",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Text",- children: [- {- type: "text",- value: "This is some text inside of a div block.",- },- ],- },- ]);- expect(fragment.props).toEqual([- {- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- type: "string",- value: "div",- },- ]);-});--test("Blockquote", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Blockquote",- tag: "blockquote",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- {- _id: "25ffefdf-c015-5edd-7673-933b41a25329",- text: true,- v: "Block Quote",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Blockquote",- children: [- {- type: "text",- value: "Block Quote",- },- ],- },- ]);- expect(fragment.props).toEqual([- {- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- type: "string",- value: "blockquote",- },- ]);-});--test("Strong", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Strong",- tag: "strong",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- {- _id: "25ffefdf-c015-5edd-7673-933b41a25329",- text: true,- v: "Bold Text",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Bold",- children: [- {- type: "text",- value: "Bold Text",- },- ],- },- ]);-});--test("Emphasized", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Emphasized",- tag: "em",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- {- _id: "25ffefdf-c015-5edd-7673-933b41a25329",- text: true,- v: "Emphasis",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Italic",- children: [- {- type: "text",- value: "Emphasis",- },- ],- },- ]);-});--test("Superscript", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Superscript",- tag: "sup",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- {- _id: "25ffefdf-c015-5edd-7673-933b41a25329",- text: true,- v: "Superscript",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Superscript",- children: [- {- type: "text",- value: "Superscript",- },- ],- },- ]);-});--test("Subscript", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Subscript",- tag: "sub",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- {- _id: "25ffefdf-c015-5edd-7673-933b41a25329",- text: true,- v: "Subscript",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Subscript",- children: [- {- type: "text",- value: "Subscript",- },- ],- },- ]);-});--test("Section", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Section",- tag: "section",- classes: [],- children: ["25ffefdf-c015-5edd-7673-933b41a25329"],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("BlockContainer", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "BlockContainer",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("Block", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Block",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("V Flex", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "VFlex",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("H Flex", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "HFlex",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("Quick Stack", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "91782272-bf55-194d-ce85-9ddc69c51dee",- type: "Layout",- tag: "div",- classes: [],- children: [- "91782272-bf55-194d-ce85-9ddc69c51def",- "91782272-bf55-194d-ce85-9ddc69c51df0",- ],- },- {- _id: "91782272-bf55-194d-ce85-9ddc69c51def",- type: "Cell",- tag: "div",- classes: [],- children: [],- },- {- _id: "91782272-bf55-194d-ce85-9ddc69c51df0",- type: "Cell",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [- { type: "id", value: expect.any(String) },- { type: "id", value: expect.any(String) },- ],- },- ]);-});--test("Grid", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "25ffefdf-c015-5edd-7673-933b41a25328",- type: "Grid",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- ]);-});--test("Columns", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b58",- type: "Row",- tag: "div",- classes: [],- children: [- "08fb88d6-f6ec-5169-f4d4-8dac98df2b59",- "08fb88d6-f6ec-5169-f4d4-8dac98df2b5a",- ],- },- {- _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b59",- type: "Column",- tag: "div",- classes: [],- children: [],- },- {- _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b5a",- type: "Column",- tag: "div",- classes: [],- children: [],- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [],- },- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [- { type: "id", value: expect.any(String) },- { type: "id", value: expect.any(String) },- ],- },- ]);-});--test("Image", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "3c0b6a7a-830f-4b4a-48c5-4215f9c9389a",- type: "Image",- tag: "img",- classes: [],- children: [],- data: {- attr: {- src: "https://uploads-ssl.webflow.com/6640ea3496ea68a4a4e3efcf/665dd9f1927826d5caad6ed4_Screenshot%202024-05-29%20at%2023.10.33.png",- loading: "eager",- width: "200",- height: "auto",- alt: "Test",- },- },- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Image",- children: [],- },- ]);-- expect(fragment.props).toEqual([- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "alt",- value: "Test",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "loading",- value: "eager",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "width",- value: "200",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "src",- value: expect.not.stringMatching("src"),- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- value: "img",- },- ]);-});--test("HtmlEmbed", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "88131b38-7a58-8085-38d2-dc51c5ce887e",- type: "HtmlEmbed",- tag: "div",- classes: [],- children: [],- v: "some html",- },- ],- styles: [],- },- });- expect(fragment.instances).toEqual([- {- component: "HtmlEmbed",- id: expect.any(String),- type: "instance",- children: [],- },- ]);-- expect(fragment.props).toEqual([- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "code",- value: "some html",- },- {- type: "boolean",- id: expect.any(String),- instanceId: expect.any(String),- name: "clientOnly",- value: true,- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- value: "div",- },- ]);-});--test("CodeBlock", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "f06b6679-6414-3592-a6e3-b59196420d7f",- type: "CodeBlock",- tag: "div",- classes: [],- children: [],- data: {- code: "test",- language: "javascript",- },- },- ],- styles: [],- },- });- expect(fragment.instances).toEqual([- {- component: "CodeText",- id: expect.any(String),- type: "instance",- children: [],- },- ]);-- expect(fragment.props).toEqual([- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "lang",- value: "javascript",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "code",- value: "test",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- value: "div",- },- ]);-});--test("RichText", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "58c7368a-83e4-a9c2-e1c9-7244f0473095",- type: "RichText",- tag: "div",- classes: [],- children: [- "363e1f05-6da0-65bc-baeb-2a4d6eec67ba",- "2bf568d0-971f-5925-e6dd-0dd1cc2bc521",- ],- },- {- _id: "363e1f05-6da0-65bc-baeb-2a4d6eec67ba",- type: "Heading",- tag: "h1",- classes: [],- children: ["6fe8587d-c2d7-b346-cdef-9e29bb6efd50"],- },- {- _id: "6fe8587d-c2d7-b346-cdef-9e29bb6efd50",- text: true,- v: "Heading 1",- },- {- _id: "2bf568d0-971f-5925-e6dd-0dd1cc2bc521",- type: "Paragraph",- tag: "p",- classes: [],- children: [- "2a2d8880-03e0-ee0a-cec1-416751acb3e5",- "14d2b6a0-e2f6-94dd-b593-9d546eee84bf",- "e9ce86ec-be82-769e-82fb-247480c8d6ba",- "6c795406-de48-6d53-7d1c-d0ec4756e9d9",- "528588c5-3733-e1c3-136a-baaf24fcba33",- "95183c77-8fe7-d0ea-9685-b930608dc373",- "0f25b98b-6549-5d4e-5e11-7e56558b21e1",- ],- },- {- _id: "2a2d8880-03e0-ee0a-cec1-416751acb3e5",- text: true,- v: "Lorem ",- },- {- _id: "14d2b6a0-e2f6-94dd-b593-9d546eee84bf",- type: "Link",- tag: "a",- classes: [],- children: ["67af720f-cc2b-567e-d3df-05feef3870ce"],- data: {- button: false,- block: "",- link: {- url: "http://google.com",- },- },- },- {- _id: "67af720f-cc2b-567e-d3df-05feef3870ce",- type: "Emphasized",- tag: "em",- classes: [],- children: ["db8be0af-8c03-0785-3b84-f9ae7f4418f5"],- },- {- _id: "db8be0af-8c03-0785-3b84-f9ae7f4418f5",- text: true,- v: "ipsum",- },- {- _id: "e9ce86ec-be82-769e-82fb-247480c8d6ba",- text: true,- v: " dolor sit ",- },- {- _id: "528588c5-3733-e1c3-136a-baaf24fcba33",- text: true,- v: ", ",- },- {- _id: "95183c77-8fe7-d0ea-9685-b930608dc373",- type: "Strong",- tag: "strong",- classes: [],- children: ["e5bbc823-9dad-bfb7-d448-2e4d9af0be84"],- },- {- _id: "e5bbc823-9dad-bfb7-d448-2e4d9af0be84",- text: true,- v: "consectetur",- },- {- _id: "0f25b98b-6549-5d4e-5e11-7e56558b21e1",- text: true,- v: " ",- },- ],- styles: [],- },- });-- expect(fragment.instances).toEqual([- {- id: expect.any(String),- type: "instance",- component: "Heading",- children: [- {- type: "text",- value: "Heading 1",- },- ],- },- {- id: expect.any(String),- type: "instance",- component: "Italic",- children: [- {- type: "text",- value: "ipsum",- },- ],- },- {- id: expect.any(String),- type: "instance",- component: "Link",- children: [- {- type: "id",- value: expect.any(String),- },- ],- },- {- id: expect.any(String),- type: "instance",- component: "Bold",- children: [- {- type: "text",- value: "consectetur",- },- ],- },- {- id: expect.any(String),- type: "instance",- component: "Paragraph",- children: [- {- type: "text",- value: "Lorem ",- },- {- type: "id",- value: expect.any(String),- },- {- type: "text",- value: " dolor sit ",- },- {- type: "text",- value: ", ",- },- {- type: "id",- value: expect.any(String),- },- {- type: "text",- value: " ",- },- ],- },- {- id: expect.any(String),- type: "instance",- component: "Box",- children: [- {- type: "id",- value: expect.any(String),- },- {- type: "id",- value: expect.any(String),- },- ],- },- ]);-});--describe("Custom attributes", () => {- test("Basic", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "249f235e-91b6-bd0f-bc42-00993479e637",- type: "Heading",- tag: "h1",- classes: [],- children: [],- data: {- xattr: [- {- name: "at",- value: "b",- },- ],- },- },- ],- styles: [],- },- });- expect(fragment.props).toEqual([- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "tag",- value: "h1",- },- {- type: "string",- id: expect.any(String),- instanceId: expect.any(String),- name: "at",- value: "b",- },- ]);- });-});--describe("Styles", () => {- test("Single class", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "97d91be2-3bba-d340-0f13-a84e975b7497",- type: "Heading",- tag: "h1",- classes: ["a7bff598-b719-1edb-067b-a90a54d68605"],- children: [],- },- ],- styles: [- {- _id: "a7bff598-b719-1edb-067b-a90a54d68605",- type: "class",- name: "Heading",- styleLess: "color: hsla(0, 80.00%, 47.78%, 1.00);",- },- ],- },- });-- expect(fragment.styleSources).toEqual([- {- type: "token",- id: expect.any(String),- name: "h1",- },- {- type: "token",- id: expect.any(String),- name: "Heading",- },- ]);- expect(fragment.styleSourceSelections).toEqual([- {- instanceId: expect.any(String),- values: [expect.any(String), expect.any(String)],- },- ]);-- expect(toCss(fragment)).toMatchInlineSnapshot(`- "@media all {- h1 {- margin-right: 0;- margin-left: 0;- margin-bottom: 10px;- font-weight: bold;- margin-top: 20px;- font-size: 38px;- line-height: 44px- }- Heading {- color: rgba(219, 24, 24, 1)- }- }"- `);- });-- test("Combo class", async () => {- const fragment = await toWebstudioFragment({- type: "@webflow/XscpData",- payload: {- nodes: [- {- _id: "5f7ab979-89b3-c705-6ab9-35f77dfb209f",- type: "Link",- tag: "a",- classes: [- "194e7d07-469d-6ffa-3925-1f51bdad7e44",- "194e7d07-469d-6ffa-3925-1f51bdad7e46",- ],- children: [],- data: {- link: {- url: "#",- },- },- },- ],- styles: [- {- _id: "194e7d07-469d-6ffa-3925-1f51bdad7e44",- type: "class",- name: "button",- styleLess: "text-align: center;",- children: ["194e7d07-469d-6ffa-3925-1f51bdad7e46"],- },- {- _id: "194e7d07-469d-6ffa-3925-1f51bdad7e46",- type: "class",- name: "is-secondary",- comb: "&",- styleLess: "background-color: transparent; ",- createdBy: "6075409192d886a671499223",- },- ],- },- });-- expect(fragment.styleSources).toEqual([- {- type: "token",- id: expect.any(String),- name: "a",- },- {- type: "token",- id: expect.any(String),- name: "button",- },- {- type: "token",- id: expect.any(String),- name: "is-secondary",- },- ]);- expect(fragment.styleSourceSelections).toEqual([- {- instanceId: expect.any(String),- values: [expect.any(String), expect.any(String), expect.any(String)],- },- ]);-- expect(toCss(fragment)).toMatchInlineSnapshot(`- "@media all {- a {- background-color: rgba(0, 0, 0, 0);- outline-width: 0;- outline-style: initial;- outline-color: initial- }- button {- text-align: center- }- is-secondary {- background-color: transparent- }- }"- `);- });-});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.tsxnew file mode 100644index 0000000000..6e1d5f4090--- /dev/null+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.test.tsx@@ -0,0 +1,1728 @@+import { test, expect, describe, beforeEach } from "@jest/globals";+import { nanoid } from "nanoid";+import {+ type StyleRule,+ createRegularStyleSheet,+} from "@webstudio-is/css-engine";+import {+ initialBreakpoints,+ type WebstudioFragment,+ type Instance,+} from "@webstudio-is/sdk";+import { $, renderJsx } from "@webstudio-is/sdk/testing";+import * as defaultMetas from "@webstudio-is/sdk-components-react-remix/metas";+import { __testing__ } from "./plugin-webflow";+import { $breakpoints, $registeredComponentMetas } from "../../nano-states";++const { toWebstudioFragment } = __testing__;++const equalFragment = (fragment: WebstudioFragment, jsx: JSX.Element) => {+ const fragmentInstances = new Map();+ fragment.instances.forEach((instance: Instance) => {+ const newId = expect.any(String) as unknown as string;+ fragmentInstances.set(newId, {+ ...instance,+ id: newId,+ children: instance.children.map((child) => {+ if (child.type === "text") {+ return child;+ }+ return { type: "id", value: expect.any(String) as unknown as string };+ }),+ });+ });++ const expected = renderJsx(jsx);++ const expectedInstances = new Map();+ for (const instance of expected.instances.values()) {+ expectedInstances.set(instance.id, instance);+ }+ const fragmentProps = new Map();+ for (const prop of fragment.props) {+ prop.id = expect.any(String) as unknown as string;+ prop.instanceId = expect.any(String) as unknown as string;+ fragmentProps.set(prop.id, prop);+ }+ const expectedProps = new Map();+ for (const prop of expected.props.values()) {+ prop.id = expect.any(String) as unknown as string;+ prop.instanceId = expect.any(String) as unknown as string;+ expectedProps.set(prop.id, prop);+ }+ //console.dir(fragmentInstances, { depth: null });+ //console.dir(expectedInstances, { depth: null });+ //console.dir(expectedProps, { depth: null });+ expect(fragmentInstances).toEqual(expectedInstances);+ expect(fragmentProps).toEqual(expectedProps);+};++const toCss = (fragment: WebstudioFragment) => {+ const sheet = createRegularStyleSheet();+ for (const breakpoint of fragment.breakpoints) {+ sheet.addMediaRule(breakpoint.id, breakpoint);+ }+ const rulesMap = new Map<string, StyleRule>();+ for (const style of fragment.styles) {+ const token = fragment.styleSources.find(+ (source) => source.id === style.styleSourceId+ );+ const name = token && "name" in token ? token.name : "Local";+ const key = name + style.breakpointId;+ let styleRule = rulesMap.get(key);+ if (styleRule === undefined) {+ styleRule = sheet.addStyleRule(+ {+ style: { [style.property]: style.value },+ breakpoint: style.breakpointId,+ },+ name+ );+ rulesMap.set(key, styleRule);+ continue;+ }+ styleRule.styleMap.set(style.property, style.value);+ }+ return sheet.cssText;+};++beforeEach(() => {+ const defaultMetasMap = new Map(Object.entries(defaultMetas));+ $registeredComponentMetas.set(defaultMetasMap);++ $breakpoints.set(+ new Map(+ initialBreakpoints.map((breakpoint) => {+ const id = nanoid();+ return [id, { ...breakpoint, id }];+ })+ )+ );+});++test("Heading", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "97d91be2-3bba-d340-0f13-a84e975b7497",+ type: "Heading",+ tag: "h1",+ children: ["97d91be2-3bba-d340-0f13-a84e975b7498"],+ classes: [],+ },+ {+ _id: "97d91be2-3bba-d340-0f13-a84e975b7498",+ v: "Turtle in the sea",+ text: true,+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Heading tag="h1">Turtle in the sea</$.Heading>);+});++test("Link Block, Button, Text Link", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "97539676-c2ca-2e8f-55f3-6c4a3104a5c0",+ type: "Link",+ tag: "a",+ classes: [],+ children: [],+ data: {+ link: {+ url: "https://webstudio.is",+ target: "_blank",+ },+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Link href="https://webstudio.is" target="_blank" />+ );+});++test("List and ListItem", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "7e11a800-c8e2-9b14-37cf-09a9e94754ad",+ type: "List",+ tag: "ul",+ classes: [],+ children: [+ "7e11a800-c8e2-9b14-37cf-09a9e94754ae",+ "7e11a800-c8e2-9b14-37cf-09a9e94754af",+ "7e11a800-c8e2-9b14-37cf-09a9e94754b0",+ ],+ },+ {+ _id: "7e11a800-c8e2-9b14-37cf-09a9e94754ae",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: [],+ },+ {+ _id: "7e11a800-c8e2-9b14-37cf-09a9e94754af",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: [],+ },+ {+ _id: "7e11a800-c8e2-9b14-37cf-09a9e94754b0",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.List>+ <$.ListItem />+ <$.ListItem />+ <$.ListItem />+ </$.List>+ );+});++test("Paragraph", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "dfab64ae-6624-b6db-a909-b85588aa3f8d",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["dfab64ae-6624-b6db-a909-b85588aa3f8e"],+ },+ {+ _id: "dfab64ae-6624-b6db-a909-b85588aa3f8e",+ text: true,+ v: "Text in a paragraph",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Paragraph>Text in a paragraph</$.Paragraph>);+});++test("Text", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "adea2109-96eb-63e0-c27f-632a7f40bce8",+ type: "Block",+ tag: "div",+ classes: [],+ children: ["adea2109-96eb-63e0-c27f-632a7f40bce9"],+ data: {+ text: true,+ },+ },+ {+ _id: "adea2109-96eb-63e0-c27f-632a7f40bce9",+ text: true,+ v: "This is some text inside of a div block.",+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Text>This is some text inside of a div block.</$.Text>+ );+});++test("Blockquote", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Blockquote",+ tag: "blockquote",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25329",+ text: true,+ v: "Block Quote",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Blockquote>Block Quote</$.Blockquote>);+});++test("Strong", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Strong",+ tag: "strong",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25329",+ text: true,+ v: "Bold Text",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Bold>Bold Text</$.Bold>);+});++test("Emphasized", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Emphasized",+ tag: "em",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25329",+ text: true,+ v: "Emphasis",+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.Italic>Emphasis</$.Italic>);+});++test("Superscript", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Superscript",+ tag: "sup",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25329",+ text: true,+ v: "Superscript",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Superscript>Superscript</$.Superscript>);+});++test("Subscript", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Subscript",+ tag: "sub",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25329",+ text: true,+ v: "Subscript",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Subscript>Subscript</$.Subscript>);+});++test("Section", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Section",+ tag: "section",+ classes: [],+ children: ["25ffefdf-c015-5edd-7673-933b41a25329"],+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Box tag="section" />);+});++test("BlockContainer", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "BlockContainer",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.Box />);+});++test("Block", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Block",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Box />);+});++test("V Flex", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "VFlex",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.Box />);+});++test("H Flex", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "HFlex",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.Box />);+});++test("Quick Stack", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "91782272-bf55-194d-ce85-9ddc69c51dee",+ type: "Layout",+ tag: "div",+ classes: [],+ children: [+ "91782272-bf55-194d-ce85-9ddc69c51def",+ "91782272-bf55-194d-ce85-9ddc69c51df0",+ ],+ },+ {+ _id: "91782272-bf55-194d-ce85-9ddc69c51def",+ type: "Cell",+ tag: "div",+ classes: [],+ children: [],+ },+ {+ _id: "91782272-bf55-194d-ce85-9ddc69c51df0",+ type: "Cell",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });+ equalFragment(+ fragment,+ <$.Box>+ <$.Box />+ <$.Box />+ </$.Box>+ );+});++test("Grid", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "25ffefdf-c015-5edd-7673-933b41a25328",+ type: "Grid",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Box />);+});++test("Columns", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b58",+ type: "Row",+ tag: "div",+ classes: [],+ children: [+ "08fb88d6-f6ec-5169-f4d4-8dac98df2b59",+ "08fb88d6-f6ec-5169-f4d4-8dac98df2b5a",+ ],+ },+ {+ _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b59",+ type: "Column",+ tag: "div",+ classes: [],+ children: [],+ },+ {+ _id: "08fb88d6-f6ec-5169-f4d4-8dac98df2b5a",+ type: "Column",+ tag: "div",+ classes: [],+ children: [],+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Box>+ <$.Box />+ <$.Box />+ </$.Box>+ );+});++test("Image", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "3c0b6a7a-830f-4b4a-48c5-4215f9c9389a",+ type: "Image",+ tag: "img",+ classes: [],+ children: [],+ data: {+ attr: {+ src: "https://test.com/image.jpg",+ loading: "eager",+ width: "200",+ height: "auto",+ alt: "Test",+ },+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Image+ alt="Test"+ loading="eager"+ width="200"+ src="https://test.com/image.jpg"+ />+ );+});++test("HtmlEmbed", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "88131b38-7a58-8085-38d2-dc51c5ce887e",+ type: "HtmlEmbed",+ tag: "div",+ classes: [],+ children: [],+ v: "some html",+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.HtmlEmbed code="some html" clientOnly={true} />);+});++test("CodeBlock", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "f06b6679-6414-3592-a6e3-b59196420d7f",+ type: "CodeBlock",+ tag: "div",+ classes: [],+ children: [],+ data: {+ code: "test",+ language: "javascript",+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.CodeText lang="javascript" code="test" />);+});++test("RichText", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "33178bae-2d99-7d1f-ffa5-101356769dad",+ type: "RichText",+ tag: "div",+ classes: [],+ children: [+ "8418336b-918d-3160-1d76-8c9de474cb43",+ "63929533-a4de-17c6-3b13-351aa16c6e10",+ "7724e6e0-9e3c-4526-35a9-f11dcd628c35",+ "d760a6fd-5da7-7d24-4f4c-24e68a651758",+ "49c71aa2-c61b-4823-dfdb-dc3badea814b",+ "28784747-282c-fe17-a81b-c36c9212b78e",+ "6e4c4ff0-0ebe-1de0-d94d-6f18f08f0762",+ "88e7fd8c-98ff-49f7-aff1-3286e2e0e211",+ "63202791-9c33-bc97-b49e-71a2af805488",+ "b386cecd-1697-e7e8-6c7b-66f36261fec2",+ "98b880aa-7ba5-c754-8069-b83cb198ec32",+ "2e3bf379-e9ee-182c-9f92-1e1409ba1dd7",+ "43d15a61-5f5d-d4bd-4a8c-04b80371e808",+ "676d66b8-3df9-45a5-b2a4-62b75b623443",+ "57268510-0593-b1df-7786-f1f3b3d02830",+ "cd959e82-0fe8-a4a7-6b9f-c5fab19aa6ec",+ "10389bae-2b31-83d5-919f-45fc50689288",+ ],+ },+ {+ _id: "8418336b-918d-3160-1d76-8c9de474cb43",+ type: "Heading",+ tag: "h1",+ classes: [],+ children: ["c1759a8a-6657-5c74-4e95-33c8a721caab"],+ },+ {+ _id: "c1759a8a-6657-5c74-4e95-33c8a721caab",+ text: true,+ v: "Heading 1",+ },+ {+ _id: "63929533-a4de-17c6-3b13-351aa16c6e10",+ type: "Heading",+ tag: "h2",+ classes: [],+ children: ["d04d84bb-f382-5af4-482a-e6a0aaab168b"],+ },+ {+ _id: "d04d84bb-f382-5af4-482a-e6a0aaab168b",+ text: true,+ v: "Heading 2",+ },+ {+ _id: "7724e6e0-9e3c-4526-35a9-f11dcd628c35",+ type: "Heading",+ tag: "h3",+ classes: [],+ children: ["409d9647-ea51-e048-2bfd-cbbee2efb0c6"],+ },+ {+ _id: "409d9647-ea51-e048-2bfd-cbbee2efb0c6",+ text: true,+ v: "Heading 3",+ },+ {+ _id: "d760a6fd-5da7-7d24-4f4c-24e68a651758",+ type: "Heading",+ tag: "h4",+ classes: [],+ children: ["4ce7fd9b-c7e9-186c-853a-931c507e5d1d"],+ },+ {+ _id: "4ce7fd9b-c7e9-186c-853a-931c507e5d1d",+ text: true,+ v: "Heading 4",+ },+ {+ _id: "49c71aa2-c61b-4823-dfdb-dc3badea814b",+ type: "Heading",+ tag: "h5",+ classes: [],+ children: ["f28abd5f-e21c-08f5-c6be-ec335166114d"],+ },+ {+ _id: "f28abd5f-e21c-08f5-c6be-ec335166114d",+ text: true,+ v: "Heading 5",+ },+ {+ _id: "28784747-282c-fe17-a81b-c36c9212b78e",+ type: "Heading",+ tag: "h6",+ classes: [],+ children: ["6f753bba-a1d9-5092-e605-2f1756fc4a3d"],+ },+ {+ _id: "6f753bba-a1d9-5092-e605-2f1756fc4a3d",+ text: true,+ v: "Heading 6",+ },+ {+ _id: "6e4c4ff0-0ebe-1de0-d94d-6f18f08f0762",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["27e847ff-962c-0782-1278-2f4ff342aaad"],+ },+ {+ _id: "27e847ff-962c-0782-1278-2f4ff342aaad",+ text: true,+ v: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",+ },+ {+ _id: "88e7fd8c-98ff-49f7-aff1-3286e2e0e211",+ type: "Blockquote",+ tag: "blockquote",+ classes: [],+ children: ["9c1d38a3-512b-4f90-e6c4-cadf585cb608"],+ },+ {+ _id: "9c1d38a3-512b-4f90-e6c4-cadf585cb608",+ text: true,+ v: "Block quote",+ },+ {+ _id: "63202791-9c33-bc97-b49e-71a2af805488",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["3080a095-fc1a-9de8-e6d1-21c801aed169"],+ },+ {+ _id: "3080a095-fc1a-9de8-e6d1-21c801aed169",+ text: true,+ v: "Ordered list",+ },+ {+ _id: "b386cecd-1697-e7e8-6c7b-66f36261fec2",+ type: "List",+ tag: "ol",+ classes: [],+ children: [+ "aafe8235-0ff4-c6f4-8382-40fc34900b75",+ "0fd98471-33b6-e8d2-76f1-6e373849e6ba",+ "2ccfda89-a200-d286-440a-f94699163329",+ ],+ },+ {+ _id: "aafe8235-0ff4-c6f4-8382-40fc34900b75",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["bf312343-69b6-bec7-5ee1-e19154d85b62"],+ },+ {+ _id: "bf312343-69b6-bec7-5ee1-e19154d85b62",+ text: true,+ v: "Item 1",+ },+ {+ _id: "0fd98471-33b6-e8d2-76f1-6e373849e6ba",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["161683ac-eed6-7a68-64f7-706c42984c65"],+ },+ {+ _id: "161683ac-eed6-7a68-64f7-706c42984c65",+ text: true,+ v: "Item 2",+ },+ {+ _id: "2ccfda89-a200-d286-440a-f94699163329",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["59f4270b-72e6-99b1-041a-5ab836481b5c"],+ },+ {+ _id: "59f4270b-72e6-99b1-041a-5ab836481b5c",+ text: true,+ v: "Item 3",+ },+ {+ _id: "98b880aa-7ba5-c754-8069-b83cb198ec32",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["b6755218-5a0d-c537-43c0-071245d7a472"],+ },+ {+ _id: "b6755218-5a0d-c537-43c0-071245d7a472",+ text: true,+ v: "Unordered list",+ },+ {+ _id: "2e3bf379-e9ee-182c-9f92-1e1409ba1dd7",+ type: "List",+ tag: "ul",+ classes: [],+ children: [+ "a90c5835-61e2-e1e6-dfd3-0b02a34ad857",+ "748eb739-12d7-26fc-b8ee-f2c460f35170",+ "54178296-1686-9b14-a341-42ce51958ce5",+ ],+ },+ {+ _id: "a90c5835-61e2-e1e6-dfd3-0b02a34ad857",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["8557d8cf-09de-52c0-4631-c2123fc056d1"],+ },+ {+ _id: "8557d8cf-09de-52c0-4631-c2123fc056d1",+ text: true,+ v: "Item A",+ },+ {+ _id: "748eb739-12d7-26fc-b8ee-f2c460f35170",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["666b664d-8023-50bb-453a-36017c7a3a38"],+ },+ {+ _id: "666b664d-8023-50bb-453a-36017c7a3a38",+ text: true,+ v: "Item B",+ },+ {+ _id: "54178296-1686-9b14-a341-42ce51958ce5",+ type: "ListItem",+ tag: "li",+ classes: [],+ children: ["15647123-fd1c-5928-3894-d666bc6f3c84"],+ },+ {+ _id: "15647123-fd1c-5928-3894-d666bc6f3c84",+ text: true,+ v: "Item C",+ },+ {+ _id: "43d15a61-5f5d-d4bd-4a8c-04b80371e808",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["db8cce1a-40ff-ccb7-5f18-ebb811777409"],+ },+ {+ _id: "db8cce1a-40ff-ccb7-5f18-ebb811777409",+ type: "Link",+ tag: "a",+ classes: [],+ children: ["a8af1cd8-157c-4b92-c27e-bca1ae5e6668"],+ data: {+ button: false,+ block: "",+ link: {+ url: "https://university.webflow.com/lesson/add-and-nest-text-links-in-webflow",+ },+ },+ },+ {+ _id: "a8af1cd8-157c-4b92-c27e-bca1ae5e6668",+ text: true,+ v: "Text link",+ },+ {+ _id: "676d66b8-3df9-45a5-b2a4-62b75b623443",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["4f0b961b-5774-f441-e97f-e84a75efcf08"],+ },+ {+ _id: "4f0b961b-5774-f441-e97f-e84a75efcf08",+ type: "Strong",+ tag: "strong",+ classes: [],+ children: ["5839c9b9-4281-f778-f7f9-c4844452295e"],+ },+ {+ _id: "5839c9b9-4281-f778-f7f9-c4844452295e",+ text: true,+ v: "Bold text",+ },+ {+ _id: "57268510-0593-b1df-7786-f1f3b3d02830",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["db4e59e1-b859-d2bc-ee4a-08c638f088db"],+ },+ {+ _id: "db4e59e1-b859-d2bc-ee4a-08c638f088db",+ type: "Emphasized",+ tag: "em",+ classes: [],+ children: ["c2661284-144d-5052-447a-ffe78f3b8bbe"],+ },+ {+ _id: "c2661284-144d-5052-447a-ffe78f3b8bbe",+ text: true,+ v: "Emphasis",+ },+ {+ _id: "cd959e82-0fe8-a4a7-6b9f-c5fab19aa6ec",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["debd47f8-ddd2-8ead-af6c-5e42a16e15d0"],+ },+ {+ _id: "debd47f8-ddd2-8ead-af6c-5e42a16e15d0",+ type: "Superscript",+ tag: "sup",+ classes: [],+ children: ["e6640190-f224-5a57-6181-55a793c00da8"],+ },+ {+ _id: "e6640190-f224-5a57-6181-55a793c00da8",+ text: true,+ v: "Superscript",+ },+ {+ _id: "10389bae-2b31-83d5-919f-45fc50689288",+ type: "Paragraph",+ tag: "p",+ classes: [],+ children: ["ec162f35-9226-0e8a-c0c2-32685ef444c1"],+ },+ {+ _id: "ec162f35-9226-0e8a-c0c2-32685ef444c1",+ type: "Subscript",+ tag: "sub",+ classes: [],+ children: ["dcdc8f43-3cdc-1522-e397-60968e378b92"],+ },+ {+ _id: "dcdc8f43-3cdc-1522-e397-60968e378b92",+ text: true,+ v: "Subscript",+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Box>+ <$.Heading tag="h1">Heading 1</$.Heading>+ <$.Heading tag="h2">Heading 2</$.Heading>+ <$.Heading tag="h3">Heading 3</$.Heading>+ <$.Heading tag="h4">Heading 4</$.Heading>+ <$.Heading tag="h5">Heading 5</$.Heading>+ <$.Heading tag="h6">Heading 6</$.Heading>+ <$.Paragraph>+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod+ tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim+ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea+ commodo consequat. Duis aute irure dolor in reprehenderit in voluptate+ velit esse cillum dolore eu fugiat nulla pariatur.+ </$.Paragraph>+ <$.Blockquote>Block quote</$.Blockquote>+ <$.Paragraph>Ordered list</$.Paragraph>+ <$.List ordered={true}>+ <$.ListItem>Item 1</$.ListItem>+ <$.ListItem>Item 2</$.ListItem>+ <$.ListItem>Item 3</$.ListItem>+ </$.List>+ <$.Paragraph>Unordered list</$.Paragraph>+ <$.List>+ <$.ListItem>Item A</$.ListItem>+ <$.ListItem>Item B</$.ListItem>+ <$.ListItem>Item C</$.ListItem>+ </$.List>+ <$.Paragraph>+ <$.Link href="https://university.webflow.com/lesson/add-and-nest-text-links-in-webflow">+ Text link+ </$.Link>+ </$.Paragraph>+ <$.Paragraph>+ <$.Bold>Bold text</$.Bold>+ </$.Paragraph>+ <$.Paragraph>+ <$.Italic>Emphasis</$.Italic>+ </$.Paragraph>+ <$.Paragraph>+ <$.Superscript>Superscript</$.Superscript>+ </$.Paragraph>+ <$.Paragraph>+ <$.Subscript>Subscript</$.Subscript>+ </$.Paragraph>+ </$.Box>+ );+});++test("Form", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "f19c775e-a9ef-fd0c-2d16-aa53c69e9da4",+ type: "FormWrapper",+ tag: "div",+ classes: [],+ children: [+ "11c85957-89b5-e4f8-da11-f1acb4223a9f",+ "492633d9-7425-ba09-036f-e43213b9875b",+ "a0877638-7523-ac57-7ed9-19f5469e79d1",+ ],+ },+ {+ _id: "11c85957-89b5-e4f8-da11-f1acb4223a9f",+ type: "FormForm",+ tag: "form",+ classes: [],+ children: ["eeb469a5-8b03-8002-7dec-586856365387"],+ },+ {+ _id: "eeb469a5-8b03-8002-7dec-586856365387",+ type: "FormTextInput",+ tag: "input",+ classes: [],+ children: [],+ data: {+ attr: {+ id: "name",+ name: "name",+ maxlength: 256,+ placeholder: "",+ disabled: false,+ type: "text",+ required: false,+ autofocus: false,+ },+ },+ },+ {+ _id: "492633d9-7425-ba09-036f-e43213b9875b",+ type: "FormSuccessMessage",+ tag: "div",+ classes: [],+ children: ["442d7e86-2c77-961c-ab1b-431bd34abcf7"],+ },+ {+ _id: "442d7e86-2c77-961c-ab1b-431bd34abcf7",+ type: "Block",+ tag: "div",+ classes: [],+ children: ["875baf7f-6c98-b379-0cbe-59b5fdd2c112"],+ },+ {+ _id: "875baf7f-6c98-b379-0cbe-59b5fdd2c112",+ text: true,+ v: "Thank you! Your submission has been received!",+ },+ {+ _id: "a0877638-7523-ac57-7ed9-19f5469e79d1",+ type: "FormErrorMessage",+ tag: "div",+ classes: [],+ children: ["9eaf0a19-b2fa-7aef-4825-41f6319d790d"],+ },+ {+ _id: "9eaf0a19-b2fa-7aef-4825-41f6319d790d",+ type: "Block",+ tag: "div",+ classes: [],+ children: ["a87685fe-24b2-31ff-e229-40c71f6155dd"],+ },+ {+ _id: "a87685fe-24b2-31ff-e229-40c71f6155dd",+ text: true,+ v: "Oops! Something went wrong while submitting the form.",+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Box>+ <$.Box>+ <$.Input+ id="name"+ name="name"+ maxLength={256}+ placeholder=""+ disabled={false}+ type="text"+ required={false}+ autoFocus={false}+ />+ </$.Box>+ </$.Box>+ );+});++test("FormButton", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "b7d4b56c-77eb-a79d-4b73-7802d6c5f74a",+ type: "FormButton",+ tag: "input",+ classes: [],+ children: [],+ data: {+ attr: {+ value: "Submit",+ },+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Button>Submit</$.Button>);+});++test("FormTextInput", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "3b60c6c7-296c-f98b-0557-a55dcac084b3",+ type: "FormTextInput",+ tag: "input",+ classes: [],+ children: [],+ data: {+ attr: {+ id: "email",+ name: "email",+ maxlength: 256,+ placeholder: "",+ disabled: false,+ type: "email",+ required: true,+ autofocus: false,+ },+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Input+ id="email"+ name="email"+ maxLength={256}+ placeholder=""+ disabled={false}+ type="email"+ required={true}+ autoFocus={false}+ />+ );+});++test("FormBlockLabel", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "0fdc679b-9891-dfb3-698a-0114d0c6c729",+ type: "FormBlockLabel",+ tag: "label",+ classes: [],+ children: ["7827c7aa-cd90-8bda-4570-605f2a1a0d61"],+ data: {+ attr: {+ for: "email",+ },+ },+ },+ {+ _id: "7827c7aa-cd90-8bda-4570-605f2a1a0d61",+ text: true,+ v: "Email Address",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Label htmlFor="email">Email Address</$.Label>);+});++test("FormTextarea", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "ff81988e-1cc2-8c93-d264-d702d846c30a",+ type: "FormTextarea",+ tag: "textarea",+ classes: [],+ children: [],+ data: {+ attr: {+ id: "field",+ name: "field",+ maxlength: 5000,+ placeholder: "Example Text",+ required: false,+ autofocus: false,+ },+ },+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Textarea+ id="field"+ name="field"+ maxLength={5000}+ placeholder="Example Text"+ required={false}+ autoFocus={false}+ />+ );+});++test("FormBlockLabel", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "0fdc679b-9891-dfb3-698a-0114d0c6c729",+ type: "FormBlockLabel",+ tag: "label",+ classes: [],+ children: ["7827c7aa-cd90-8bda-4570-605f2a1a0d61"],+ data: {+ attr: {+ for: "email",+ },+ },+ },+ {+ _id: "7827c7aa-cd90-8bda-4570-605f2a1a0d61",+ text: true,+ v: "Email Address",+ },+ ],+ styles: [],+ },+ });++ equalFragment(fragment, <$.Label htmlFor="email">Email Address</$.Label>);+});++test("FormCheckboxWrapper, FormCheckboxInput, FormInlineLabel", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "4b49f914-6011-9030-5727-232bbddc7d56",+ type: "FormCheckboxWrapper",+ tag: "div",+ classes: [],+ children: [+ "2e32acc8-7027-1741-1be1-cc72606b57cf",+ "3f68e88d-5c03-698e-c4e2-a6ad6ff1a00c",+ ],+ },+ {+ _id: "2e32acc8-7027-1741-1be1-cc72606b57cf",+ type: "FormCheckboxInput",+ tag: "input",+ classes: [],+ children: [],+ data: {+ attr: {+ type: "checkbox",+ name: "checkbox",+ id: "checkbox",+ required: false,+ checked: false,+ },+ },+ },+ {+ _id: "3f68e88d-5c03-698e-c4e2-a6ad6ff1a00c",+ type: "FormInlineLabel",+ tag: "label",+ classes: [],+ children: ["18550f45-3a50-27d6-4524-b91a226ded60"],+ },+ {+ _id: "18550f45-3a50-27d6-4524-b91a226ded60",+ text: true,+ v: "Checkbox",+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Label ws:label="Checkbox Field">+ <$.Checkbox+ id="checkbox"+ name="checkbox"+ required={false}+ defaultChecked={false}+ />+ <$.Text tag="span" ws:label="Label">+ Checkbox+ </$.Text>+ </$.Label>+ );+});++test("FormRadioWrapper, FormRadioInput, FormInlineLabel", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "712915f3-84e7-6e7a-e1a1-050e12d3b401",+ type: "FormRadioWrapper",+ tag: "div",+ classes: [],+ children: [+ "2ee7bcbb-e2ec-3c21-2cb0-c76171ff84e0",+ "99874ce0-e582-a5ea-9934-f6e42266a80d",+ ],+ },+ {+ _id: "2ee7bcbb-e2ec-3c21-2cb0-c76171ff84e0",+ type: "FormRadioInput",+ tag: "input",+ classes: [],+ children: [],+ data: {+ attr: {+ type: "radio",+ name: "radio",+ id: "radio",+ value: "Radio",+ required: false,+ },+ },+ },+ {+ _id: "99874ce0-e582-a5ea-9934-f6e42266a80d",+ type: "FormInlineLabel",+ tag: "label",+ classes: [],+ children: ["9e6a0451-a55e-a063-9acc-ee22ed5eac94"],+ },+ {+ _id: "9e6a0451-a55e-a063-9acc-ee22ed5eac94",+ text: true,+ v: "Radio",+ },+ ],+ styles: [],+ },+ });++ equalFragment(+ fragment,+ <$.Label ws:label="Radio Field">+ <$.RadioButton id="radio" name="radio" required={false} value="Radio" />+ <$.Text tag="span" ws:label="Label">+ Radio+ </$.Text>+ </$.Label>+ );+});++describe("Custom attributes", () => {+ test("Basic", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "249f235e-91b6-bd0f-bc42-00993479e637",+ type: "Heading",+ tag: "h1",+ classes: [],+ children: [],+ data: {+ xattr: [+ {+ name: "at",+ value: "b",+ },+ ],+ },+ },+ ],+ styles: [],+ },+ });+ equalFragment(fragment, <$.Heading tag="h1" at="b" />);+ });+});++describe("Styles", () => {+ test("Single class", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "97d91be2-3bba-d340-0f13-a84e975b7497",+ type: "Heading",+ tag: "h1",+ classes: ["a7bff598-b719-1edb-067b-a90a54d68605"],+ children: [],+ },+ ],+ styles: [+ {+ _id: "a7bff598-b719-1edb-067b-a90a54d68605",+ type: "class",+ name: "Heading",+ styleLess: "color: hsla(0, 80.00%, 47.78%, 1.00);",+ },+ ],+ },+ });++ expect(fragment.styleSources).toEqual([+ {+ type: "token",+ id: expect.any(String),+ name: "h1",+ },+ {+ type: "token",+ id: expect.any(String),+ name: "Heading",+ },+ ]);+ expect(fragment.styleSourceSelections).toEqual([+ {+ instanceId: expect.any(String),+ values: [expect.any(String), expect.any(String)],+ },+ ]);++ expect(toCss(fragment)).toMatchInlineSnapshot(`+ "@media all {+ h1 {+ margin-right: 0;+ margin-left: 0;+ margin-bottom: 10px;+ font-weight: bold;+ margin-top: 20px;+ font-size: 38px;+ line-height: 44px+ }+ Heading {+ color: rgba(219, 24, 24, 1)+ }+ }"+ `);+ });++ test("Combo class", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "5f7ab979-89b3-c705-6ab9-35f77dfb209f",+ type: "Link",+ tag: "a",+ classes: [+ "194e7d07-469d-6ffa-3925-1f51bdad7e44",+ "194e7d07-469d-6ffa-3925-1f51bdad7e46",+ ],+ children: [],+ data: {+ link: {+ url: "#",+ },+ },+ },+ ],+ styles: [+ {+ _id: "194e7d07-469d-6ffa-3925-1f51bdad7e44",+ type: "class",+ name: "button",+ styleLess: "text-align: center;",+ children: ["194e7d07-469d-6ffa-3925-1f51bdad7e46"],+ },+ {+ _id: "194e7d07-469d-6ffa-3925-1f51bdad7e46",+ type: "class",+ name: "is-secondary",+ comb: "&",+ styleLess: "background-color: transparent; ",+ createdBy: "6075409192d886a671499223",+ },+ ],+ },+ });++ expect(fragment.styleSources).toEqual([+ {+ type: "token",+ id: expect.any(String),+ name: "a",+ },+ {+ type: "token",+ id: expect.any(String),+ name: "button",+ },+ {+ type: "token",+ id: expect.any(String),+ name: "is-secondary",+ },+ ]);+ expect(fragment.styleSourceSelections).toEqual([+ {+ instanceId: expect.any(String),+ values: [expect.any(String), expect.any(String), expect.any(String)],+ },+ ]);++ expect(toCss(fragment)).toMatchInlineSnapshot(`+ "@media all {+ a {+ background-color: rgba(0, 0, 0, 0);+ outline-width: 0;+ outline-style: initial;+ outline-color: initial+ }+ button {+ text-align: center+ }+ is-secondary {+ background-color: transparent+ }+ }"+ `);+ });+});++test("Breakpoints", async () => {+ const fragment = await toWebstudioFragment({+ type: "@webflow/XscpData",+ payload: {+ nodes: [+ {+ _id: "c06c94aa-e2cd-fa7a-d8f8-574b474a20fa",+ type: "Block",+ tag: "div",+ classes: ["81fbefba-d2de-9cc2-81bf-3a929d4eb219"],+ children: [],+ },+ ],+ styles: [+ {+ _id: "81fbefba-d2de-9cc2-81bf-3a929d4eb219",+ fake: false,+ type: "class",+ name: "Div Block 2",+ namespace: "",+ comb: "",+ styleLess: "background-color: hsla(191, 100.00%, 50.00%, 1.00);",+ variants: {+ large: {+ styleLess: "background-color: hsla(150, 100.00%, 50.00%, 1.00);",+ },+ xl: {+ styleLess: "background-color: hsla(69, 100.00%, 50.00%, 1.00);",+ },+ xxl: {+ styleLess: "background-color: hsla(14, 100.00%, 50.00%, 1.00);",+ },+ medium: {+ styleLess: "background-color: hsla(256, 100.00%, 50.00%, 1.00);",+ },+ small: {+ styleLess: "background-color: hsla(308, 100.00%, 50.00%, 1.00);",+ },+ tiny: {+ styleLess: "background-color: hsla(359, 100.00%, 50.00%, 1.00);",+ },+ },+ },+ ],+ },+ });++ expect(toCss(fragment)).toMatchInlineSnapshot(`+ "@media all {+ Div Block 2 {+ background-color: rgba(0, 208, 255, 1)+ }+ }+ @media all and (max-width: 991px) {+ Div Block 2 {+ background-color: rgba(68, 0, 255, 1)+ }+ }+ @media all and (max-width: 767px) {+ Div Block 2 {+ background-color: rgba(255, 0, 221, 1)+ }+ }+ @media all and (max-width: 479px) {+ Div Block 2 {+ background-color: rgba(255, 0, 4, 1)+ }+ }+ @media all and (min-width: 1280px) {+ Div Block 2 {+ background-color: rgba(0, 255, 128, 1)+ }+ }+ @media all and (min-width: 1440px) {+ Div Block 2 {+ background-color: rgba(217, 255, 0, 1)+ }+ }+ @media all and (min-width: 1920px) {+ Div Block 2 {+ background-color: rgba(255, 60, 0, 1)+ }+ }"+ `);+});diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.tsindex c4bb7cb668..b0699449a3 100644--- a/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.ts+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/plugin-webflow.ts@@ -1,8 +1,11 @@import type { Instance, WebstudioFragment } from "@webstudio-is/sdk";import {computeInstancesConstraints,+ findAvailableDataSources,findClosestDroppableTarget,- insertTemplateData,+ insertInstanceChildrenMutable,+ insertWebstudioFragmentCopy,+ updateWebstudioData,} from "../../instance-utils";import {$instances,@@ -14,9 +17,11 @@ import { isFeatureEnabled } from "@webstudio-is/feature-flags";import { WfData, WfNode, WfStyle, wfNodeTypes } from "./schema";import { addInstanceAndProperties } from "./instances-properties";import { addStyles } from "./styles";-import { toast } from "@webstudio-is/design-system";+import { builderApi } from "~/shared/builder-api";import { denormalizeSrcProps } from "../asset-upload";+const { toast } = builderApi;+export const mimeType = "application/json";const toWebstudioFragment = async (wfData: WfData) => {@@ -42,15 +47,19 @@ const toWebstudioFragment = async (wfData: WfData) => {const wfStyles = new Map<WfStyle["_id"], WfStyle>(wfData.payload.styles.map((style: WfStyle) => [style._id, style]));- const added = new Map<WfNode["_id"], Instance["id"]>();+ // False value used to skip a node.+ const doneNodes = new Map<WfNode["_id"], Instance["id"] | false>();for (const wfNode of wfNodes.values()) {- addInstanceAndProperties(wfNode, added, wfNodes, fragment);+ addInstanceAndProperties(wfNode, doneNodes, wfNodes, fragment);}- await addStyles(wfNodes, wfStyles, added, fragment);+ await addStyles(wfNodes, wfStyles, doneNodes, fragment);// First node should be always the root node in theory, if not// we need to find a node that is not a child of any other node.const rootWfNode = wfData.payload.nodes[0];- const rootInstanceId = added.get(rootWfNode._id);+ const rootInstanceId = doneNodes.get(rootWfNode._id);+ if (rootInstanceId === false) {+ return fragment;+ }if (rootInstanceId === undefined) {console.error(`No root instance id found for node ${rootWfNode._id}`);return fragment;@@ -87,7 +96,7 @@ const parse = (clipboardData: string) => {.map((node: { type: string }) => node.type);if (unsupportedNodeTypes.length !== 0) {- const message = `Skipping unsupported nodes: ${unsupportedNodeTypes.join(", ")}`;+ const message = `Skipping unsupported elements: ${unsupportedNodeTypes.join(", ")}`;toast.info(message);console.info(message);}@@ -112,7 +121,7 @@ export const onPaste = async (clipboardData: string) => {}let fragment = await toWebstudioFragment(wfData);const selectedPage = $selectedPage.get();- if (fragment.instances.length === 0 || selectedPage === undefined) {+ if (fragment === undefined || selectedPage === undefined) {return false;}@@ -122,23 +131,52 @@ export const onPaste = async (clipboardData: string) => {const newInstances = new Map(fragment.instances.map((instance) => [instance.id, instance]));- const rootInstanceIds = fragment.children- .filter((child) => child.type === "id")- .map((child) => child.value);+// paste to the root if nothing is selectedconst instanceSelector = $selectedInstanceSelector.get() ?? [selectedPage.rootInstanceId,];++ const rootInstanceIds = fragment.children+ .filter((child) => child.type === "id")+ .map((child) => child.value);+const dropTarget = findClosestDroppableTarget(metas,$instances.get(),instanceSelector,computeInstancesConstraints(metas, newInstances, rootInstanceIds));+if (dropTarget === undefined) {return false;}- insertTemplateData(fragment, dropTarget);++ updateWebstudioData((data) => {+ const { newInstanceIds } = insertWebstudioFragmentCopy({+ data,+ fragment,+ availableDataSources: findAvailableDataSources(+ data.dataSources,+ data.instances,+ instanceSelector+ ),+ });++ const children = fragment.children+ .map((child) => {+ if (child.type === "id") {+ const value = newInstanceIds.get(child.value);+ if (value) {+ return { type: "id" as const, value };+ }+ }+ })+ .filter(<T>(value: T): value is NonNullable<T> => value !== undefined);++ insertInstanceChildrenMutable(data, children, dropTarget);+ });+return true;};diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/schema.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/schema.tsindex 1f982642e8..dc3504b89d 100644--- a/apps/builder/app/shared/copy-paste/plugin-webflow/schema.ts+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/schema.ts@@ -1,6 +1,9 @@import { z } from "zod";+const Attr = z.object({ id: z.string() }).partial();+const WfNodeData = z.object({+ attr: Attr.optional(),xattr: z.array(z.object({ name: z.string(), value: z.string() })).optional(),});@@ -10,6 +13,7 @@ const WfBaseNode = z.object({children: z.array(z.string()),classes: z.array(z.string()),data: WfNodeData.optional(),+ attr: Attr.optional(),});const WfTextNode = z.object({@@ -43,19 +47,36 @@ export const wfNodeTypes = ["CodeBlock","HtmlEmbed","Image",+ "FormWrapper",+ "FormForm",+ "FormSuccessMessage",+ "FormErrorMessage",+ "FormButton",+ "FormTextInput",+ "FormTextarea",+ "FormBlockLabel",+ "FormCheckboxWrapper",+ "FormCheckboxInput",+ "FormInlineLabel",+ "FormRadioWrapper",+ "FormRadioInput",] as const;export const WfElementNode = z.union([WfBaseNode.extend({ type: z.enum(["Heading"]) }),WfBaseNode.extend({type: z.enum(["Block"]),- data: WfNodeData.extend({ text: z.boolean().optional() }).optional(),+ data: WfNodeData.extend({+ attr: Attr.optional(),+ text: z.boolean().optional(),+ }).optional(),}),WfBaseNode.extend({ type: z.enum(["List"]) }),WfBaseNode.extend({ type: z.enum(["ListItem"]) }),WfBaseNode.extend({type: z.enum(["Link"]),data: WfNodeData.extend({+ attr: Attr.optional(),block: z.enum(["inline", "block", ""]).optional(),button: z.boolean().optional(),link: z.object({@@ -83,6 +104,7 @@ export const WfElementNode = z.union([WfBaseNode.extend({type: z.enum(["CodeBlock"]),data: WfNodeData.extend({+ attr: Attr.optional(),language: z.string().optional(),code: z.string(),}),@@ -91,11 +113,10 @@ export const WfElementNode = z.union([type: z.enum(["HtmlEmbed"]),v: z.string(),}),-WfBaseNode.extend({type: z.enum(["Image"]),data: WfNodeData.extend({- attr: z.object({+ attr: Attr.extend({alt: z.string(),loading: z.enum(["lazy", "eager", "auto"]),src: z.string(),@@ -104,12 +125,102 @@ export const WfElementNode = z.union([}),}),}),+ WfBaseNode.extend({ type: z.enum(["FormWrapper"]) }),+ WfBaseNode.extend({+ type: z.enum(["FormForm"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ action: z.string(),+ method: z.string(),+ name: z.string(),+ }),+ }),+ }),+ WfBaseNode.extend({ type: z.enum(["FormSuccessMessage"]) }),+ WfBaseNode.extend({ type: z.enum(["FormErrorMessage"]) }),+ WfBaseNode.extend({+ type: z.enum(["FormButton"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ value: z.string(),+ }),+ }),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormTextInput"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ name: z.string(),+ maxlength: z.number(),+ placeholder: z.string(),+ disabled: z.boolean(),+ type: z.string(),+ required: z.boolean(),+ autofocus: z.boolean(),+ }),+ }),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormTextarea"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ name: z.string(),+ maxlength: z.number(),+ placeholder: z.string(),+ required: z.boolean(),+ autofocus: z.boolean(),+ }),+ }),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormBlockLabel"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ for: z.string().optional(),+ }),+ }),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormCheckboxWrapper"]),+ }),++ WfBaseNode.extend({+ type: z.enum(["FormCheckboxInput"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ type: z.enum(["checkbox"]),+ name: z.string(),+ required: z.boolean(),+ checked: z.boolean(),+ }),+ }),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormInlineLabel"]),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormRadioWrapper"]),+ }),+ WfBaseNode.extend({+ type: z.enum(["FormRadioInput"]),+ data: WfNodeData.extend({+ attr: Attr.extend({+ type: z.enum(["radio"]),+ name: z.string(),+ required: z.boolean(),+ value: z.string(),+ }),+ }),+ }),]);export type WfElementNode = z.infer<typeof WfElementNode>;[...wfNodeTypes] as const satisfies WfElementNode["type"][];+//@todo verify the other way around too+//(typeof WfElementNode)["type"] satisfies typeof wfNodeTypes[number]+export const WfNode = z.union([WfElementNode, WfTextNode]);export type WfNode = z.infer<typeof WfNode>;@@ -121,7 +232,16 @@ export const WfStyle = z.object({fake: z.boolean().optional(),comb: z.string().optional(),namespace: z.string().optional(),- variants: z.object({}).optional(),+ variants: z+ .object({+ large: z.object({ styleLess: z.string() }).optional(),+ medium: z.object({ styleLess: z.string() }).optional(),+ small: z.object({ styleLess: z.string() }).optional(),+ tiny: z.object({ styleLess: z.string() }).optional(),+ xl: z.object({ styleLess: z.string() }).optional(),+ xxl: z.object({ styleLess: z.string() }).optional(),+ })+ .optional(),children: z.array(z.string()).optional(),createdBy: z.string().optional(),origin: z.null().optional(),diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/style-presets.css b/apps/builder/app/shared/copy-paste/plugin-webflow/style-presets.cssindex f07ecfc05b..a6603672a7 100644--- a/apps/builder/app/shared/copy-paste/plugin-webflow/style-presets.css+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/style-presets.css@@ -2225,3 +2225,64 @@ textarea.w-select {top: 0;left: 0;}++.w-checkbox {+ margin-bottom: 5px;+ padding-left: 20px;+ display: block;+}++.w-checkbox:before {+ content: " ";+ grid-area: 1 / 1 / 2 / 2;+ display: table;+}++.w-checkbox:after {+ content: " ";+ clear: both;+ grid-area: 1 / 1 / 2 / 2;+ display: table;+}++.w-checkbox-input {+ float: left;+ margin: 4px 0 0 -20px;+ line-height: normal;+}++.w-checkbox-input--inputType-custom {+ border: 1px solid #ccc;+ border-radius: 2px;+ width: 12px;+ height: 12px;+}++.w-checkbox-input--inputType-custom.w--redirected-checked {+ background-color: #3898ec;+ background-image: url("https://d3e54v103j8qbb.cloudfront.net/static/custom-checkbox-checkmark.589d534424.svg");+ background-position: 50%;+ background-repeat: no-repeat;+ background-size: cover;+ border-color: #3898ec;+}++.w-checkbox-input--inputType-custom.w--redirected-focus {+ box-shadow: 0 0 3px 1px #3898ec;+}++.w-form-formradioinput--inputType-custom {+ border: 1px solid #ccc;+ border-radius: 50%;+ width: 12px;+ height: 12px;+}++.w-form-formradioinput--inputType-custom.w--redirected-focus {+ box-shadow: 0 0 3px 1px #3898ec;+}++.w-form-formradioinput--inputType-custom.w--redirected-checked {+ border-width: 4px;+ border-color: #3898ec;+}diff --git a/apps/builder/app/shared/copy-paste/plugin-webflow/styles.ts b/apps/builder/app/shared/copy-paste/plugin-webflow/styles.tsindex ead4e452d1..fda7a709f1 100644--- a/apps/builder/app/shared/copy-paste/plugin-webflow/styles.ts+++ b/apps/builder/app/shared/copy-paste/plugin-webflow/styles.ts@@ -1,27 +1,148 @@-import type { Instance, WebstudioFragment } from "@webstudio-is/sdk";+import type {+ Breakpoint,+ Breakpoints,+ Instance,+ WebstudioFragment,+} from "@webstudio-is/sdk";import type { WfElementNode, WfNode, WfStyle } from "./schema";import { nanoid } from "nanoid";import { $breakpoints } from "~/shared/nano-states";-import { isBaseBreakpoint } from "~/shared/breakpoints";import { parseCss } from "@webstudio-is/css-data";// @todo this should be movedimport type { EmbedTemplateStyleDecl } from "@webstudio-is/react-sdk";-import { toast } from "@webstudio-is/design-system";import { kebabCase } from "change-case";+import { equalMedia } from "@webstudio-is/css-engine";+import { isBaseBreakpoint } from "~/shared/breakpoints";+import type { Styles as WfStylePresets } from "./__generated__/style-presets";+import { builderApi } from "~/shared/builder-api";++const { toast } = builderApi;++type WfBreakpoint = { minWidth?: number; maxWidth?: number };++type WfBreakpointName =+ | "base"+ | "xxl"+ | "xl"+ | "large"+ | "medium"+ | "small"+ | "tiny";-const addNodeStyles = (- name: string,- styles: Array<EmbedTemplateStyleDecl>,- instanceId: Instance["id"],+const wfBreakpoints = new Map<WfBreakpointName, WfBreakpoint>([+ ["base", {}],+ ["xxl", { minWidth: 1920 }],+ ["xl", { minWidth: 1440 }],+ ["large", { minWidth: 1280 }],+ ["medium", { maxWidth: 991 }],+ ["small", { maxWidth: 767 }],+ ["tiny", { maxWidth: 479 }],+]);++const findWsBreakpoint = (+ wfBreakpoint: WfBreakpoint,+ breakpoints: Breakpoints+) => {+ return Array.from($breakpoints.get().values()).find((breakpoint) => {+ return equalMedia(breakpoint, wfBreakpoint);+ });+};++type UnparsedVariants = Map<+ WfBreakpointName,+ string | Array<EmbedTemplateStyleDecl>+>;++// Variants value can be wf styleLess string which is a styles block+// or it can be an array of EmbedTemplateStyleDecl.+// If its an array, convert it to ws style decl.+const toParsedVariants = (variants: UnparsedVariants) => {+ const parsedVariants = new Map<+ WfBreakpointName,+ Array<EmbedTemplateStyleDecl>+ >();++ for (const [breakpointName, styles] of variants) {+ if (typeof styles === "string") {+ try {+ const parsed = parseCss(`.styles {${styles}}`).styles ?? [];+ parsedVariants.set(breakpointName, parsed);+ } catch (error) {+ console.error("Failed to parse style", error, breakpointName, styles);+ }+ continue;+ }+ parsedVariants.set(breakpointName, styles);+ }++ return parsedVariants;+};++type BreakpointsByWfName = Map<WfBreakpointName, Breakpoint>;++const addBreakpoints = (+ breakpoints: Breakpoints,fragment: WebstudioFragment) => {- const breakpointId = Array.from($breakpoints.get().values()).find(- isBaseBreakpoint- )?.id;- if (breakpointId === undefined) {- console.error("No base breakpoint found - should never happen");- return;+ const add = (newBreakpoint: Breakpoint) => {+ const breakpoint = fragment.breakpoints.find((breakpoint) => {+ return equalMedia(breakpoint, newBreakpoint);+ });+ if (breakpoint === undefined) {+ fragment.breakpoints.push(newBreakpoint);+ }+ };+ // Creates a map of wf breakpoint name to ws breakpoint config:+ const wfBreakpointNameToId: BreakpointsByWfName = new Map();+ for (const [wfBreakpointName, wfBreakpoint] of wfBreakpoints) {+ if (wfBreakpointName === "base") {+ const baseBreakpoint = Array.from(breakpoints.values()).find(+ isBaseBreakpoint+ );+ if (baseBreakpoint) {+ wfBreakpointNameToId.set(wfBreakpointName, baseBreakpoint);+ add(baseBreakpoint);+ }+ continue;+ }++ const wsBreakpoint = findWsBreakpoint(wfBreakpoint, breakpoints);+ if (wsBreakpoint) {+ wfBreakpointNameToId.set(wfBreakpointName, wsBreakpoint);+ add(wsBreakpoint);+ continue;+ }+ const newBreakpoint: Breakpoint = {+ id: nanoid(),+ label: wfBreakpointName,+ ...(wfBreakpoint.minWidth !== undefined && {+ minWidth: wfBreakpoint.minWidth,+ }),+ ...(wfBreakpoint.maxWidth !== undefined && {+ maxWidth: wfBreakpoint.maxWidth,+ }),+ };++ add(newBreakpoint);+ wfBreakpointNameToId.set(wfBreakpointName, newBreakpoint);}+ return wfBreakpointNameToId;+};++const addNodeStyles = ({+ name,+ variants,+ instanceId,+ fragment,+ breakpointsByName,+}: {+ name: string;+ variants: UnparsedVariants;+ instanceId: Instance["id"];+ fragment: WebstudioFragment;+ breakpointsByName: BreakpointsByWfName;+}) => {+ const parsedVariants = toParsedVariants(variants);const styleSourceId = nanoid();fragment.styleSources.push({@@ -39,25 +160,40 @@ const addNodeStyles = (}styleSourceSelection.values.push(styleSourceId);- for (const style of styles) {- fragment.styles.push({- styleSourceId,- breakpointId,- property: style.property,- value: style.value,- state: style.state,- });- if (style.value.type === "invalid") {- const error = `Invalid style value: "${kebabCase(style.property)}: ${style.value.value}"`;- toast.error(error);- console.error(error);+ for (const [breakpointName, styles] of parsedVariants) {+ const breakpoint = breakpointsByName.get(breakpointName);+ if (breakpoint === undefined) {+ console.error(`No breakpoint found for ${breakpointName}`);+ continue;+ }++ for (const style of styles) {+ fragment.styles.push({+ styleSourceId,+ breakpointId: breakpoint.id,+ property: style.property,+ value: style.value,+ state: style.state,+ });+ if (style.value.type === "invalid") {+ const error = `Invalid style value: "${kebabCase(style.property)}: ${style.value.value}"`;+ toast.error(error);+ console.error(error);+ }}}};-const mapComponentAndPresetStyles = (wfNode: WfElementNode) => {+const mapComponentAndPresetStyles = (+ wfNode: WfElementNode,+ stylePresets: WfStylePresets+) => {const component = wfNode.type;- const presetStyles = [wfNode.tag];+ const presetStyles: Array<keyof WfStylePresets> = [];++ if (wfNode.tag in stylePresets) {+ presetStyles.push(wfNode.tag as keyof typeof stylePresets);+ }switch (component) {case "Link": {@@ -78,10 +214,6 @@ const mapComponentAndPresetStyles = (wfNode: WfElementNode) => {presetStyles.push("w-embed");return presetStyles;}- //case "Form": {- // presetStyles.push("w-form");- // return presetStyles;- //}case "BlockContainer": {presetStyles.push("w-container");return presetStyles;@@ -94,6 +226,39 @@ const mapComponentAndPresetStyles = (wfNode: WfElementNode) => {presetStyles.push("w-col");return presetStyles;}+ case "FormWrapper": {+ presetStyles.push("w-form");+ return presetStyles;+ }+ case "FormTextInput":+ case "FormTextarea": {+ presetStyles.push("w-input");+ return presetStyles;+ }+ case "FormButton": {+ presetStyles.push("w-button");+ return presetStyles;+ }+ case "FormCheckboxWrapper": {+ presetStyles.push("w-checkbox");+ return presetStyles;+ }+ case "FormCheckboxInput": {+ presetStyles.push("w-checkbox-input");+ return presetStyles;+ }+ case "FormInlineLabel": {+ presetStyles.push("w-form-label");+ return presetStyles;+ }+ case "FormRadioWrapper": {+ presetStyles.push("w-radio");+ return presetStyles;+ }+ case "FormRadioInput": {+ presetStyles.push("w-radio-input");+ return presetStyles;+ }}return presetStyles;@@ -102,28 +267,38 @@ const mapComponentAndPresetStyles = (wfNode: WfElementNode) => {export const addStyles = async (wfNodes: Map<WfNode["_id"], WfNode>,wfStyles: Map<WfStyle["_id"], WfStyle>,- added: Map<WfNode["_id"], Instance["id"]>,+ doneNodes: Map<WfNode["_id"], Instance["id"] | false>,fragment: WebstudioFragment) => {- const { default: presets } = await import("./__generated__/style-presets");+ const { styles: stylePresets } = await import(+ "./__generated__/style-presets"+ );for (const wfNode of wfNodes.values()) {if ("text" in wfNode) {continue;}- const instanceId = added.get(wfNode._id);+ const instanceId = doneNodes.get(wfNode._id);+ if (instanceId === false) {+ continue;+ }if (instanceId === undefined) {console.error(`No instance id found for node ${wfNode._id}`);continue;}- mapComponentAndPresetStyles(wfNode).forEach((name) => {- const styles = presets[- name as keyof typeof presets- ] as Array<EmbedTemplateStyleDecl>;- if (styles) {- addNodeStyles(name, styles, instanceId, fragment);- }+ const breakpointsByName = addBreakpoints($breakpoints.get(), fragment);++ mapComponentAndPresetStyles(wfNode, stylePresets).forEach((name) => {+ addNodeStyles({+ name,+ variants: new Map([+ ["base", stylePresets[name] as Array<EmbedTemplateStyleDecl>],+ ]),+ instanceId,+ fragment,+ breakpointsByName,+ });});const instance = fragment.instances.find(@@ -140,15 +315,25 @@ export const addStyles = async (if (style === undefined) {continue;}- try {- const styles = parseCss(`.styles {${style.styleLess}}`).styles ?? [];- if (instance && instance.label === undefined) {- instance.label = style.name;- }- addNodeStyles(style.name, styles, instanceId, fragment);- } catch (error) {- console.error("Failed to parse style", error, style);+ if (instance && instance.label === undefined) {+ instance.label = style.name;}+ const variants = new Map();+ variants.set("base", style.styleLess);+ const wfVariants = style.variants ?? {};+ Object.keys(wfVariants).forEach((breakpointName) => {+ const variant = wfVariants[breakpointName as keyof typeof wfVariants];+ if (variant && "styleLess" in variant) {+ variants.set(breakpointName, variant.styleLess);+ }+ });+ addNodeStyles({+ name: style.name,+ variants,+ instanceId,+ fragment,+ breakpointsByName,+ });}}};diff --git a/packages/css-data/bin/css-to-ws.ts b/packages/css-data/bin/css-to-ws.tsindex 2bd14dd207..db71c9c872 100755--- a/packages/css-data/bin/css-to-ws.ts+++ b/packages/css-data/bin/css-to-ws.ts@@ -24,7 +24,8 @@ const parsed = parseCss(css);mkdirSync(path.dirname(destinationPath), { recursive: true });const code = `/* eslint-disable *//* This file was generated by css-to-ws.ts */-export default ${JSON.stringify(parsed, null, 2)};`;+export const styles = ${JSON.stringify(parsed, null, 2)};+export type Styles = typeof styles;`;writeFileSync(destinationPath, code, "utf8");console.info("✅ CSS parsed and Webstudio Data generated");diff --git a/packages/sdk/src/jsx.ts b/packages/sdk/src/jsx.tsindex 589feb736e..64e6a585a2 100644--- a/packages/sdk/src/jsx.ts+++ b/packages/sdk/src/jsx.ts@@ -76,7 +76,7 @@ export const renderJsx = (root: JSX.Element) => {traverseJsx(root, (element, children) => {const instanceId = element.props?.["ws:id"] ?? getId(element);for (const [name, value] of Object.entries({ ...element.props })) {- if (name === "ws:id" || name === "children") {+ if (name === "ws:id" || name === "ws:label" || name === "children") {continue;}const propId = `${instanceId}:${name}`;@@ -120,6 +120,9 @@ export const renderJsx = (root: JSX.Element) => {type: "instance",id: instanceId,component,+ ...(element.props?.["ws:label"]+ ? { label: element.props?.["ws:label"] }+ : undefined),children: children.map((child) =>typeof child === "string"? { type: "text", value: child }