🎥 Make videos programmatically with React
Broaden rotation regex to accept all CSS number forms and consolidate units (#6946)
pullfrog[bot]3849482a32a2
diff --git a/packages/studio/src/components/Timeline/TimelineRotationField.tsx b/packages/studio/src/components/Timeline/TimelineRotationField.tsxindex 3367547cf1..908c78c0a6 100644--- a/packages/studio/src/components/Timeline/TimelineRotationField.tsx+++ b/packages/studio/src/components/Timeline/TimelineRotationField.tsx@@ -3,27 +3,19 @@ import type {SchemaFieldInfo} from '../../helpers/timeline-layout';import {InputDragger} from '../NewComposition/InputDragger';import {draggerStyle, getDecimalPlaces} from './timeline-field-utils';-const parseCssRotationToDegrees = (value: string): number => {- const trimmed = value.trim();-- const degMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)deg$/);- if (degMatch) {- return Number(degMatch[1]);- }-- const radMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)rad$/);- if (radMatch) {- return Number(radMatch[1]) * (180 / Math.PI);- }+const unitPattern = /^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/;- const turnMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)turn$/);- if (turnMatch) {- return Number(turnMatch[1]) * 360;- }+const unitToDegrees: Record<string, number> = {+ deg: 1,+ rad: 180 / Math.PI,+ turn: 360,+ grad: 360 / 400,+};- const gradMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)grad$/);- if (gradMatch) {- return Number(gradMatch[1]) * (360 / 400);+const parseCssRotationToDegrees = (value: string): number => {+ const match = value.trim().match(unitPattern);+ if (match) {+ return Number(match[1]) * unitToDegrees[match[2]];}try {