diff --git a/package-lock.json b/package-lock.json index 5d2e4d09..8747943b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5167,6 +5167,21 @@ } } }, + "node_modules/svelte-check/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/svelte-check/node_modules/readdirp": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", diff --git a/src/lib/components/css-form/Form.svelte b/src/lib/components/css-form/Form.svelte index cdbdc0fd..d0cbbcee 100644 --- a/src/lib/components/css-form/Form.svelte +++ b/src/lib/components/css-form/Form.svelte @@ -13,6 +13,7 @@ import { get_css, type CssFetchNetworkError, type CssFetchApiError, type CssFetchRemoteError } from '$lib/get-css' import { get_css_state } from '$lib/css-state.svelte' import { IsOnline } from '$lib/is-online.svelte' + import { HashState } from '$lib/url-hash-state.svelte' import type { Snippet } from 'svelte' interface Props { @@ -29,6 +30,8 @@ let error: Error | undefined = $state() let url = $state('') let css_state = get_css_state() + let raw_hash_state = new HashState<{ css: string }>({ css: '' }) + let initial_tab: 'url' | 'file' | 'raw' = raw_hash_state.current.css ? 'raw' : 'url' let prettify = $state(page.url.searchParams.has('prettify') ? page.url.searchParams.get('prettify') === '1' : true) let is_online = new IsOnline() @@ -42,11 +45,11 @@ let input_val = form_data.get('raw-css') let val = String(input_val) - // Remove ?url= and prettify= query parameters from the URL + // Remove ?url= and prettify= query parameters from the URL, but keep + // the hash so the raw CSS state is preserved for sharing let cleaned_url = page.url cleaned_url.searchParams.delete('url') cleaned_url.searchParams.delete('prettify') - cleaned_url.hash = '' await goto(cleaned_url, { replaceState: true }) status = 'idle' @@ -167,7 +170,7 @@ {/snippet} - + {#snippet title()} {@render title_snippet?.()} {/snippet} @@ -227,7 +230,7 @@
-