diff --git a/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx b/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx index fce059e5..7ffacba1 100644 --- a/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx +++ b/ui/src/components/compatible-cli/raw-json-settings-editor-panel.tsx @@ -23,7 +23,7 @@ interface RawConfigEditorPanelProps { onRefresh: () => Promise | void; onDiscard?: () => void; language?: 'json' | 'yaml' | 'toml'; - plainText?: boolean; + exactText?: boolean; loadingLabel?: string; parseWarningLabel?: string; ownershipNotice?: ReactNode; @@ -45,7 +45,7 @@ export function RawConfigEditorPanel({ onRefresh, onDiscard, language = 'json', - plainText = false, + exactText = false, loadingLabel = 'Loading settings.json...', parseWarningLabel = 'Parse warning', ownershipNotice, @@ -130,7 +130,7 @@ export function RawConfigEditorPanel({ onChange={onChange} language={language} readonly={readOnly} - plainText={plainText} + exactText={exactText} minHeight="100%" heightMode="fill-parent" /> diff --git a/ui/src/components/shared/code-editor.tsx b/ui/src/components/shared/code-editor.tsx index 11860fbc..6454828b 100644 --- a/ui/src/components/shared/code-editor.tsx +++ b/ui/src/components/shared/code-editor.tsx @@ -4,7 +4,7 @@ * Uses react-simple-code-editor + prism-react-renderer for minimal bundle size (~18KB) */ -import { useState, useCallback, useMemo } from 'react'; +import { useState, useCallback, useMemo, useRef, type UIEvent } from 'react'; import Editor from 'react-simple-code-editor'; import { Highlight, themes } from 'prism-react-renderer'; import Prism from 'prismjs'; @@ -24,7 +24,7 @@ interface CodeEditorProps { onChange: (value: string) => void; language?: 'json' | 'yaml' | 'toml'; readonly?: boolean; - plainText?: boolean; + exactText?: boolean; className?: string; minHeight?: string; heightMode?: 'content' | 'fill-parent'; @@ -96,7 +96,7 @@ export function CodeEditor({ onChange, language = 'json', readonly = false, - plainText = false, + exactText = false, className, minHeight = '300px', heightMode = 'content', @@ -191,6 +191,14 @@ export function CodeEditor({ ), [isDark, language, validation.line, isMasked] ); + const highlightLayerRef = useRef(null); + const syncHighlightScroll = useCallback((event: UIEvent) => { + const layer = highlightLayerRef.current; + if (!layer) return; + + const { scrollLeft, scrollTop } = event.currentTarget; + layer.style.transform = `translate(${-scrollLeft}px, ${-scrollTop}px)`; + }, []); return (
- {plainText ? ( -