From 3bb67f6673f97119c8522d7159727cea3d0e581d Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 8 Jul 2026 14:32:04 +0800 Subject: [PATCH] style(runner): optimize CodeMirror editor height auto-scaling and scrolling limit --- input.css | 15 +++++++++++++++ src/components/code_runner/runner.rs | 4 ---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/input.css b/input.css index ef67aa2..0b4c739 100644 --- a/input.css +++ b/input.css @@ -852,3 +852,18 @@ /* ========== Blur-up 渐进图片加载(已移入 @layer components) ========== */ @source "./src/**/*.{rs,html}"; + +/* ========== CodeMirror 代码运行器高度自适应优化 ========== */ +.code-runner-editor { + min-height: 120px; + max-height: 400px; + display: flex; + flex-direction: column; +} +.code-runner-editor .cm-editor { + flex: 1 1 auto !important; +} +.code-runner-editor .cm-scroller { + overflow: auto; +} + diff --git a/src/components/code_runner/runner.rs b/src/components/code_runner/runner.rs index bab076f..f37a773 100644 --- a/src/components/code_runner/runner.rs +++ b/src/components/code_runner/runner.rs @@ -259,13 +259,9 @@ pub fn CodeRunner( } } } - // CodeMirror 容器:组件自身在 WASM 端按此 id 挂载编辑器。 - // 服务端渲染时仅展示空容器,避免在 SSR 阶段拉起 JS 编辑器。 - // relative 定位,使骨架屏覆盖层(未就绪时)能贴合容器尺寸。 div { id: "{container_id}", class: "code-runner-editor font-mono text-sm relative", - style: "min-height: 160px; display: flex; flex-direction: column", // 骨架屏:CodeMirror 尚未挂载就绪时(SSR + hydration 完成前)显示。 // editor_ready 由挂载 effect 置 true 后,此处 if 分支消失,骨架屏从 DOM 移除。