undeadinu
1/10/2019 - 2:48 PM

Paste SVG to Paper.js from clipboard

Paste SVG to Paper.js from clipboard

//CC2018
document.addEventListener('paste', function(evt) {
    //Import SVG copied to clipboard from Illustrator
    //remove last hidden character that will otherwise break the import
    if(document.activeElement.nodeName!="TEXTAREA"){
        var str=evt.clipboardData.getData('text/plain').slice(0, -1);
        var svg=project.importSVG(str)
        svg.clipped=false;
        svg.children[0].remove()
        svg.parent.insertChildren(svg.index,svg.removeChildren());
        svg.remove();
    }
})
//CC2019
document.addEventListener('paste', function(evt) {
    if(document.activeElement.nodeName!="TEXTAREA"){
        var svg=project.importSVG( evt.clipboardData.getData('text/plain') )
        svg.clipped=false;
        svg.children[0].remove()
        svg.parent.insertChildren(svg.index,svg.removeChildren());
        svg.remove();
    }
})