UNPKG

@atlaskit/editor-plugin-annotation

Version:

Annotation plugin for @atlaskit/editor-core

54 lines (53 loc) 3.51 kB
import type { AnalyticsEventPayloadCallback } from '@atlaskit/editor-common/analytics'; import type { Mark, Node, ResolvedPos, Schema, Slice } from '@atlaskit/editor-prosemirror/model'; import type { EditorState, Selection, SelectionBookmark } from '@atlaskit/editor-prosemirror/state'; import { AllSelection, NodeSelection, PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state'; import { Decoration } from '@atlaskit/editor-prosemirror/view'; import type { AnnotationInfo, DraftBookmark, InlineCommentInputMethod, TargetType } from '../types'; import { AnnotationSelectionType } from '../types'; import type { InlineCommentPluginState } from './types'; /** * Finds the marks in the nodes to the left and right. * @param $pos Position to center search around */ export declare const surroundingMarks: ($pos: ResolvedPos) => (readonly Mark[])[]; export declare const getAllAnnotations: (doc: Node) => string[]; export declare const decorationKey: { block: string; inline: string; }; export declare const addDraftDecoration: (start: number, end: number, targetType?: TargetType) => Decoration; export declare const getAnnotationViewKey: (annotations: AnnotationInfo[]) => string; export declare const findAnnotationsInSelection: (selection: Selection, doc: Node) => AnnotationInfo[]; export declare const resolveDraftBookmark: (editorState: EditorState, bookmark?: SelectionBookmark, supportedBlockNodes?: string[]) => DraftBookmark; /** * get selection from position to apply new comment for * @returns bookmarked positions if they exists, otherwise current selection positions */ export declare function getSelectionPositions(editorState: EditorState, bookmark: SelectionBookmark | undefined): Selection; export declare const inlineCommentPluginKey: PluginKey<InlineCommentPluginState>; export declare const getPluginState: (state: EditorState) => InlineCommentPluginState | undefined; /** * get payload for the open/close analytics event */ export declare const getDraftCommandAnalyticsPayload: (drafting: boolean, inputMethod: InlineCommentInputMethod) => AnalyticsEventPayloadCallback; export declare const isSelectionValid: (state: EditorState, _supportedNodes?: string[]) => AnnotationSelectionType; export declare const hasInvalidNodes: (state: EditorState) => boolean; export declare const isSupportedBlockNode: (node: Node, supportedBlockNodes?: string[]) => boolean; /** * Checks if any of the nodes in a given selection are completely whitespace * This is to conform to Confluence annotation specifications */ export declare function hasInvalidWhitespaceNode(selection: TextSelection | AllSelection | NodeSelection, schema: Schema): boolean; export declare function annotationExists(annotationId: string, state: EditorState): boolean; export declare function stripNonExistingAnnotations(slice: Slice, state: EditorState): false | undefined; /** * Compares two sets of annotationInfos to see if the annotations have changed * This function assumes annotations will have unique id's for simplicity */ export declare function isSelectedAnnotationsChanged(oldSelectedAnnotations: AnnotationInfo[], newSelectedAnnotations: AnnotationInfo[]): boolean; /** * Checks if the selectedAnnotations are the same as the annotations on the selected block node */ export declare const isBlockNodeAnnotationsSelected: (selection: Selection, selectedAnnotations?: AnnotationInfo[]) => boolean; export declare const hasAnyUnResolvedAnnotationInPage: (state: EditorState) => boolean;