@@ -987,6 +987,33 @@ export default function VideoEditor() {
987987 [ pushState ] ,
988988 ) ;
989989
990+ const handleAnnotationDuplicate = useCallback (
991+ ( id : string ) => {
992+ const duplicateId = `annotation-${ nextAnnotationIdRef . current ++ } ` ;
993+ const duplicateZIndex = nextAnnotationZIndexRef . current ++ ;
994+ pushState ( ( prev ) => {
995+ const source = prev . annotationRegions . find ( ( region ) => region . id === id ) ;
996+ if ( ! source ) return { } ;
997+
998+ const duplicate : AnnotationRegion = {
999+ ...source ,
1000+ id : duplicateId ,
1001+ zIndex : duplicateZIndex ,
1002+ position : { x : source . position . x + 4 , y : source . position . y + 4 } ,
1003+ size : { ...source . size } ,
1004+ style : { ...source . style } ,
1005+ figureData : source . figureData ? { ...source . figureData } : undefined ,
1006+ } ;
1007+
1008+ return { annotationRegions : [ ...prev . annotationRegions , duplicate ] } ;
1009+ } ) ;
1010+ setSelectedAnnotationId ( duplicateId ) ;
1011+ setSelectedZoomId ( null ) ;
1012+ setSelectedTrimId ( null ) ;
1013+ } ,
1014+ [ pushState ] ,
1015+ ) ;
1016+
9901017 const handleAnnotationDelete = useCallback (
9911018 ( id : string ) => {
9921019 pushState ( ( prev ) => ( {
@@ -1993,6 +2020,7 @@ export default function VideoEditor() {
19932020 onAnnotationTypeChange = { handleAnnotationTypeChange }
19942021 onAnnotationStyleChange = { handleAnnotationStyleChange }
19952022 onAnnotationFigureDataChange = { handleAnnotationFigureDataChange }
2023+ onAnnotationDuplicate = { handleAnnotationDuplicate }
19962024 onAnnotationDelete = { handleAnnotationDelete }
19972025 selectedBlurId = { selectedBlurId }
19982026 blurRegions = { blurRegions }
0 commit comments