2021-04-12 06:18:30 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import ConfigSelector from "./ConfigSelector.svelte";
|
|
|
|
import ConfigEditor from "./ConfigEditor.svelte";
|
2021-04-25 10:40:02 +02:00
|
|
|
import type { DeckOptionsState } from "./lib";
|
2021-04-23 03:20:12 +02:00
|
|
|
import { onMount, onDestroy } from "svelte";
|
|
|
|
import { registerShortcut } from "lib/shortcuts";
|
2021-04-24 02:14:54 +02:00
|
|
|
import type { Writable } from "svelte/store";
|
|
|
|
import HtmlAddon from "./HtmlAddon.svelte";
|
2021-04-25 11:24:19 +02:00
|
|
|
import type { DynamicSvelteComponent } from "sveltelib/dynamicComponent";
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-25 10:40:02 +02:00
|
|
|
export let state: DeckOptionsState;
|
2021-04-24 02:14:54 +02:00
|
|
|
let addons = state.addonComponents;
|
|
|
|
|
|
|
|
export function auxData(): Writable<Record<string, unknown>> {
|
|
|
|
return state.currentAuxData;
|
|
|
|
}
|
|
|
|
|
2021-04-25 11:24:19 +02:00
|
|
|
export function addSvelteAddon(component: DynamicSvelteComponent): void {
|
|
|
|
$addons = [...$addons, component];
|
|
|
|
}
|
|
|
|
|
2021-04-24 02:14:54 +02:00
|
|
|
export function addHtmlAddon(html: string, mounted: () => void): void {
|
|
|
|
$addons = [
|
|
|
|
...$addons,
|
|
|
|
{
|
|
|
|
component: HtmlAddon,
|
|
|
|
html,
|
|
|
|
mounted,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
2021-04-22 11:52:44 +02:00
|
|
|
|
2021-04-23 12:25:47 +02:00
|
|
|
let registerCleanup: () => void;
|
2021-04-23 03:20:12 +02:00
|
|
|
onMount(() => {
|
2021-04-23 12:25:47 +02:00
|
|
|
registerCleanup = registerShortcut(() => state.save(false), "Control+Enter");
|
2021-04-23 03:20:12 +02:00
|
|
|
});
|
2021-04-23 12:25:47 +02:00
|
|
|
onDestroy(() => registerCleanup?.());
|
2021-04-12 06:18:30 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-18 18:55:22 +02:00
|
|
|
<ConfigSelector {state} />
|
2021-05-25 18:54:58 +02:00
|
|
|
<ConfigEditor {state} />
|