import { AnnotationTypes } from '@atlaskit/adf-schema'; import type { AnnotationActionResult, AnnotationByMatches, SelectionContext } from '@atlaskit/editor-common/types'; import type { JSONDocNode } from '@atlaskit/editor-json-transformer'; import type { Mark, Node, Schema } from '@atlaskit/editor-prosemirror/model'; import type { Step } from '@atlaskit/editor-prosemirror/transform'; import { RemoveMarkStep, RemoveNodeMarkStep } from '@atlaskit/editor-prosemirror/transform'; import type { AnalyticsEventPayload } from '../analytics/events'; type ActionResult = { doc: JSONDocNode; step: Step; } | false; type Position = { from: number; to: number; }; type Annotation = { annotationId: string; annotationType: AnnotationTypes; }; interface RendererActionsOptions { annotate: (range: Range, annotationId: string, annotationType: 'inlineComment') => ActionResult; deleteAnnotation: (annotationId: string, annotationType: 'inlineComment') => ActionResult; isValidAnnotationRange: (range: Range) => boolean; } export type ApplyAnnotation = (pos: Position, annotation: Annotation) => AnnotationActionResult; interface AnnotationsRendererActionsOptions { applyAnnotation: ApplyAnnotation; getAnnotationMarks: () => Mark[]; isValidAnnotationPosition: (pos: Position) => boolean; } interface PositionRendererActionsOptions { getPositionFromRange: (range: Range) => Position | false; } interface SelectionRendererActionsOptions { getSelectionContext: () => SelectionContext | null; } export default class RendererActions implements RendererActionsOptions, AnnotationsRendererActionsOptions, PositionRendererActionsOptions, SelectionRendererActionsOptions { private initFromContext; private transformer; doc?: Node; private schema?; private ref?; private onAnalyticsEvent?; constructor(initFromContext?: boolean); _privateRegisterRenderer(ref: React.MutableRefObject, doc: Node, schema: Schema, onAnalyticsEvent?: (event: AnalyticsEventPayload) => void): void; _privateUnregisterRenderer(): void; /** * Validate whether we can create an annotation between two positions */ _privateValidatePositionsForAnnotation(from: number, to: number): boolean; deleteAnnotation(annotationId: string, annotationType: 'inlineComment'): false | { step: RemoveNodeMarkStep | RemoveMarkStep; doc: JSONDocNode; }; annotate(range: Range, annotationId: string, _annotationType: 'inlineComment'): AnnotationActionResult; isValidAnnotationRange(range: Range | null): boolean; isRangeAnnotatable(range: Range | null): boolean; /** * This is replaced by `isRangeAnnotatable`. * * @deprecated **/ isRendererWithinRange(range: Range): boolean; isValidAnnotationPosition(pos: Position): boolean; /** * Note: False indicates that the selection not able to be calculated. */ getPositionFromRange(range: Range | null): Position | false; getSelectionContext(): SelectionContext | null; getAnnotationMarks(): Mark[]; getAnnotationsByPosition(range: Range): string[]; applyAnnotation(pos: Position, annotation: Annotation): AnnotationActionResult; generateAnnotationIndexMatch(pos: Position): AnnotationByMatches | false; getInlineNodeTypes(annotationId: string): string[] | undefined; } export {};