fix(Editor): Don't discard parameters from URL when changing themes
import { diff, objToVars, ThemeObject } from '.'
-import { keys } from './index'
import { styleEntry, themes } from '../../browser'
import { append, create, prepend } from '../../util'
-import { forceReady, getPreviewDoc, getPreviewHead } from './preview'
+import { keys } from './index'
+import {
+ forceReady,
+ getExample,
+ getPreviewDoc,
+ getPreviewHead
+} from './preview'
export const getTheme = (): string => {
return (
@@ -16,9 +21,7 @@ export const themeSet = (theme: string): void => {
// Update all the places that theme is set
const url = new URL(window.location.href)
- const example = url.searchParams.get(keys.EXAMPLE)
- url.search = ''
- url.searchParams.set(keys.EXAMPLE, example ?? '')
+ url.searchParams.set(keys.EXAMPLE, getExample())
url.searchParams.set(keys.THEME, theme)
history.replaceState(null, 'none', url.toString())
sessionStorage.setItem(keys.THEME, theme)
