From 8aa14c561484d8412eb07d95e11717f606f6b2f5 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Sun, 18 Jun 2023 21:15:42 +0200 Subject: [PATCH] split editor mode and command line, part 1 --- client/src/components/Level.tsx | 68 +++++++++++++++++++++++---------- client/src/components/level.css | 2 +- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/client/src/components/Level.tsx b/client/src/components/Level.tsx index d5e23cb..48fe7d5 100644 --- a/client/src/components/Level.tsx +++ b/client/src/components/Level.tsx @@ -83,6 +83,37 @@ function Level() { } } +// The mathematical formulation of the statement, supporting e.g. Latex +// It takes three forms, depending on the precence of name and description: +// - Theorem xyz: description +// - Theorem xyz +// - Exercises: description +function ExerciseStatement({data}) { + return
+ {(data?.statementName ? `**Theorem** \`${data?.statementName}\`: ` : data?.descrText && "**Exercise**: ") + `${data?.descrText}` } +
+} + + +// ref: the codeViewRef. Used to edit the editor's content even if not visible +function EditorInterface({data, codeviewRef, hidden, worldId, levelId, editorConnection}) { + + const { commandLineMode, setCommandLineMode } = React.useContext(InputModeContext) + + return
+
{data?.descrFormat}
+
+ {editorConnection &&
} + +
+} + +function ReducedInterface({worldId, levelId, editorConnection}) { + return
+ {/* */} + {editorConnection &&
} +
+} function PlayableLevel({worldId, levelId}) { const codeviewRef = useRef(null) @@ -192,6 +223,7 @@ function PlayableLevel({worldId, levelId}) { // If this state is set to a pair `(name, type)` then the according doc will be open. const [inventoryDoc, setInventoryDoc] = useState<{name: string, type: string}>(null) + // Open the doc of the clicked inventory item function openInventoryDoc(name, type) { setInventoryDoc({name, type}) } @@ -234,29 +266,25 @@ function PlayableLevel({worldId, levelId}) { }
+ + + +
- - {(level?.data?.statementName ? - `**Theorem** \`${level?.data?.statementName}\`: ` - : - level?.data?.descrText && "**Exercise**: ") - + `${level?.data?.descrText}` - } - -
{level?.data?.descrFormat}
-
+ {/* We need the editor to be hidden because the command line edits its content */} +
-
+ {/*
{commandLineMode && } -
- - - - - {editorConnection &&
} - - - +
*/} + {/* {editorConnection &&
} */} + + +
{!level.isLoading && diff --git a/client/src/components/level.css b/client/src/components/level.css index e20e344..4a76bc6 100644 --- a/client/src/components/level.css +++ b/client/src/components/level.css @@ -29,7 +29,7 @@ overflow: auto; } -.chat-panel, .infoview, .exercise { +.chat-panel, .infoview, .exercise, .exercise-statement { padding-top: 1em; padding-left: 1em; padding-right: 1em;