Forked from eeropic/paste-svg-from-clipboard-paper.js
Created
August 6, 2019 13:47
-
-
Save druzn3k/51184216d596ba852536467963020d3f to your computer and use it in GitHub Desktop.
Paste SVG to Paper.js from clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment