xsrf/easyeda-svg-import

Uncaught TypeError: svgDocument.matchAll(...)

vlrmprjct opened this issue · 8 comments

After selecting a svg file and hit the "Import"-Button , nothing happens.
As you can see in the screenshot below I tried this with different images.

Console Error Output:
Uncaught TypeError: svgDocument.matchAll(...) is not a function or its return value is not iterable

image

xsrf commented

Okay, the regex won't match any <path ... > tags within the svg. I should add a proper error message for that. Can you provide an example svg?

xsrf commented

Thank you. The image you provided consists of a lot of <line ... > segments which are not yet supported. But it also contains three <path ... > segments which import fine for me:

2020-11-24 15_24_50-Window

You can however convert the missing lines to paths using the free software Inkscape. Just open the SVG with Inkscape, select everything (CTRL+A) and then convert outlines to paths (Path -> Stroke to Path; CTRL+ALT+C) and save it. After that, the complete image imports fine for me. I've attached the converted image.

2020-11-24 15_34_08-Window

dd_normalized_out2path.zip

Ok.
Thank you for your response.

But the point is the posted samplefile is a valid SVG and it is created with Inkscape.
So can you please provide some DOES and DONT's for SVGs for a successful import ?

Maybe the readme.md ?

xsrf commented

There is a reference.svg in the root of the project. Also, I cannot reproduce the issue shown in your screenshot even with an empty string loaded as SVG. I guess the browser may be the issue. Are you using the desktop version of EasyEDA? I've actually not tested that yet, I use it with Chrome in the Browser. I've read that the Desktop Version ships with an older Browser version. Maybe that is the issue?

xsrf commented

Okay, confirmed that. The Desktop Version of EasyEDA ships with Chrome/69.0.3497.128 ... String.matchAll() requires at least Chrome/73 which was released in march 2019. So, for now, the extension will only work in the Browser. I'll have a look if I can find some polyfills to make it also work with that old version.

You are right.
It depends on the browser version.
I testet it in the latest Edge Browser and its working fine with the sample svg above without any changes.

xsrf commented

I found some polyfills and fixed the issue with d926c84 ... Now it should also work in the Desktop Client.