UNPKG

@atlaskit/editor-plugin-annotation

Version:

Annotation plugin for @atlaskit/editor-core

50 lines (49 loc) 2.37 kB
import type { IntlShape } from 'react-intl'; import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics'; import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types'; import type { PopupPosition } from '@atlaskit/editor-common/ui'; import type { NodeType } from '@atlaskit/editor-prosemirror/model'; import type { SelectionBookmark, EditorState } from '@atlaskit/editor-prosemirror/state'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { AnnotationPlugin } from '../annotationPluginType'; import { type AnnotationProviders } from '../types'; interface BuildToolbarOptions { _supportedNodes?: string[]; annotationManager?: AnnotationProviders['annotationManager']; api?: ExtractInjectionAPI<AnnotationPlugin>; contentType?: string; createCommentExperience?: AnnotationProviders['createCommentExperience']; getCanAddComments?: () => boolean; intl: IntlShape; isCommentOnMediaOn?: boolean; isToolbarAbove?: boolean; onCommentButtonMount?: () => void; state: EditorState; } type ShouldSuppressFloatingToolbarOptions = { bookmark?: SelectionBookmark; state: EditorState; }; /** * Should suppress toolbars when the user is creating an inline comment * This only applies when the selection range exactly matches the bookmark range * which should be the case immediately after the comment button is clicked * if the user creates a different selection range, the floating toolbar should still be shown * @param root0 * @param root0.state * @param root0.bookmark * @example */ export declare const shouldSuppressFloatingToolbar: ({ state, bookmark, }: ShouldSuppressFloatingToolbarOptions) => boolean; export declare const buildSuppressedToolbar: (state: EditorState) => { items: never[]; nodeType: NodeType[]; title: string; }; export declare const buildToolbar: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ state, intl, isToolbarAbove, _supportedNodes, api, createCommentExperience, annotationManager, onCommentButtonMount, getCanAddComments, contentType, }: BuildToolbarOptions) => { items: FloatingToolbarButton<Command>[]; nodeType: NodeType[]; onPositionCalculated: (editorView: EditorView, nextPos: PopupPosition) => PopupPosition; title: string; } | undefined; export {};