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
+15
View File
@@ -89,6 +89,21 @@ export function createEditor() {
// Subscriptions: Allows subscribing to messages in JS that are sent from the WASM backend
const subscriptions: SubscriptionRouter = createSubscriptionRouter();
// Check if the URL hash fragment has any demo artwork to be loaded
(async () => {
const demoArtwork = window.location.hash.trim().match(/#demo\/(.*)/)?.[1];
if (!demoArtwork) return;
try {
const url = new URL(`https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/${demoArtwork}.graphite`);
const data = await fetch(url);
const filename = url.pathname.split("/").pop() || "Untitled";
const content = await data.text();
instance.openDocumentFile(filename, content);
} catch {}
})();
return {
raw,
instance,
@@ -513,6 +513,10 @@ export class TriggerLoadAutoSaveDocuments extends JsMessage { }
export class TriggerLoadPreferences extends JsMessage { }
export class TriggerFetchAndOpenDocument extends JsMessage {
readonly url!: string;
}
export class TriggerOpenDocument extends JsMessage { }
export class TriggerImport extends JsMessage { }
@@ -874,6 +878,19 @@ export class IconLabel extends WidgetProps {
tooltip!: string | undefined;
}
export class ImageLabel extends WidgetProps {
image!: IconName;
@Transform(({ value }: { value: string }) => value || undefined)
width!: string | undefined;
@Transform(({ value }: { value: string }) => value || undefined)
height!: string | undefined;
@Transform(({ value }: { value: string }) => value || undefined)
tooltip!: string | undefined;
}
export class LayerReferenceInput extends WidgetProps {
@Transform(({ value }: { value: BigUint64Array | undefined }) => (value ? String(value) : undefined))
value!: string | undefined;
@@ -1120,6 +1137,7 @@ const widgetSubTypes = [
{ value: FontInput, name: "FontInput" },
{ value: IconButton, name: "IconButton" },
{ value: IconLabel, name: "IconLabel" },
{ value: ImageLabel, name: "ImageLabel" },
{ value: LayerReferenceInput, name: "LayerReferenceInput" },
{ value: NumberInput, name: "NumberInput" },
{ value: OptionalInput, name: "OptionalInput" },
@@ -1367,6 +1385,7 @@ export const messageMakers: Record<string, MessageMaker> = {
DisplayRemoveEditableTextbox,
TriggerAboutGraphiteLocalizedCommitDate,
TriggerCopyToClipboardBlobUrl,
TriggerFetchAndOpenDocument,
TriggerDownloadBlobUrl,
TriggerDownloadRaster,
TriggerDownloadTextFile,