diff --git a/src/mol-plugin/behavior/static/state.ts b/src/mol-plugin/behavior/static/state.ts index d2faaebef9bb72ff1dc3435c6a78ec2763533492..fad738a730597dd863550db7ebb7d56b017ad9fa 100644 --- a/src/mol-plugin/behavior/static/state.ts +++ b/src/mol-plugin/behavior/static/state.ts @@ -187,4 +187,9 @@ export function Snapshots(ctx: PluginContext) { PluginCommands.State.Snapshots.OpenFile.subscribe(ctx, ({ file }) => { return ctx.managers.snapshot.open(file); }); + + PluginCommands.State.Snapshots.OpenUrl.subscribe(ctx, async ({ url, type }) => { + const data = await ctx.runTask(ctx.fetch({ url, type: 'binary' })); + return ctx.managers.snapshot.open(new File([data], `state.${type}`)); + }); } \ No newline at end of file diff --git a/src/mol-plugin/commands.ts b/src/mol-plugin/commands.ts index 6f111ebebe8b1baba1305e17d4690e5171fdfe2e..e2921b6cee0819a265072e59d5d81c61a7155468 100644 --- a/src/mol-plugin/commands.ts +++ b/src/mol-plugin/commands.ts @@ -37,8 +37,9 @@ export const PluginCommands = { Upload: PluginCommand<{ name?: string, description?: string, playOnLoad?: boolean, serverUrl: string, params?: PluginState.SnapshotParams }>(), Fetch: PluginCommand<{ url: string }>(), - DownloadToFile: PluginCommand<{ name?: string, type: 'json' | 'molj' | 'zip' | 'molx', params?: PluginState.SnapshotParams }>(), + DownloadToFile: PluginCommand<{ name?: string, type: PluginState.SnapshotType, params?: PluginState.SnapshotParams }>(), OpenFile: PluginCommand<{ file: File }>(), + OpenUrl: PluginCommand<{ url: string, type: PluginState.SnapshotType }>(), } }, Interactivity: { diff --git a/src/mol-plugin/state.ts b/src/mol-plugin/state.ts index 9c7d3af705cb57092188ad3c32c3cf47fcaef90e..7e9cd200764f22b3f86777c200a77a45415d05a0 100644 --- a/src/mol-plugin/state.ts +++ b/src/mol-plugin/state.ts @@ -166,4 +166,6 @@ namespace PluginState { structureFocus?: StructureFocusSnapshot, durationInMs?: number } + + export type SnapshotType = 'json' | 'molj' | 'zip' | 'molx' }