I almost finish my plugin , the last step is save canvas to database as a image link. But I got this error:
Konva error: Unable to get data URL. Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.
This problem related to CORS issue but I don’t know how to apply to my plugin.
I used Konvajs library - https://konvajs.org
This is my plugin action code:
var stage = instance.data.stage;
// function from https://konvajs.org/docs/data_and_serialization/High-Quality-Export.html#How-to-export-a-high-quality-image-from-a-stage
var dataURL = stage.toDataURL({ pixelRatio: 3 });
downloadURI(dataURL, 'stage.png');
// function from https://stackoverflow.com/a/15832662/512042
function downloadURI(uri, name) {
var link = document.createElement('a');
link.download = name;
link.href = uri;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
delete link;
}
And finally, I still have know ideas how to save it to the next step in workflow.