import type { Extension } from '@codemirror/state'; import { Compartment, StateEffect } from '@codemirror/state'; import type { KeyBinding } from '@codemirror/view'; import { EditorView } from '@codemirror/view'; import type { IEditorConfig } from '@difizen/libro-code-editor'; import type { IOptions } from './editor.js'; /** * The configuration options for a codemirror editor. */ export interface CodeMirrorConfig extends IEditorConfig { /** * The mode to use. */ mode?: string; /** * content mimetype */ mimetype?: string; /** * Whether to use the context-sensitive indentation that the mode provides * (or just indent the same as the line before). */ smartIndent?: boolean; /** * Configures whether the editor should re-indent the current line when a * character is typed that might change its proper indentation * (only works if the mode supports indentation). */ electricChars?: boolean; /** * Configures the keymap to use. The default is "default", which is the * only keymap defined in codemirror.js itself. * Extra keymaps are found in the CodeMirror keymap directory. */ keyMap?: string; /** * Can be used to specify extra keybindings for the editor, alongside the * ones defined by keyMap. Should be either null, or a valid keymap value. */ extraKeys?: KeyBinding[] | null; /** * Can be used to add extra gutters (beyond or instead of the line number * gutter). * Should be an array of CSS class names, each of which defines a width * (and optionally a background), * and which will be used to draw the background of the gutters. * May include the CodeMirror-linenumbers class, in order to explicitly * set the position of the line number gutter * (it will default to be to the right of all other gutters). * These class names are the keys passed to setGutterMarker. */ gutters?: string[]; /** * Determines whether the gutter scrolls along with the content * horizontally (false) * or whether it stays fixed during horizontal scrolling (true, * the default). */ fixedGutter?: boolean; /** * Whether the cursor should be drawn when a selection is active. */ showCursorWhenSelecting?: boolean; /** * When fixedGutter is on, and there is a horizontal scrollbar, by default * the gutter will be visible to the left of this scrollbar. If this * option is set to true, it will be covered by an element with class * CodeMirror-gutter-filler. */ coverGutterNextToScrollbar?: boolean; /** * Controls whether drag-and-drop is enabled. */ dragDrop?: boolean; /** * Explicitly set the line separator for the editor. * By default (value null), the document will be split on CRLFs as well as * lone CRs and LFs, and a single LF will be used as line separator in all * output (such as getValue). When a specific string is given, lines will * only be split on that string, and output will, by default, use that * same separator. */ lineSeparator?: string | null; /** * Chooses a scrollbar implementation. The default is "native", showing * native scrollbars. The core library also provides the "null" style, * which completely hides the scrollbars. Addons can implement additional * scrollbar models. */ scrollbarStyle?: string; /** * When enabled, which is the default, doing copy or cut when there is no * selection will copy or cut the whole lines that have cursors on them. */ lineWiseCopyCut?: boolean; /** * Whether to scroll past the end of the buffer. */ scrollPastEnd?: boolean; /** * Whether to give the wrapper of the line that contains the cursor the class * cm-activeLine. */ styleActiveLine?: boolean; /** * Whether to causes the selected text to be marked with the CSS class * CodeMirror-selectedtext. Useful to change the colour of the selection * (in addition to the background). */ styleSelectedText?: boolean; /** * Defines the mouse cursor appearance when hovering over the selection. * It can be set to a string, like "pointer", or to true, * in which case the "default" (arrow) cursor will be used. */ selectionPointer?: boolean | string; highlightActiveLineGutter?: boolean; highlightSpecialChars?: boolean; history?: boolean; drawSelection?: boolean; dropCursor?: boolean; allowMultipleSelections?: boolean; autocompletion?: boolean; rectangularSelection?: boolean; crosshairCursor?: boolean; highlightSelectionMatches?: boolean; foldGutter?: boolean; syntaxHighlighting?: boolean; /** * 是否从kernel获取completion */ jupyterKernelCompletion?: boolean; /** * 是否从kernel获取tooltip */ jupyterKernelTooltip?: boolean; indentationMarkers?: boolean; hyperLink?: boolean; /** * 是否开启tab触发completion和tooltip */ tabEditorFunction?: boolean; lspCompletion?: boolean; lspTooltip?: boolean; lspLint?: boolean; placeholder?: HTMLElement | string; } /** * Builds an extension in a compartment that can * be reconfigured. */ interface IConfigurableBuilder { of: (value: T) => Extension; reconfigure: (value: T) => StateEffect; } /** * Editor configuration: provides APIs to get and reconfigure CodeMirror 6 * extensions from option names. Also allows to register new themes and * inject ne extensions in already configured editor instances. */ export declare class EditorConfiguration { constructor(options: IOptions); /** * Reconfigures the extension mapped with key with the provided value. */ reconfigureExtension(view: EditorView, key: string, value: T): void; /** * Reconfigures all the extensions mapped with the options from the * provided partial configuration. */ reconfigureExtensions(view: EditorView, config: Partial): void; /** * Appends extensions to the top-level configuration of the * editor. */ injectExtension(view: EditorView, ext: Extension): void; /** * Returns the list of initial extensions of an editor * based on the provided configuration. */ getInitialExtensions(config: CodeMirrorConfig): Extension[]; protected updateThemeOverload(config: Partial | Record): Extension; protected get(key: string): IConfigurableBuilder | undefined; protected _configurableBuilderMap: Map; protected _themeOverloaderSpec: Record>; protected _themeOverloader: Compartment; } export {}; //# sourceMappingURL=config.d.ts.map