File tree Expand file tree Collapse file tree 1 file changed +7
-20
lines changed Expand file tree Collapse file tree 1 file changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -714,36 +714,23 @@ export class TipTapEditorBase extends BaseElement {
714
714
if ( event == null ) return ;
715
715
716
716
const { clipboardData } = event ;
717
- console . log ( event )
718
717
719
718
if ( clipboardData == null ) return ;
720
719
721
720
const hasFiles = clipboardData . files ?. length > 0 ;
722
721
723
722
if ( ! hasFiles && clipboardData . items ?. length > 0 ) {
724
723
event . preventDefault ( ) ;
725
- const data = clipboardData . items
726
- let promises : Promise < string > [ ] = [ ]
727
- for ( let i = 0 ; i < data . length ; i += 1 ) {
728
- promises . push ( new Promise < string > ( ( resolve ) => {
729
- const item = data [ i ]
730
- if ( item . kind === "string" && item . type . match ( "^text" ) ) {
731
- item . getAsString ( ( str ) => {
732
- resolve ( str )
733
- } )
734
- }
735
- } ) )
724
+
725
+ let dataType = "text/plain"
726
+
727
+ if ( clipboardData . types . includes ( "text/html" ) ) {
728
+ dataType = "text/html"
736
729
}
737
730
738
- const strings : string [ ] = [ ]
739
- const settledPromises = await Promise . allSettled ( promises )
740
- settledPromises . forEach ( ( promise ) => {
741
- if ( promise . status === "fulfilled" ) {
742
- strings . push ( promise . value )
743
- }
744
- } )
731
+ const string = clipboardData . getData ( dataType )
745
732
746
- this . editor . chain ( ) . focus ( ) . insertContent ( strings . join ( " " ) ) . run ( )
733
+ this . editor . chain ( ) . focus ( ) . insertContent ( string ) . run ( )
747
734
return ;
748
735
}
749
736
You can’t perform that action at this time.
0 commit comments