Skip to content

Commit 71c2331

Browse files
committed
feat(ui): 为变量感知输入框添加自动换行功能
- 新增 lineWrappingCompartment 管理 CodeMirror 自动换行扩展 - 集成 EditorView.lineWrapping 实现文本自动换行 - 添加 CSS 样式支持长行文本正确换行显示 - 遵循组件现有的 Compartment 架构模式
1 parent f82eb4c commit 71c2331

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/ui/src/components/variable-extraction/VariableAwareInput.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ const existingVariableTooltipCompartment = new Compartment();
157157
const placeholderCompartment = new Compartment();
158158
const themeCompartment = new Compartment();
159159
const readOnlyCompartment = new Compartment();
160+
const lineWrappingCompartment = new Compartment();
160161
161162
const buildVariableMap = (
162163
names: string[] | undefined,
@@ -560,6 +561,8 @@ onMounted(() => {
560561
themeCompartment.of(createThemeExtension(themeVars.value)),
561562
// 🆕 只读状态
562563
readOnlyCompartment.of(EditorState.readOnly.of(props.readonly)),
564+
// 🆕 自动换行功能
565+
lineWrappingCompartment.of(EditorView.lineWrapping),
563566
// 监听文档变化
564567
EditorView.updateListener.of((update) => {
565568
if (update.docChanged) {
@@ -826,6 +829,16 @@ defineExpose({
826829
827830
.codemirror-container :deep(.cm-content) {
828831
min-height: v-bind("editorHeight.min");
832+
/* 🆕 支持文本自动换行 */
833+
white-space: pre-wrap;
834+
word-wrap: break-word;
835+
overflow-wrap: break-word;
836+
}
837+
838+
/* 🆕 确保长行文本正确换行 */
839+
.codemirror-container :deep(.cm-line) {
840+
white-space: pre-wrap;
841+
word-break: break-word;
829842
}
830843
831844
/* 占位符样式 */

0 commit comments

Comments
 (0)