tmp.js 592 B

123456789101112131415161718192021222324
  1. import svgToEx from "svg-to-excalidraw";
  2. const heartSVG = `
  3. <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  4. <path d="M 10,30
  5. A 20,20 0,0,1 50,30
  6. A 20,20 0,0,1 90,30
  7. Q 90,60 50,90
  8. Q 10,60 10,30 z"/>
  9. </svg>
  10. `;
  11. const { hasErrors, errors, content } = svgToEx.convert(heartSVG);
  12. // SVG parsing errors are propagated through.
  13. if (hasErrors) {
  14. console.error(errors);
  15. return;
  16. }
  17. navigator.clipboard.writeText(content);
  18. // the heart excalidraw json is now copied to your clipboard.
  19. // Just Paste it into your Excalidraw session!