@@ -93,9 +93,9 @@ export const TextInput = React.forwardRef(function TextInputImpl(
93
93
}
94
94
} , [ onPressPublish ] )
95
95
React . useEffect ( ( ) => {
96
- textInputWebEmitter . addListener ( 'photo -pasted' , onPhotoPasted )
96
+ textInputWebEmitter . addListener ( 'media -pasted' , onPhotoPasted )
97
97
return ( ) => {
98
- textInputWebEmitter . removeListener ( 'photo -pasted' , onPhotoPasted )
98
+ textInputWebEmitter . removeListener ( 'media -pasted' , onPhotoPasted )
99
99
}
100
100
} , [ onPhotoPasted ] )
101
101
@@ -105,8 +105,8 @@ export const TextInput = React.forwardRef(function TextInputImpl(
105
105
if ( transfer ) {
106
106
const items = transfer . items
107
107
108
- getImageFromUri ( items , ( uri : string ) => {
109
- textInputWebEmitter . emit ( 'photo -pasted' , uri )
108
+ getImageOrVideoFromUri ( items , ( uri : string ) => {
109
+ textInputWebEmitter . emit ( 'media -pasted' , uri )
110
110
} )
111
111
}
112
112
@@ -160,8 +160,8 @@ export const TextInput = React.forwardRef(function TextInputImpl(
160
160
view . pasteText ( text )
161
161
preventDefault = true
162
162
}
163
- getImageFromUri ( clipboardData . items , ( uri : string ) => {
164
- textInputWebEmitter . emit ( 'photo -pasted' , uri )
163
+ getImageOrVideoFromUri ( clipboardData . items , ( uri : string ) => {
164
+ textInputWebEmitter . emit ( 'media -pasted' , uri )
165
165
} )
166
166
if ( preventDefault ) {
167
167
// Return `true` to prevent ProseMirror's default paste behavior.
@@ -346,7 +346,7 @@ const styles = StyleSheet.create({
346
346
} ,
347
347
} )
348
348
349
- function getImageFromUri (
349
+ function getImageOrVideoFromUri (
350
350
items : DataTransferItemList ,
351
351
callback : ( uri : string ) => void ,
352
352
) {
@@ -363,11 +363,21 @@ function getImageFromUri(
363
363
if ( blob . type . startsWith ( 'image/' ) ) {
364
364
blobToDataUri ( blob ) . then ( callback , err => console . error ( err ) )
365
365
}
366
+
367
+ if ( blob . type . startsWith ( 'video/' ) ) {
368
+ blobToDataUri ( blob ) . then ( callback , err => console . error ( err ) )
369
+ }
366
370
}
367
371
} )
368
372
} else if ( type . startsWith ( 'image/' ) ) {
369
373
const file = item . getAsFile ( )
370
374
375
+ if ( file ) {
376
+ blobToDataUri ( file ) . then ( callback , err => console . error ( err ) )
377
+ }
378
+ } else if ( type . startsWith ( 'video/' ) ) {
379
+ const file = item . getAsFile ( )
380
+
371
381
if ( file ) {
372
382
blobToDataUri ( file ) . then ( callback , err => console . error ( err ) )
373
383
}
0 commit comments