From 07aafa0d8974e9bebab25fa3fe4c68ad98aa9744 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Sun, 25 Jan 2026 02:00:07 +0100 Subject: [PATCH] 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 --- src/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index 17b5d04..a073ba6 100644 --- a/src/app.js +++ b/src/app.js @@ -653,8 +653,11 @@ function loadCurrentLesson() { renderDifficultyBadge(elements.lessonTitleRow, lesson); // Set user code in CodeMirror (clear history to prevent undo/redo across lessons) + // Pass codePrefix/codeSuffix as read-only zones for CSS mode if (codeEditor) { - codeEditor.setValueAndClearHistory(engineState.userCode); + const prefix = lesson.codePrefix || ""; + const suffix = lesson.codeSuffix || ""; + codeEditor.setValueAndClearHistory(engineState.userCode, prefix, suffix); } // Update Run button text based on completion status @@ -869,7 +872,7 @@ function loadRandomTemplate() { } function runCode() { - const userCode = codeEditor ? codeEditor.getValue() : ""; + const userCode = codeEditor ? codeEditor.getEditableValue() : ""; const engineState = lessonEngine.getCurrentState(); const isPlayground = engineState.lesson?.mode === "playground";