Spaces:
Runtime error
Runtime error
feat: allow saving and running edited code
Browse files- src/pages/index.tsx +17 -1
src/pages/index.tsx
CHANGED
@@ -222,7 +222,23 @@ export default function Home() {
|
|
222 |
</Toolbar>
|
223 |
</AppBar>
|
224 |
{showCode && (
|
225 |
-
<Box
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
<MonacoEditor
|
227 |
theme={getTheme(mode, systemMode)}
|
228 |
language="javascript"
|
|
|
222 |
</Toolbar>
|
223 |
</AppBar>
|
224 |
{showCode && (
|
225 |
+
<Box
|
226 |
+
sx={{ flex: 1 }}
|
227 |
+
onKeyDown={event => {
|
228 |
+
if (event.key === "s" && event.metaKey) {
|
229 |
+
event.preventDefault();
|
230 |
+
setAnswers(previousAnswers =>
|
231 |
+
previousAnswers.map(previousAnswer => {
|
232 |
+
console.log(previousAnswer.id, activeId);
|
233 |
+
return previousAnswer.id === activeId
|
234 |
+
? { ...previousAnswer, content: template }
|
235 |
+
: previousAnswer;
|
236 |
+
})
|
237 |
+
);
|
238 |
+
reload();
|
239 |
+
}
|
240 |
+
}}
|
241 |
+
>
|
242 |
<MonacoEditor
|
243 |
theme={getTheme(mode, systemMode)}
|
244 |
language="javascript"
|