mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
Serve the demo artwork in each build (#1494)
* Serve local demo artwork * Disable restricted import lint * Revert * Switch approach to vite-multiple-assets plugin --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
b60736c2c6
commit
af4c793f43
7 changed files with 85 additions and 22 deletions
|
@ -47,15 +47,17 @@ export function createPortfolioState(editor: Editor) {
|
|||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerFetchAndOpenDocument, async (triggerFetchAndOpenDocument) => {
|
||||
try {
|
||||
const url = new URL(triggerFetchAndOpenDocument.url);
|
||||
const { name, filename } = triggerFetchAndOpenDocument;
|
||||
const url = new URL(filename, document.location.href);
|
||||
const data = await fetch(url);
|
||||
|
||||
const filename = url.pathname.split("/").pop() || "Untitled";
|
||||
const content = await data.text();
|
||||
|
||||
editor.instance.openDocumentFile(filename, content);
|
||||
editor.instance.openDocumentFile(name, 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.");
|
||||
// Needs to be delayed until the end of the current call stack so the existing demo artwork dialog can be closed first, otherwise this dialog won't show
|
||||
setTimeout(() => {
|
||||
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.");
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerOpenDocument, async () => {
|
||||
|
|
|
@ -522,7 +522,9 @@ export class TriggerLoadAutoSaveDocuments extends JsMessage {}
|
|||
export class TriggerLoadPreferences extends JsMessage {}
|
||||
|
||||
export class TriggerFetchAndOpenDocument extends JsMessage {
|
||||
readonly url!: string;
|
||||
readonly name!: string;
|
||||
|
||||
readonly filename!: string;
|
||||
}
|
||||
|
||||
export class TriggerOpenDocument extends JsMessage {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue