import { Language } from '@codemirror/language'; import { Extension } from '@codemirror/state'; import { type DataTestId, type MaskingProps, type StylingProps, type AriaLabelingProps } from '@dynatrace/strato-components/core'; import type { FormControlStateProps } from '../../core/types/form-control-state.js'; import { AutocompleteProvider } from '../base-code-editor/auto-completion/autocompletion.extension.js'; import type { ListAutocompletionConfig } from '../base-code-editor/auto-completion/list/list-autocompletion-extension.js'; import type { EditorLanguageConfiguration } from '../base-code-editor/configuration/configuration.js'; import type { GutterConfiguration } from '../base-code-editor/configuration/getDefaultConfigurations.js'; /** * @public */ export interface CodeEditorProps extends FormControlStateProps, StylingProps, DataTestId, AriaLabelingProps, MaskingProps { /** The language for syntax highlighting and autocompletion. * @defaultValue 'other' */ language?: 'json' | 'js' | 'jsx' | 'ts' | 'tsx' | 'md' | 'yaml' | 'other'; /** The ID for the DOM element. */ id?: string; /** The value (i.e. contents) of the editor. * @defaultValue '' */ value?: string; /** Callback that is called when the value in the editor changes. */ onChange?: (value: string) => void; /** Displayed initially in the editor when there is no other content. */ placeholder?: string; /** Whether spellcheck should be enabled. * @defaultValue false */ spellCheck?: boolean; /** * If set to true, the code editor uses the full height available in its parent. * @defaultValue false */ fullHeight?: boolean; /** The start indices (character position) that should be folded initially in uncontrolled scenarios. */ defaultFolding?: number[]; /** The start indices (character position) that should be folded initially in controlled scenarios.*/ folding?: number[]; /** Callback that is called when folding changes. */ onFoldingChange?: (values: number[]) => void; /** Whether the input is readonly. * @defaultValue false */ readOnly?: boolean; /** Whether long lines should be wrapped. * @defaultValue false */ lineWrap?: boolean; /** Callback that is called when the editor loses focus. */ onBlur?: (e: FocusEvent) => void; /** Callback that is called when the editor receives focus. */ onFocus?: (e: FocusEvent) => void; /** * Provides the gutter configuration to display a gutter next to the fold gutter */ gutterConfiguration?: GutterConfiguration; /** * Editor layout size, 'default' for standard spacing and 'condensed' for reduced font-size, padding and margins. * @defaultValue 'default' */ size?: 'default' | 'condensed'; /** * If set to true, `aria-required` will be set to true on the input element. * @defaultValue false */ required?: boolean; } /** * public ref type * @public */ export type CodeEditorRef = { focus: () => void; selectRange: (range: { from: number; to: number; }) => void; readonly element: HTMLDivElement | null; setCursorPosition: (position: number | 'end') => void; }; /** * The `CodeEditor` provides a text input field that is specifically designed for editing code. * It further offers properties to configure e.g. syntax highlighting, spell checks or line wrapping. * Once the editor is focused via the keyboard, the user must press "Enter" to start editing and "Escape" to quit editing and return to the keyboard navigation flow. * @public */ export declare const CodeEditor: (props: CodeEditorProps & import("react").RefAttributes) => React.ReactElement | null; /** * If readOnly is true then there is no autocompletion. * @param languageConfig - standard language config * @param readOnly - whether the editor is readOnly * @returns new config with appropriate values * @internal */ export declare function getLanguageConfig(languageConfig: EditorLanguageConfiguration, readOnly: boolean): { language: Language | undefined; autocompleteOptions: { activateOnTyping: boolean; providers: (AutocompleteProvider | ListAutocompletionConfig)[]; } | undefined; extendWith: readonly Extension[] | undefined; };