import { Button, HStack, Input, Select, SelectContent, SelectIcon, SelectListbox, SelectOption, SelectOptionIndicator, SelectOptionText, SelectPlaceholder, SelectTrigger, SelectValue, } from "@hope-ui/solid" import { createMemo, createSignal, For, Show } from "solid-js" import { getSetting } from "~/store" import { useT } from "~/hooks" const COMMON_EXTS = [ "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "md", "html", "json", "log", "srt", "ass", "lrc", "vtt", "jpg", "jpeg", "png", "gif", "webp", "svg", "mp3", "flac", "wav", "mp4", "mkv", "webm", "mov", "epub", "zip", "rar", "7z", "ipa", "plist", ] const collectKeysFromRecord = (raw: string): string[] => { if (!raw) return [] try { const obj = JSON.parse(raw) if (!obj || typeof obj !== "object") return [] const out: string[] = [] for (const k of Object.keys(obj)) { if (k.startsWith("/")) continue k.split(",").forEach((part) => { const t = part.trim().toLowerCase() if (t) out.push(t) }) } return out } catch { return [] } } export const useExtensionList = (extraKeys: () => string[]) => createMemo(() => { const set = new Set(COMMON_EXTS) collectKeysFromRecord(getSetting("iframe_previews")).forEach((k) => set.add(k), ) collectKeysFromRecord(getSetting("external_previews")).forEach((k) => set.add(k), ) extraKeys().forEach((k) => set.add(k.toLowerCase())) return Array.from(set).sort() }) export const ExtensionPicker = (props: { value: string onChange: (v: string) => void extraKeys: () => string[] onAdd: (ext: string) => void }) => { const t = useT() const list = useExtensionList(props.extraKeys) const [adding, setAdding] = createSignal(false) const [draft, setDraft] = createSignal("") return ( setDraft(e.currentTarget.value)} /> } > ) }