接口: IFUniverDrawingUIMixin
继承于
方法
registerURLImageDownloader()
registerURLImageDownloader(downloader): IDisposableRegister a custom image downloader for URL images
参数
| 参数 | 类型 | 描述 |
|---|---|---|
downloader | (url) => Promise<…> | The downloader function that takes a URL and returns a base64 string |
返回
IDisposable
A disposable object to unregister the downloader
示例
const disposable = univerAPI.registerURLImageDownloader(async (url) => {
const response = await fetch(url);
const blob = await response.blob();
const base64 = await new Promise<string>((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result as string);
reader.readAsDataURL(blob);
});
return base64;
});