import { type JSONPatchDocument, type JSONPath } from 'immutable-json-patch'; import type { AfterSelection, CaretPosition, DocumentState, EditKeySelection, EditValueSelection, InsideSelection, JSONEditorSelection, JSONParser, JSONSelection, KeySelection, MultiSelection, TextSelection, ValueSelection } from '../types.js'; import { SelectionType } from '../types.js'; export declare function isAfterSelection(selection: JSONEditorSelection | undefined): selection is AfterSelection; export declare function isInsideSelection(selection: JSONEditorSelection | undefined): selection is InsideSelection; export declare function isKeySelection(selection: JSONEditorSelection | undefined): selection is KeySelection; export declare function isValueSelection(selection: JSONEditorSelection | undefined): selection is ValueSelection; export declare function isMultiSelection(selection: JSONEditorSelection | undefined): selection is MultiSelection; export declare function isMultiSelectionWithOneItem(selection: JSONEditorSelection | undefined): selection is MultiSelection; export declare function isJSONSelection(selection: JSONEditorSelection | undefined): selection is JSONSelection; export declare function isTextSelection(selection: JSONEditorSelection | undefined): selection is TextSelection; /** * Expand a selection start and end into an array containing all paths * between (and including) start and end */ export declare function getSelectionPaths(json: unknown, selection: JSONSelection): JSONPath[]; /** * Expand a selection start and end into an array containing all paths * between (and including) start and end. * * The function iterates always from start to end, independent of the order * of focusPath and anchorPath. * * When the callback returns something other than undefined, the iteration is * canceled and the value returned by the callback is returned by iterateOverSelection. */ export declare function iterateOverSelection(json: unknown | undefined, selection: JSONSelection | undefined, callback: (path: JSONPath) => void | undefined | T): void | undefined | T; export declare function getParentPath(selection: JSONSelection): JSONPath; export declare function getStartPath(json: unknown, selection: JSONSelection): JSONPath; export declare function getEndPath(json: unknown, selection: JSONSelection): JSONPath; export declare function isSelectionInsidePath(selection: JSONSelection, path: JSONPath): boolean; export declare function getSelectionUp(json: unknown, documentState: DocumentState | undefined, selection: JSONSelection | undefined, keepAnchorPath?: boolean): JSONSelection | undefined; export declare function getSelectionDown(json: unknown, documentState: DocumentState | undefined, selection: JSONSelection | undefined, keepAnchorPath?: boolean): JSONSelection | undefined; /** * Get the next selection for a value inside the current object/array * If there is no next value, select AFTER. * Only applicable for ValueSelection */ export declare function getSelectionNextInside(json: unknown, documentState: DocumentState | undefined, path: JSONPath): JSONSelection | undefined; /** * Find the caret position and its siblings for a given selection */ export declare function findCaretAndSiblings(json: unknown, documentState: DocumentState | undefined, selection: JSONSelection | undefined, includeInside: boolean): { next: CaretPosition | undefined; caret: CaretPosition | undefined; previous: CaretPosition | undefined; }; export declare function getSelectionLeft(json: unknown, documentState: DocumentState | undefined, selection: JSONSelection | undefined, keepAnchorPath?: boolean, includeInside?: boolean): JSONSelection | undefined; export declare function getSelectionRight(json: unknown, documentState: DocumentState | undefined, selection: JSONSelection | undefined, keepAnchorPath?: boolean, includeInside?: boolean): JSONSelection | undefined; /** * Get a proper initial selection based on what is visible */ export declare function getInitialSelection(json: unknown, documentState: DocumentState | undefined): JSONSelection; export declare function createSelectionFromOperations(json: unknown, operations: JSONPatchDocument): JSONSelection | undefined; /** * Find the common path of two paths. * For example findCommonRoot(['arr', '1', 'name'], ['arr', '1', 'address', 'contact']) returns ['arr', '1'] */ export declare function findSharedPath(path1: JSONPath, path2: JSONPath): JSONPath; export declare function singleItemSelected(selection: JSONSelection | undefined): boolean; export declare function findRootPath(json: unknown, selection: JSONSelection): JSONPath; export declare function pathStartsWith(path: JSONPath, parentPath: JSONPath): boolean; export declare function removeEditModeFromSelection(selection: JSONSelection | undefined): JSONSelection | undefined; export declare function createKeySelection(path: JSONPath): KeySelection; export declare function createEditKeySelection(path: JSONPath, initialValue?: string): EditKeySelection; export declare function createValueSelection(path: JSONPath): ValueSelection; export declare function createEditValueSelection(path: JSONPath, initialValue?: string): EditValueSelection; export declare function createInsideSelection(path: JSONPath): InsideSelection; export declare function createAfterSelection(path: JSONPath): AfterSelection; export declare function createMultiSelection(anchorPath: JSONPath, focusPath: JSONPath): MultiSelection; /** * Turn selected contents into plain text partial JSON, usable for copying to * clipboard for example. */ export declare function selectionToPartialJson(json: unknown, selection: JSONSelection | undefined, indentation: number | string | undefined, parser: JSONParser): string | undefined; export declare function isEditingSelection(selection: JSONSelection | undefined): selection is EditKeySelection | EditValueSelection; /** * Create a selection which selects the root of the document */ export declare function selectAll(): JSONSelection; export declare function hasSelectionContents(selection: JSONSelection | undefined): boolean; /** * Test whether the current selection can be converted. * That is the case when the selection is a key/value, or a multi selection with only one path */ export declare function canConvert(selection: JSONSelection | undefined): boolean; export declare function fromCaretPosition(caretPosition: CaretPosition): JSONSelection; export declare function fromSelectionType(selectionType: SelectionType, path: JSONPath): JSONSelection; export declare function selectionIfOverlapping(json: unknown | undefined, selection: JSONSelection | undefined, path: JSONPath): JSONSelection | undefined; export declare function pathInSelection(json: unknown | undefined, selection: JSONSelection | undefined, path: JSONPath): boolean; export declare function getFocusPath(selection: JSONSelection): JSONPath; export declare function getAnchorPath(selection: JSONSelection): JSONPath;