Skip to content

Commit 07aafa0

Browse files
committed
feat(app): pass codePrefix/codeSuffix to editor on lesson load
- Update loadCurrentLesson() to pass prefix/suffix to editor - Use getEditableValue() in runCode() to get only user code
1 parent eb82eed commit 07aafa0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/app.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,11 @@ function loadCurrentLesson() {
653653
renderDifficultyBadge(elements.lessonTitleRow, lesson);
654654

655655
// Set user code in CodeMirror (clear history to prevent undo/redo across lessons)
656+
// Pass codePrefix/codeSuffix as read-only zones for CSS mode
656657
if (codeEditor) {
657-
codeEditor.setValueAndClearHistory(engineState.userCode);
658+
const prefix = lesson.codePrefix || "";
659+
const suffix = lesson.codeSuffix || "";
660+
codeEditor.setValueAndClearHistory(engineState.userCode, prefix, suffix);
658661
}
659662

660663
// Update Run button text based on completion status
@@ -869,7 +872,7 @@ function loadRandomTemplate() {
869872
}
870873

871874
function runCode() {
872-
const userCode = codeEditor ? codeEditor.getValue() : "";
875+
const userCode = codeEditor ? codeEditor.getEditableValue() : "";
873876
const engineState = lessonEngine.getCurrentState();
874877
const isPlayground = engineState.lesson?.mode === "playground";
875878

0 commit comments

Comments
 (0)