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
This commit is contained in:
@@ -653,8 +653,11 @@ function loadCurrentLesson() {
|
|||||||
renderDifficultyBadge(elements.lessonTitleRow, lesson);
|
renderDifficultyBadge(elements.lessonTitleRow, lesson);
|
||||||
|
|
||||||
// Set user code in CodeMirror (clear history to prevent undo/redo across lessons)
|
// 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) {
|
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
|
// Update Run button text based on completion status
|
||||||
@@ -869,7 +872,7 @@ function loadRandomTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runCode() {
|
function runCode() {
|
||||||
const userCode = codeEditor ? codeEditor.getValue() : "";
|
const userCode = codeEditor ? codeEditor.getEditableValue() : "";
|
||||||
const engineState = lessonEngine.getCurrentState();
|
const engineState = lessonEngine.getCurrentState();
|
||||||
const isPlayground = engineState.lesson?.mode === "playground";
|
const isPlayground = engineState.lesson?.mode === "playground";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user