Skip to content

Commit

Permalink
feat(editor): ability to paste in hop array only
Browse files Browse the repository at this point in the history
  • Loading branch information
sabberworm committed Oct 14, 2024
1 parent ebb8104 commit fb5ae11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/frontend/sections/ScriptEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const ScriptEditor: FC = () => {

return (
<Elm className="script-editor">
<fieldset className="options">
<fieldset className="field-container">
<legend>Options</legend>
<Select label="Log Level" list={LOG_LEVEL_LABELS} value={script.logLevel} onChange={val => (script.logLevel = val)} />
</fieldset>
Expand Down
9 changes: 8 additions & 1 deletion src/main/frontend/sections/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export const Toolbar: FC = () => {
if (typeof state !== 'object') {
throw new Error(`Pasted JSON is not an object: ${json}`);
}
scriptContext.replace({ ...INITIAL_SCRIPT, ...state });
if (Array.isArray(state)) {
// Assume steps were pasted in
script.hops.push(...state);
scriptContext.commit();
} else {
// Otherwise, it’s likely a complete script
scriptContext.replace({ ...INITIAL_SCRIPT, ...state });
}
} catch (e) {
console.error('Could not paste script', e);
}
Expand Down

0 comments on commit fb5ae11

Please sign in to comment.