๐ Fix: Crop Properties Type Compatibility
This PR fixes TypeScript compilation errors related to crop properties in the media properties panel. The main issue was that the updateElementProperties function had incorrect type definitions that didn't properly support the crop property for MediaElement types, causing build failures. Changes made: Fixed type definition for updateElementProperties to properly handle union types (MediaElement & TextElement) Added missing MediaElement import to the timeline store Corrected PropertyItem component usage to use the proper component structure with PropertyItemLabel and PropertyItemValue This ensures that media element crop settings can be properly updated through the properties panel without TypeScript errors. Fixes build compilation errors in the media properties panel. Type of change [x] Bug fix (non-breaking change which fixes an issue) [ ] New feature (non-breaking change which adds functionality) [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) [ ] This change requires a documentation update [ ] Performance improvement [ ] Code refactoring [ ] Tests How Has This Been Tested? [x] Build Test: Verified that npm run build completes successfully without TypeScript errors [x] Type Safety Test: Confirmed that crop properties can be updated without type errors [x] Component Rendering Test: Verified that the media properties panel renders correctly with proper component structure Test Configuration: Node version: Latest (as per project requirements) Browser (if applicable): N/A (build-time fix) Operating System: macOS Screenshots (if applicable) N/A - This is a build/type fix with no visual changes. Checklist: [x] My code follows the style guidelines of this project [x] I have performed a self-review of my code [ ] I have added screenshots if ui has been changed [x] I have commented my code, particularly in hard-to-understand areas [ ] I have made corresponding changes to the documentation [x] My changes generate no new warnings [ ] I have added tests that prove my fix is effective or that my feature works [x] New and existing unit tests pass locally with my changes [x] Any dependent changes have been merged and published in downstream modules
This fix was necessary to ensure the project builds successfully. The crop functionality was already implemented but had type compatibility issues that prevented compilation. The changes maintain backward compatibility while fixing the type system to properly support all media element properties. The fix specifically addresses: Union type handling in the updateElementProperties function Proper component usage patterns for the PropertyItem components Import dependencies for type definitions
Summary by CodeRabbit
-
New Features
- Introduced a comprehensive properties panel for media elements, allowing users to adjust crop, position, scale, rotation, and opacity directly within the editor.
- Media elements now support cropping and transformation controls for more precise editing.
-
Refactor
- Improved code formatting and structure in the preview panel and related components for enhanced readability, with no changes to user-facing behavior.
- Enhanced timeline element property updates for seamless editing across tracks.
-
Style
- Minor update to internal string formatting (not visible to users).
Deploy request for appcut pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | 2ab7609b610831bbd60d5abb90e93242c6c62d01 |
@FirasLatrech is attempting to deploy a commit to the OpenCut OSS Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
This update introduces a comprehensive implementation of the MediaProperties panel for editing media element properties, adds support for crop and transform attributes in media elements, and provides a generic method for updating timeline element properties. Additionally, code style and formatting are standardized in the PreviewPanel and related components, with minor string literal changes in FFmpeg utilities.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Media Properties Panel Implementationapps/web/src/components/editor/properties-panel/media-properties.tsx |
Replaces placeholder with a full-featured React component for editing media element properties, including crop and transform controls, real-time updates, and UI enhancements. |
Preview Panel Formatting & Refactorapps/web/src/components/editor/preview-panel.tsx |
Refactors and reformats the PreviewPanel and related subcomponents for consistent style and structure; no functional or behavioral changes to logic, only formatting, indentation, and code clarity improvements. |
Timeline Store Enhancementsapps/web/src/stores/timeline-store.ts |
Adds a generic updateElementProperties method to update properties of timeline elements by ID, supporting both media and text elements, and updates the store interface accordingly. |
Media Element Type Extensionsapps/web/src/types/timeline.ts |
Introduces a new CropSettings interface and extends MediaElement with optional crop, position, scale, rotation, and opacity properties to support advanced editing features. |
FFmpeg Utils Style Fixapps/web/src/lib/ffmpeg-utils.ts |
Changes string literals from double to single quotes in the trimVideo function; no logic or functional changes. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant MediaPropertiesPanel
participant TimelineStore
User->>MediaPropertiesPanel: Adjusts crop/transform sliders
MediaPropertiesPanel->>TimelineStore: updateElementProperties(elementId, newProps)
TimelineStore->>TimelineStore: Update element in all tracks
TimelineStore-->>MediaPropertiesPanel: Store updates
MediaPropertiesPanel-->>User: UI reflects changes
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~20 minutes
Possibly related PRs
- OpenCut-app/OpenCut#483: Refactors
preview-panel.tsxfor style and clarity, overlapping with this PR's formatting changes in the same file and functions, indicating a shared focus on code cleanup in the preview panel component. - OpenCut-app/OpenCut#494: Contains minor syntax and formatting improvements in
preview-panel.tsx, touching similar functions and code areas as this PR, showing related formatting and style refinements.
Poem
A nibble here, a tweak just right,
Crops and transforms now in sight.
With sliders smooth and panels neat,
Media properties feel complete!
The timeline grows with every hopโ
This bunnyโs work will never stop.
๐โจ
[!NOTE]
โก๏ธ Unit Test Generation is now available in beta!
Learn more here, or try it out under "Finishing Touches" below.
๐ Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 8ba6a5d42940621ea0dc2927fbe326d74aa2c1f5 and 2ab7609b610831bbd60d5abb90e93242c6c62d01.
๐ Files selected for processing (3)
apps/web/src/components/editor/preview-panel.tsx(2 hunks)apps/web/src/stores/timeline-store.ts(3 hunks)apps/web/src/types/timeline.ts(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (3)
- apps/web/src/stores/timeline-store.ts
- apps/web/src/components/editor/preview-panel.tsx
- apps/web/src/types/timeline.ts
โจ Finishing Touches
- [ ] ๐ Generate Docstrings
๐งช Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
๐ชง Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
can merge when conflicts are resolved
@mazeincoding conflict fixed.