mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-13 06:19:33 -04:00
30 lines
755 B
React
30 lines
755 B
React
import { errorLogger } from '@strudel/core';
|
|
import { useSettings, storeStartupScript } from '../../../settings.mjs';
|
|
import { SpecialActionInput } from '../button/action-button';
|
|
|
|
async function importScript(script) {
|
|
const reader = new FileReader();
|
|
reader.readAsText(script);
|
|
|
|
reader.onload = () => {
|
|
const text = reader.result;
|
|
storeStartupScript(text);
|
|
};
|
|
|
|
reader.onerror = () => {
|
|
errorLogger(new Error('failed to import prebake script'), 'importScript');
|
|
};
|
|
}
|
|
export function ImportPrebakeScriptButton() {
|
|
const settings = useSettings();
|
|
|
|
return (
|
|
<SpecialActionInput
|
|
type="file"
|
|
label="import prebake script"
|
|
accept=".strudel"
|
|
onChange={(e) => importScript(e.target.files[0])}
|
|
/>
|
|
);
|
|
}
|