feat(editor): apply word wrap to config editors

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-13 01:59:04 +08:00
1 parent f88e39563d
commit 1d2a47fee0
13 files changed
+48 -12

No files matched your search

@@ -197,6 +197,7 @@ const importSource = shallowRef<string | File | null>(null);
const importSourceName = ref("");
const configEditorTheme = new Compartment();
const configEditorFontTheme = new Compartment();
const configEditorWordWrap = new Compartment();
const configEditorLanguage = new Compartment();
const configListRequestGuard = createNacosLatestRequestGuard();
const configDetailRequestGuard = createNacosLatestRequestGuard();
@@ -553,7 +554,7 @@ async function mountConfigEditor() {
configEditorLanguage.of(language),
configEditorTheme.of(theme),
configEditorFontTheme.of(editorFontTheme(EditorView, editorSettings.fontSize, editorSettings.fontFamily, { fixedHeight: true, scrollable: true })),
EditorView.lineWrapping,
configEditorWordWrap.of(editorSettings.wordWrap ? EditorView.lineWrapping : []),
EditorState.readOnly.of(!!props.readOnly),
EditorView.editable.of(!props.readOnly),
EditorView.updateListener.of((update) => {
@@ -2314,7 +2315,7 @@ watch(
if (configEditorView.value !== view) return;
configEditorFontSize.value = clampEditorFontSize(settings.fontSize);
view.dispatch({
effects: [configEditorTheme.reconfigure(theme), configEditorFontTheme.reconfigure(editorFontTheme(EditorView, settings.fontSize, settings.fontFamily, { fixedHeight: true, scrollable: true }))],
effects: [configEditorTheme.reconfigure(theme), configEditorFontTheme.reconfigure(editorFontTheme(EditorView, settings.fontSize, settings.fontFamily, { fixedHeight: true, scrollable: true })), configEditorWordWrap.reconfigure(settings.wordWrap ? EditorView.lineWrapping : [])],
});
},
{ deep: true },
@@ -123,6 +123,13 @@ describe("NacosAdminConsole config workbench layout", () => {
expect(source).toContain("configEditorZoomCommitScheduler.dispose()");
});
it("keeps the configuration editor word wrapping aligned with the global editor setting", () => {
expect(source).toContain("const configEditorWordWrap = new Compartment()");
expect(source).toContain("configEditorWordWrap.of(editorSettings.wordWrap ? EditorView.lineWrapping : [])");
expect(source).toContain("configEditorWordWrap.reconfigure(settings.wordWrap ? EditorView.lineWrapping : [])");
expect(source).not.toContain("\n EditorView.lineWrapping,\n");
});
it("allows optional configuration columns to be hidden without hiding the data ID", () => {
const configListHeader = source.indexOf('class="sticky top-0 z-20 grid border-b bg-muted');
const columnVisibility = source.indexOf("nacos.visibleColumns");