import { Language } from '@codemirror/language'; import { Extension } from '@codemirror/state'; import type { AutocompleteProvider } from '../base-code-editor/auto-completion/autocompletion.extension.js'; import type { ListAutocompletionConfig } from '../base-code-editor/auto-completion/list/list-autocompletion-types.js'; import { type SharedBaseCodeEditorProps } from '../base-code-editor/BaseCodeEditor.js'; import type { EditorLanguageConfiguration } from '../base-code-editor/configuration/configuration.js'; import type { GutterConfiguration } from '../base-code-editor/configuration/getDefaultConfigurations.js'; /** * Props for the `CodeEditor` component. * @public */ export interface CodeEditorBaseProps extends SharedBaseCodeEditorProps { /** * The language for syntax highlighting and autocompletion. * @defaultValue 'other' */ language?: 'json' | 'js' | 'jsx' | 'ts' | 'tsx' | 'md' | 'yaml' | 'other'; /** * Provides the gutter configuration to display a marker next to the fold gutter. */ gutterConfiguration?: GutterConfiguration; } /** * Props for the `CodeEditor` in controlled usage. * @public */ export type CodeEditorControlledProps = { /** * The value of the editor in controlled mode. * @defaultValue '' */ value?: string; /** Not allowed in controlled mode. */ defaultValue?: never; }; /** * Props for the `CodeEditor` in uncontrolled usage. * @public */ export type CodeEditorUncontrolledProps = { /** Not allowed in uncontrolled mode. */ value?: never; /** * The default value of the editor for uncontrolled usage. */ defaultValue?: string; /** * `isControlled` has no effect without `value`. * @deprecated [APPDEV-17404] BREAKING-CHANGE: Will be removed when controlled behaviour becomes the default. */ isControlled?: never; }; /** * Props for the `CodeEditor` component. * @public */ export type CodeEditorProps = CodeEditorBaseProps & (CodeEditorControlledProps | CodeEditorUncontrolledProps); /** * Ref handle exposed by the `CodeEditor` component. * @public */ export type CodeEditorRef = { /** * Moves focus to the editor. */ focus: () => void; /** * Selects the text within the given character-offset range. */ selectRange: (range: { from: number; to: number; }) => void; /** * The underlying editor container DOM element. */ readonly element: HTMLDivElement | null; /** * Moves the cursor to the given character offset, or to the end of the document when `'end'` is passed. */ 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) => import("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; };