UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

32 lines (31 loc) 2.49 kB
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model'; import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { AnalyticsEventPayload } from '../analytics'; import type { Command } from '../types'; export { RelativeSelectionPos } from './types'; export type { SelectionPluginState, EditorSelectionAPI, SelectionPluginOptions, SelectionSharedState, SetSelectionRelativeToNode, } from './types'; export { GapCursorSelection, Side, JSON_ID, GapBookmark, } from './gap-cursor/selection'; export { setSelectionTopLevelBlocks, setGapCursorAtPos, } from './gap-cursor/actions'; export { isIgnored, isValidTargetNode } from './gap-cursor/utils'; export { setGapCursorSelection } from './gap-cursor/utils/setGapCursorSelection'; export { hideCaretModifier, gapCursorStyles } from './gap-cursor/styles'; export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, isSelectionAtEndOfNode, isSelectionAtStartOfNode, startPositionOfParent, } from './utils'; export declare function getNodeSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined; export declare function getAllSelectionAnalyticsPayload(selection: Selection): AnalyticsEventPayload | undefined; export declare function getCellSelectionAnalyticsPayload(state: EditorState): AnalyticsEventPayload | undefined; export declare function getRangeSelectionAnalyticsPayload(selection: Selection, doc: PmNode): AnalyticsEventPayload | undefined; /** * Insert content, delete a range and create a new selection * This function automatically handles the mapping of positions for insertion and deletion. * The new selection is handled as a function since it may not always be necessary to resolve a position to the transactions mapping * * @param getSelectionResolvedPos get the resolved position to create a new selection * @param insertions content to insert at the specified position * @param deletions the ranges to delete */ export declare const selectNode: (pos: number) => Command; export declare function createSelectionClickHandler(nodes: string[], isValidTarget: (target: HTMLElement) => boolean, options: { useLongPressSelection: boolean; getNodeSelectionPos?: (state: EditorState, nodePos: number) => number; }): (view: EditorView, pos: number, node: PmNode, nodePos: number, event: MouseEvent, direct: boolean) => boolean;