feat(editor): duplicate annotations#342
feat(editor): duplicate annotations#342siddharthvaddem merged 6 commits intosiddharthvaddem:mainfrom
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR implements annotation duplication functionality across three components. A new "Duplicate" button is added to the AnnotationSettingsPanel alongside the delete button. The feature threads an optional callback through SettingsPanel and implements duplication logic in VideoEditor that creates a new annotation with copied styling, incremented zIndex, and offset position. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/video-editor/AnnotationSettingsPanel.tsx`:
- Around line 603-613: The "Duplicate" button in AnnotationSettingsPanel is
hardcoded and must be localized; replace the literal "Duplicate" string inside
the Button (the element with onClick={() => onDuplicate?.()} and className...)
with the component's i18n call (the same translation helper used elsewhere in
this file, e.g., t('...') or useTranslations('...')) using the appropriate
translation key (e.g., "duplicate" or "annotation.duplicate"), and add that key
to the project's locale files so the label is translated in non-English locales.
In `@src/components/video-editor/VideoEditor.tsx`:
- Around line 834-859: handleAnnotationDuplicate currently increments
nextAnnotationIdRef and nextAnnotationZIndexRef and sets selection even when the
source region isn't found, causing wasted IDs and invalid selection; modify the
flow so you first use pushState to find the source region and only
generate/consume the new duplicateId and duplicateZIndex after confirming the
source exists (or abort without mutating refs), returning the previous state
unchanged if source is missing, and only call
setSelectedAnnotationId(duplicateId) / setSelectedZoomId(null) /
setSelectedTrimId(null) when a duplicate was actually created; you can either
move the id/zIndex increments inside the pushState callback after the source
lookup or detect source absence and skip both state change and selection updates
to avoid no-op history entries and invalid selection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f645b4f1-d924-463b-9d88-8ba84ead134b
📒 Files selected for processing (3)
src/components/video-editor/AnnotationSettingsPanel.tsxsrc/components/video-editor/SettingsPanel.tsxsrc/components/video-editor/VideoEditor.tsx
Signed-off-by: Cocoon-Break <54054995+kuishou68@users.noreply.github.com>
|
@kuishou68 ci fixes 🙏 |
|
Hi @siddharthvaddem! Thanks for the review 🙏 Fixed both Biome lint errors:
Both fixes are in the latest two commits. Should be green now! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/i18n-check.mjs`:
- Around line 36-41: The current compareLocales computed from filesystem entries
ignores the configured SUPPORTED_LOCALES, so missing locale folders can go
unnoticed; update the logic to iterate SUPPORTED_LOCALES (excluding
BASE_LOCALE), check that each locale has a corresponding directory under
LOCALES_DIR, collect missing dirs and non-configured extra dirs, and fail
(throw/exit non-zero) when any configured locale folder is missing; keep
compareLocales as the intersection of SUPPORTED_LOCALES and actual directories
for downstream comparisons and reference the existing symbols SUPPORTED_LOCALES,
BASE_LOCALE, LOCALES_DIR, and compareLocales when implementing these checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3ff1dbbe-3a80-4b8f-a495-8500ba3d458a
📒 Files selected for processing (1)
scripts/i18n-check.mjs
Summary
Closes #167
Adds a Duplicate button to the annotation settings panel, allowing users to quickly clone any selected annotation.
Changes
VideoEditor.tsxhandleAnnotationDuplicate(id)handler that:{ x: +4, y: +4 }so the duplicate is visually distinctsize,style, andfigureData(if present)annotationRegionsviapushStateSettingsPanel.tsxonAnnotationDuplicate?: (id: string) => voidproponDuplicatehandler down toAnnotationSettingsPanelwhen an annotation is selectedAnnotationSettingsPanel.tsxonDuplicate?: () => voidproponDuplicateis absent)Type of Change
Screenshots
Duplicate button appears alongside the existing Delete button in the annotation settings panel.
Testing
Checklist
Summary by CodeRabbit