From f1f54604f5fcf538d6a53f3f06f7ab2f561eefba Mon Sep 17 00:00:00 2001 From: Ivan Borshchov Date: Wed, 14 Apr 2021 23:40:31 +0300 Subject: [PATCH] add fallback to webkitURL when investigated #130 --- build/index.html | 13 +++++++------ js/inserter.js | 1 + js/main.js | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build/index.html b/build/index.html index 6d3aa33..fdd8d9e 100644 --- a/build/index.html +++ b/build/index.html @@ -82,14 +82,14 @@ // window.p2 = Painterro({id: "test-2"}).show() window.p = Painterro({ - hideByEsc: true, - saveByEnter: true, - shadowScale: 1, + // hideByEsc: true, + // saveByEnter: true, + // shadowScale: 1, id: 'app', // backplateImgUrl: 'https://images.pexels.com/photos/4386297/pexels-photo-4386297.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940', // toolbarHeightPx: 50, // buttonSizePx: 42, - // defaultTool: 'arrow', + /* // defaultTool: 'arrow', onChange: (e) => {console.log('onchange e', e)}, onUndo: (e) => {console.log('onUndo e', e)}, onRedo: (e) => {console.log('onRedo e', e)}, @@ -104,6 +104,7 @@ onImageFailedOpen: () => { console.log('open new image'); }, + */ // language: 'ja', //availableLineWidths: [1,2,4,8,16,64], //availableEraserWidths: [1,2,4,8,16,64], @@ -114,13 +115,13 @@ console.log('saving', saver.getWidth(), saver.getHeight()) console.log('hasAlphaChannel', saver.hasAlphaChannel()) // console.log('Base64', saver.asDataURL()) - //done(true); + done(true); } //toolbarPosition: 'top', // fixMobilePageReloader: false, // defaultTool: 'line', //hiddenTools: ['line'] - }).show() + }).show('https://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Gutenberg.jpg/300px-Gutenberg.jpg?12') const ctx = window.p.ctx; // ctx.beginPath(); diff --git a/js/inserter.js b/js/inserter.js index cff5333..9a9b630 100644 --- a/js/inserter.js +++ b/js/inserter.js @@ -204,6 +204,7 @@ export default class Inserter { this.main.params.onImageFailedOpen(); } }; + // img.crossOrigin = '*'; img.src = source; if (!empty) { if (Object.keys(this.activeOption).length !== 1) { diff --git a/js/main.js b/js/main.js index 1191b92..5b05b86 100644 --- a/js/main.js +++ b/js/main.js @@ -1153,7 +1153,7 @@ class PainterroProc { return; } this.loadedName = trim((f.name || '').replace(/\..+$/, '')); - const dataUrl = URL.createObjectURL(f); + const dataUrl = (window.URL ? window.URL : window.webkitURL).createObjectURL(f); this.loadImage(dataUrl, f.type); }