import type { JupyterFrontEnd } from '@jupyterlab/application'; import type { EditorView } from '@codemirror/view'; import type { Widget } from '@lumino/widgets'; import type { IAskAgentRequest } from './tokens'; /** * A CodeMirror view a selection can be asked about, plus the context needed * to describe it to an agent: the document path and, for notebooks, which * cell the view belongs to. */ interface IEditorTarget { view: EditorView; path: string; cell?: { index: number; type: string; }; } /** * Resolve the CodeMirror view a selection in `widget` would live in, or * `null` when the widget holds no such editor. Two widget shapes are * recognized: * * - a notebook panel, where the active cell carries the editor and * `activeCellIndex` names its 0-based position in the nbformat `cells` * array. A rendered markdown cell keeps its (hidden) editor, but a * selection in the rendered HTML never passes {@link domSelectionInView}, * so no pill appears there; and * - a document widget whose content is a `FileEditor`. The wrapper is not * checked with `instanceof DocumentWidget`: `@jupyterlab/docregistry` is * not a core singleton, so another copy of the class could be in play. * `FileEditor` and `NotebookPanel` come from singleton packages. */ export declare function resolveEditorTarget(widget: Widget | null): IEditorTarget | null; /** * Whether the current DOM selection lives inside `view`. Guards the * selection-change listener against selections made elsewhere (a terminal, * a sidebar, another notebook cell) while the widget owning `view` happens * to be the shell's current widget. */ export declare function domSelectionInView(view: EditorView, selection: Selection): boolean; /** * Build an ask-agent request from the current selection in the shell's * current widget — a file editor or the active notebook cell — or return * `null` when that widget holds no CodeMirror document editor. * * With `allowEmpty`, a collapsed selection falls back to the cursor's line * (used by the command/shortcut path so it works without a mouse * selection); otherwise an empty selection yields `null`. */ export declare function editorAskRequest(app: JupyterFrontEnd, options?: { allowEmpty?: boolean; }): IAskAgentRequest | null; export {};