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
fix batch publish and parse css values
Sultand761ce9c4da2
diff --git a/apps/designer/app/designer/features/style-panel/shared/lock.tsx b/apps/designer/app/designer/features/style-panel/shared/lock.tsxindex 09109bde07..6fb9964107 100644--- a/apps/designer/app/designer/features/style-panel/shared/lock.tsx+++ b/apps/designer/app/designer/features/style-panel/shared/lock.tsx@@ -17,21 +17,25 @@ export const Lock = ({}) => {const aKey = pairedKeys[0];const bKey = pairedKeys[1];- const aVal = parseFloat(currentStyle[aKey]?.value as string);- const bVal = parseFloat(currentStyle[bKey]?.value as string);+ const a = currentStyle[aKey];+ const b = currentStyle[bKey];+ const aVal =+ a?.value + (a?.type === "unit" && a.unit !== "number" ? a.unit : "");+ const bVal =+ b?.value + (b?.type === "unit" && b.unit !== "number" ? b.unit : "");const [isPaired, setIsPaired] = useState(aVal === bVal);useEffect(() => {if (!isPaired) return;if (aVal === bVal) return;- batchUpdate.setProperty(aKey)(String(aVal));- batchUpdate.setProperty(bKey)(String(aVal));+ batchUpdate.setProperty(aKey)(aVal);+ batchUpdate.setProperty(bKey)(aVal);batchUpdate.publish();- }, [batchUpdate, isPaired, aKey, bKey, aVal, bVal]);+ }, [aKey, bKey, aVal, bVal, isPaired, batchUpdate]);return (<Tooltip- content={isPaired ? "Locked" : "Unlocked"}+ content={isPaired ? "Unlock" : "Lock"}delayDuration={400}disableHoverableContent={true}>diff --git a/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts b/apps/designer/app/designer/features/style-panel/shared/parse-css-value.tsindex 71fa329dab..527547ced0 100644--- a/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts+++ b/apps/designer/app/designer/features/style-panel/shared/parse-css-value.ts@@ -14,6 +14,7 @@ const isValid = (property: string, value: string): boolean => {return true;}+ console.log(hyphenate(property), value);try {CSSStyleValue.parse(hyphenate(property), value);} catch (error) {@@ -64,7 +65,6 @@ export const parseCssValue = (type: "invalid",value: input,} as const;-if (input.length === 0) {return invalidValue;}@@ -88,13 +88,9 @@ export const parseCssValue = (const fallbackUnit: Unit = defaultUnit ?? "number";const [unit] = parsedUnit || [fallbackUnit];- if (isValid(property, number) || isValid(property, number + unit)) {- return {- type: "unit",- unit,- value: number,- };- }-- return invalidValue;+ return {+ type: "unit",+ unit: isValid(property, number + unit.replace("number", "")) ? unit : "px",+ value: number,+ };};diff --git a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts b/apps/designer/app/designer/features/style-panel/shared/use-style-data.tsindex a3d5658df5..5b7e21db36 100644--- a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts+++ b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts@@ -115,7 +115,7 @@ export const useStyleData = ({};const createBatchUpdate = () => {- const updates: StyleUpdates["updates"] = [];+ let updates: StyleUpdates["updates"] = [];const setProperty = (property: StyleProperty) => {const setValue = (input: string) => {@@ -129,6 +129,7 @@ export const useStyleData = ({};const publish = () => {+ if (!updates.length) return;publishUpdates("update", updates);const nextStyle = updates.reduce((currentStyle, { property, value }) => {@@ -137,6 +138,7 @@ export const useStyleData = ({},{ ...currentStyle });+ updates = [];setCurrentStyle(nextStyle);};