Fix cannot copy & paste base64 image as inline image in composer web

This commit is contained in:
dab246
2024-08-19 19:53:01 +07:00
committed by Dat H. Pham
parent a5a8d42763
commit b27eaed659
10 changed files with 138 additions and 29 deletions
@@ -1,7 +1,4 @@
import 'dart:convert' as convert;
import 'dart:typed_data' as type_data;
import 'package:flutter/foundation.dart';
import 'package:html_editor_enhanced/utils/file_upload_model.dart';
import 'package:model/upload/file_info.dart';
@@ -23,22 +20,17 @@ extension FileUploadExtension on FileUpload {
return base64;
}
Future<FileInfo?> toFileInfo() async {
FileInfo? toFileInfo() {
if (base64Data != null) {
final bytes = await compute(convertBase64ToBytes, base64Data!);
return FileInfo.fromBytes(
bytes: bytes,
bytes: convert.base64Decode(base64Data!),
name: name,
size: size,
type: type,
isInline: true
);
} else {
return null;
}
}
static Uint8List convertBase64ToBytes(String base64) {
type_data.Uint8List decodeBytes = convert.base64Decode(base64);
return decodeBytes;
}
}