diff --git a/src/core/client.mjs b/src/core/client.mjs index afe1a82..db1d269 100644 --- a/src/core/client.mjs +++ b/src/core/client.mjs @@ -21,7 +21,7 @@ export default async (api, db) => { openMenuHotkey = await db.get("openMenuHotkey"), menuButtonIconStyle = await db.get("menuButtonIconStyle"), loadThemeOverrides = await db.get("loadThemeOverrides"), - customStyles = await db.get("customStyles"); + customStyles = JSON.parse((await db.get("customStyles")) || "{}").content; // appearance @@ -38,9 +38,10 @@ export default async (api, db) => { } if (customStyles) { - document.head.append(html``); + `; + document.head.append($customStyles); } // menu diff --git a/src/core/menu/components.mjs b/src/core/menu/components.mjs index 93bb7a4..d175347 100644 --- a/src/core/menu/components.mjs +++ b/src/core/menu/components.mjs @@ -100,9 +100,15 @@ function Option({ type, value, description, _update, ...props }) { $input = html`<${ColorInput} ...${{ value, onchange }} />`; break; case "file": + try { + value = JSON.parse(value); + } catch { + value = {}; + } $input = html`<${FileInput} + filename="${value.filename}" extensions="${props.extensions}" - onchange=${onchange} + onupload=${(upload) => _update(JSON.stringify(upload))} />`; break; case "select": @@ -278,27 +284,57 @@ function ColorInput({ value, ...props }) { `; } -function FileInput({ extensions, ...props }) { - // todo: show uploaded file name, clear prev upload - const { html } = globalThis.__enhancerApi; - return html`