Skip to content

Commit 8608ee2

Browse files
[FIX] export: image charts as base64
During the split of the model, we changed the way the image generated for charts were handled. It worked well, except when exporting with Odoo because the zipping is done server side and the image definition was only available server side though URL.createObjectIrl() This fix uses the standard fileReader to obtrain a true base64 image as text, like before closes #7439 Task: 5253880 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent 8a5c1ba commit 8608ee2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/o-spreadsheet-engine/src/helpers/figures/charts/chart_ui_common.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ async function canvasToObjectUrl(canvas: OffscreenCanvas): Promise<string | unde
127127
if (!blob) {
128128
return undefined;
129129
}
130-
if (!URL.createObjectURL)
131-
throw new Error("URL.createObjectURL is not supported in this environment");
132-
return URL.createObjectURL(blob);
130+
return new Promise((resolve) => {
131+
const f = new FileReader();
132+
f.addEventListener("load", () => {
133+
resolve(f.result as string);
134+
});
135+
f.readAsDataURL(blob);
136+
});
133137
}

0 commit comments

Comments
 (0)