diff --git a/apps/playground/src/App.tsx b/apps/playground/src/App.tsx index 3b1113a7..1de85ed9 100644 --- a/apps/playground/src/App.tsx +++ b/apps/playground/src/App.tsx @@ -18,7 +18,7 @@ import { DeobfuscateContextProvider } from './context/DeobfuscateContext'; import { settings } from './hooks/useSettings'; import { useWorkspaces, type Workspace } from './indexeddb'; import { debounce } from './utils/debounce'; -import { downloadFile } from './utils/download'; +import { downloadFile } from './utils/files'; import type { DeobfuscateResult } from './webcrack.worker'; export const [config, setConfig] = createStore({ @@ -245,6 +245,9 @@ function App() { currentModel={activeTab()} onModelChange={openTab} onValueChange={saveModelsDebounced} + onFileOpen={(content) => { + openUntitledTab().setValue(content); + }} /> diff --git a/apps/playground/src/components/Menu.tsx b/apps/playground/src/components/Menu.tsx index 9993b0dc..aec5085c 100644 --- a/apps/playground/src/components/Menu.tsx +++ b/apps/playground/src/components/Menu.tsx @@ -1,6 +1,7 @@ import { For } from 'solid-js'; import { setSettings, settings, type Settings } from '../hooks/useSettings'; import { useWorkspaces, type Workspace } from '../indexeddb'; +import { openFile } from '../utils/files'; interface Props { onFileOpen?: (content: string) => void; @@ -11,18 +12,6 @@ interface Props { export default function Menu(props: Props) { const { workspaces } = useWorkspaces(); - function openFile() { - const input = document.createElement('input'); - input.type = 'file'; - input.onchange = async (event) => { - const file = (event.target as HTMLInputElement).files?.[0]; - if (!file) return; - const content = await file.text(); - props.onFileOpen?.(content); - }; - input.click(); - } - return (