File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 2525 </ input-container >
2626 < input class ="btn filled blue " type ="submit " value ="Paste " />
2727</ form >
28- < form method ="post " enctype ="multipart/form-data ">
28+ < form method ="post " enctype ="multipart/form-data " id =" file_form " >
2929 < input-container style ="flex-direction:column; gap: 1ex ">
3030 You can also upload a file directly:
3131 < div style ="display: flex; ">
4141 event . target . form ?. submit ( ) ;
4242 }
4343 } ) ;
44+ document . body . addEventListener ( 'paste' , ( event ) => {
45+ if ( event . clipboardData . files . length > 0 ) {
46+ document . querySelector ( "#file" ) . files = event . clipboardData . files
47+ document . querySelector ( "#file_form" ) . submit ( )
48+ }
49+ console . log ( event . clipboardData . files [ 0 ] )
50+ console . log ( event . clipboardData . items [ 0 ] )
51+ if ( event . clipboardData . types . includes ( "Files" ) ) {
52+ let image = event . clipboardData . getData ( "Files" )
53+ console . log ( image ) ;
54+ }
55+ } ) ;
4456</ script >
4557{% endblock %}
You can’t perform that action at this time.
0 commit comments