import { Language } from '@codemirror/language'; import { Extension } from '@codemirror/state'; import type { InlineDiagnostic } from './inline-diagnostic.js'; 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. * @deprecated Use the `diagnostics` and `showLintGutter` props for per-line validation markers instead. * Will be removed in a future major release. */ gutterConfiguration?: GutterConfiguration; /** * Diagnostics to render inside the editor (underlines, hover tooltips). * When provided, the built-in JSON linter is overridden. */ diagnostics?: InlineDiagnostic[]; /** * When `true`, shows a severity marker in a gutter column next to each diagnostic line. * Has no effect when `diagnostics` is `undefined` or empty. Takes precedence over * `gutterConfiguration` when both are set. * @defaultValue false */ showLintGutter?: boolean; } /** * 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. * When custom diagnostics are supplied, built-in language linter extensions * (e.g. jsonParseLinter) are stripped from `extendWith` so they don't conflict * with the consumer-supplied diagnostics. * @param languageConfig - standard language config * @param readOnly - whether the editor is readOnly * @param hasDiagnostics - whether the consumer supplies custom diagnostics * @returns new config with appropriate values * @internal */ export declare function getLanguageConfig(languageConfig: EditorLanguageConfiguration, readOnly: boolean, hasDiagnostics?: boolean): { language: Language | undefined; autocompleteOptions: { activateOnTyping: boolean; providers: (AutocompleteProvider | ListAutocompletionConfig)[]; } | undefined; extendWith: readonly Extension[] | undefined; }; //# sourceMappingURL=CodeEditor.d.ts.map