diff --git a/src/lib/Util/state.ts b/src/lib/Util/state.ts index 463154b4..feea1576 100644 --- a/src/lib/Util/state.ts +++ b/src/lib/Util/state.ts @@ -37,7 +37,9 @@ export const loadState = (data: string): void => { }; export const updateCodeStore = (newState: State): void => { - codeStore.set(newState); + codeStore.update((state) => { + return { ...state, ...newState }; + }); }; export const updateCode = (code: string, updateEditor: boolean): void => { diff --git a/src/lib/Util/util.ts b/src/lib/Util/util.ts index 38508e0c..d45e49c4 100644 --- a/src/lib/Util/util.ts +++ b/src/lib/Util/util.ts @@ -1,10 +1,17 @@ -import { initURLSubscription, loadState } from './state'; +import { initURLSubscription, loadState, updateCodeStore } from './state'; export const loadStateFromURL = (): void => { loadState(window.location.hash.slice(1)); }; +export const syncDiagram = (): void => { + updateCodeStore({ + updateDiagram: true + } as State); +}; + export const initHandler = (): void => { loadStateFromURL(); + syncDiagram(); initURLSubscription(); }; diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index e2f535ec..da46ff8e 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -120,7 +120,7 @@ }); - +
{#if isClipboardAvailable()} diff --git a/src/lib/components/card/card.svelte b/src/lib/components/card/card.svelte index a45b8e7d..d731ff28 100644 --- a/src/lib/components/card/card.svelte +++ b/src/lib/components/card/card.svelte @@ -16,7 +16,7 @@
(isOpen = !isOpen)}>
-
+
diff --git a/src/lib/components/card/tabs.svelte b/src/lib/components/card/tabs.svelte index b2993a07..f70bbcf3 100644 --- a/src/lib/components/card/tabs.svelte +++ b/src/lib/components/card/tabs.svelte @@ -16,7 +16,7 @@
- (isOpen = !isOpen)}> + (isOpen = !isOpen)}> {#if isCloseable} {#if isOpen && tabs} -
    +
      {#each tabs as tab} -
    • +
    • - - + +
        {#each $historyStore as { state, time, name }} @@ -98,3 +94,9 @@ {/each}
      + + diff --git a/src/lib/components/history/history.ts b/src/lib/components/history/history.ts index 518c859d..9b53615d 100644 --- a/src/lib/components/history/history.ts +++ b/src/lib/components/history/history.ts @@ -2,7 +2,7 @@ import { derived, Readable, Writable, writable, get } from 'svelte/store'; import { persist, localStorage } from '@macfja/svelte-persistent-store'; import { generateSlug } from 'random-word-slugs'; -const MAX_AUTO_HISTORY_LENGTH = 10; +const MAX_AUTO_HISTORY_LENGTH = 30; export const autoHistoryMode: Writable = persist( writable(true), diff --git a/src/routes/edit.svelte b/src/routes/edit.svelte index f15db52a..0b3baee5 100644 --- a/src/routes/edit.svelte +++ b/src/routes/edit.svelte @@ -7,7 +7,7 @@ import Card from '$lib/components/card/card.svelte'; import History from '$lib/components/history/history.svelte'; import { updateCode, updateConfig, codeStore, base64State } from '$lib/util/state'; - import { initHandler } from '$lib/util/util'; + import { initHandler, syncDiagram } from '$lib/util/util'; import { errorStore } from '$lib/util/error'; import { onMount } from 'svelte'; import type monaco from 'monaco-editor'; @@ -58,10 +58,6 @@ updateConfig(config, false); }; - const syncDiagram = () => { - $codeStore.updateDiagram = true; - }; - const updateHandler = async (message: CustomEvent) => { try { if (selectedMode === 'code') { @@ -108,8 +104,9 @@
      {#if !$codeStore.autoSync} - + {/if}