Add demo artwork

This commit is contained in:
Keavon Chambers
2023-08-22 03:26:59 -07:00
parent 0e97a256b7
commit 0dcfafbf64
33 changed files with 2133 additions and 1050 deletions
+14 -1
View File
@@ -8,10 +8,10 @@ import { type Editor } from "@graphite/wasm-communication/editor";
import {
type FrontendDocumentDetails,
TriggerCopyToClipboardBlobUrl,
TriggerFetchAndOpenDocument,
TriggerDownloadBlobUrl,
TriggerDownloadRaster,
TriggerDownloadTextFile,
TriggerImaginateCheckServerStatus,
TriggerImport,
TriggerOpenDocument,
TriggerRasterizeRegionBelowLayer,
@@ -45,6 +45,19 @@ export function createPortfolioState(editor: Editor) {
return state;
})
});
editor.subscriptions.subscribeJsMessage(TriggerFetchAndOpenDocument, async (triggerFetchAndOpenDocument) => {
try {
const url = new URL(triggerFetchAndOpenDocument.url);
const data = await fetch(url);
const filename = url.pathname.split("/").pop() || "Untitled";
const content = await data.text();
editor.instance.openDocumentFile(filename, content);
} catch {
editor.instance.errorDialog("Failed to open document", "The file could not be reached over the internet. You may be offline, or it may be missing.");
}
});
editor.subscriptions.subscribeJsMessage(TriggerOpenDocument, async () => {
const extension = editor.instance.fileSaveSuffix();
const data = await upload(extension, "text");