Try to get the image loading work in the embedded doc preview

By specifying the CORS-friendly github raw url as base url for the interpreter,
we can load images using relative paths.

According to the inspector the image is loaded successfully,
so what seems to be left to fix is an event loop related issue.
This commit is contained in:
Simon Hausmann 2020-10-13 09:31:14 +02:00
parent dbdc8483e2
commit 9f488bba3b
2 changed files with 5 additions and 2 deletions

View file

@ -10,7 +10,8 @@
canvas.id = canvas_id;
div.appendChild(canvas);
try {
sixtyfps.instantiate_from_string(source, document.location.href, canvas_id);
// Use the git repo as the base url, so that we can resolve image urls.
sixtyfps.instantiate_from_string(source, "https://raw.githubusercontent.com/sixtyfpsui/sixtyfps/master/README.md", canvas_id);
} catch (e) {
if (e.message === "Using exceptions for control flow, don't mind me. This isn't actually an error!") {
throw e;

View file

@ -92,7 +92,9 @@ An Image can be used to represent an image loaded from an image file
```60
Example := Image {
source: img!"foo.png";
source: img!"resources/logo_scaled.png";
width: 64lx;
height: 44lx;
}
```