diff --git a/next_app/src/components/layout.tsx b/next_app/src/components/layout.tsx index f6bb9ce..395d820 100644 --- a/next_app/src/components/layout.tsx +++ b/next_app/src/components/layout.tsx @@ -202,6 +202,10 @@ const CodeCell = ({ else monaco.editor.setTheme("vs-light"); // set font family editor.updateOptions({ fontFamily: "DM mono" }); + // run function on ctrl+enter + editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => { + runCellCode(); + }); }} onChange={(value) => { // console.log(value); @@ -246,10 +250,22 @@ const VisualCell = ( ) => { const [mouseHovered, setMouseHovered] = useState(false); const [editing, setEditing] = useState(file.content.cells[cellId].editing); + const [clickCount, setClickCount] = useState(0); const { theme } = useTheme(); const cellType = file.content.cells[cellId].type + function checkDoubleClick() { + if (editing) return + setClickCount(clickCount + 1); + setTimeout(() => { + if (clickCount == 1) { + setEditing(true); + } + setClickCount(0); + }, 200); + } + return
setMouseHovered(true)} onMouseLeave={() => setMouseHovered(false)} @@ -297,6 +313,11 @@ const VisualCell = ( else monaco.editor.setTheme("vs-light"); // set font family editor.updateOptions({ fontFamily: "DM mono" }); + // run function on ctrl+enter + editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => { + setEditing(false); + }); + editor.focus(); }} onChange={(value) => { // console.log(value); @@ -316,7 +337,7 @@ const VisualCell = ( language={file.content.cells[cellId].type == "MARKDOWN" ? "markdown" : "latex"} options={monacoConfig.CodeCell} /> -
:
+
:
{cellType == "MARKDOWN" ? {file.content.cells[cellId].code} : {file.content.cells[cellId].code} }