import { Editor } from './editor'; import { Cell, type CellStyle, type CellValue, Rectangle, type Theme } from '../../../treb-base-types/src/index'; import { DataModel, type ViewModel, type GridSelection } from '../../../treb-data-model/src/index'; import { Autocomplete } from './autocomplete'; export type OverlayEditorResult = 'handled' | 'commit' | 'discard'; /** * but when to send it? */ export interface ResetSelectionEvent { type: 'reset-selection'; } export declare class OverlayEditor extends Editor { private container; private theme; /** * selection being edited. note that this is private rather than protected * in an effort to prevent subclasses from accidentally using shallow copies */ private internal_selection; /** accessor for selection */ get selection(): GridSelection; /** set selection, deep copy */ set selection(rhs: GridSelection); /** possibly carrying over a font face (+size?) */ edit_style?: CellStyle; /** * this is a flag used to indicate when we need to reset the selection. * the issue has to do with selecting cells via arrow keys; if you do * that twice, the second time the selection starts on the cell you * selected the first time. so we want to fix that. * * I guess that used to work with an 'end-selection' event (although it * didn't change the sheet) but that doesn't happen anymore because * selecting state is determined dynamically now. */ reset_selection: boolean; /** we could use the descriptor reference */ edit_node: HTMLElement & ElementContentEditable; /** narrowing from superclass */ container_node: HTMLElement; /** special node for ICE */ edit_inset: HTMLElement; scale: number; /** shadow property */ private internal_editing; /** accessor */ get editing(): boolean; /** * this is only set one time for each state, so it would be more * efficient to inline it unless that's going to change */ protected set editing(state: boolean); constructor(container: HTMLElement, theme: Theme, model: DataModel, view: ViewModel, autocomplete: Autocomplete); UpdateCaption(text?: string): void; Focus(text?: string): void; CloseEditor(): void; /** * remove contents, plus add mozilla junk node */ ClearContents(): void; /** * start editing. I'm not sure why we're passing the selection around, * but I don't want to take it out until I can answer that question. * * something to do with keyboard selection? (which needs to be fixed)? */ Edit(gridselection: GridSelection, rect: Rectangle, cell: Cell, value?: CellValue, event?: Event, edit_style?: CellStyle): void; GetEditState(): { text: string; substring: string; }; /** * check if we want to handle this key. we have some special cases (tab, * enter, escape) where we do take some action but we also let the * spreadsheet handle the key. for those we have some additional return * values. * * NOTE this is *not* added as an event handler -- it's called by the grid * * @param event * @returns */ HandleKeyDown(event: KeyboardEvent): OverlayEditorResult | undefined; UpdateScale(scale: number): void; }