diff --git a/src/polyfills.ts b/src/polyfills.ts index a5d20e2715c4442f0c83530a3cf352b11dc8b832..7992435c173d6df6f77163ce4deedb3276c40c0b 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -78,3 +78,21 @@ import "zone.js/dist/zone"; // Included with Angular CLI. // Requis pour Buffer dans jalhyd (!?) (window as any).global = window; global.Buffer = global.Buffer || require("buffer").Buffer; + +// Edge polyfill for canvas.toBlob method +if (!HTMLCanvasElement.prototype.toBlob) { + Object.defineProperty(HTMLCanvasElement.prototype, "toBlob", { + value: function (callback, type, quality) { + const dataURL = this.toDataURL(type, quality).split(",")[1]; + setTimeout(function() { + const binStr = atob( dataURL ), + len = binStr.length, + arr = new Uint8Array(len); + for (let i = 0; i < len; i++ ) { + arr[i] = binStr.charCodeAt(i); + } + callback( new Blob( [arr], {type: type || "image/png"} ) ); + }); + } + }); + }