Commit 3111e67 1 parent 893951c commit 3111e67 Copy full SHA for 3111e67
File tree 2 files changed +26
-2
lines changed
ai-native/src/browser/components
startup/entry/sample-modules/ai-native
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 635
635
display : flex ;
636
636
justify-content : center ;
637
637
align-items : center ;
638
+ background-color : var (--badge-background );
638
639
& :hover {
639
640
cursor : pointer ;
640
641
transform : scale (1.2 );
641
642
}
642
643
:global(.codicon ) {
643
644
font-size : 12px ;
645
+ color : var (--badge-foreground );
644
646
}
645
647
}
646
648
}
Original file line number Diff line number Diff line change @@ -512,8 +512,30 @@ export class AINativeContribution implements AINativeCoreContribution {
512
512
513
513
registerImageUploadProvider ( registry : IImageUploadProviderRegistry ) : void {
514
514
registry . registerImageUploadProvider ( {
515
- imageUpload : async ( file ) =>
516
- 'https://img.alicdn.com/imgextra/i1/O1CN01IhPyCU1JeK3xDkJVv_!!6000000001053-2-tps-180-180.png' ,
515
+ imageUpload : async ( file ) => {
516
+ const base64 = await imageToBase64 ( file ) ;
517
+ return new URL ( base64 ) ;
518
+ } ,
517
519
} ) ;
518
520
}
519
521
}
522
+
523
+ const MAX_IMAGE_SIZE = 3 * 1024 * 1024 ;
524
+
525
+ const imageToBase64 = ( file : File ) =>
526
+ new Promise < string > ( ( resolve , reject ) => {
527
+ if ( file . size > MAX_IMAGE_SIZE ) {
528
+ reject ( new Error ( 'Image size exceeds 3MB limit' ) ) ;
529
+ return ;
530
+ }
531
+
532
+ const reader = new FileReader ( ) ;
533
+ reader . onload = ( ) => {
534
+ const base64String = reader . result as string ;
535
+ resolve ( base64String ) ;
536
+ } ;
537
+ reader . onerror = ( ) => {
538
+ reject ( new Error ( 'Failed to convert image to base64' ) ) ;
539
+ } ;
540
+ reader . readAsDataURL ( file ) ;
541
+ } ) ;
You can’t perform that action at this time.
0 commit comments