@atlaskit/editor-plugin-floating-toolbar
Version:
Floating toolbar plugin for @atlaskit/editor-core
61 lines (60 loc) • 3.66 kB
TypeScript
import React from 'react';
import type { IntlShape } from 'react-intl';
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import type { ExtractInjectionAPI, FloatingToolbarConfig, FloatingToolbarHandler, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { ConfigWithNodeInfo, FloatingToolbarPlugin, FloatingToolbarPluginState } from './floatingToolbarPluginType';
export declare const getRelevantConfig: (selection: Selection, configs: Array<FloatingToolbarConfig>) => ConfigWithNodeInfo | undefined;
export declare const floatingToolbarPlugin: FloatingToolbarPlugin;
/**
* React component that renders the floating toolbar UI for the editor.
*
* This component manages the display of floating toolbars based on the current editor state,
* selection, and configuration. It handles visibility conditions, positioning, toolbar items
* consolidation, and confirmation dialogs.
*
* @param props - Component properties
* @param props.pluginInjectionApi - Plugin injection API for accessing other plugin states
* @param props.editorView - ProseMirror EditorView instance
* @param props.popupsMountPoint - DOM element where popups should be mounted
* @param props.popupsBoundariesElement - Element that defines popup boundaries
* @param props.popupsScrollableElement - Scrollable container element for popups
* @param props.providerFactory - Factory for creating various providers
* @param props.dispatchAnalyticsEvent - Function to dispatch analytics events
* @returns JSX element representing the floating toolbar or null if not visible
*/
export declare function ContentComponent({ pluginInjectionApi, editorView, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, providerFactory, dispatchAnalyticsEvent, }: Pick<UiComponentFactoryParams, 'editorView' | 'popupsMountPoint' | 'popupsBoundariesElement' | 'providerFactory' | 'dispatchAnalyticsEvent' | 'popupsScrollableElement'> & {
pluginInjectionApi: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
} & {
editorView: EditorView;
}): React.JSX.Element | null;
/**
*
* ProseMirror Plugin
*
*/
export declare const pluginKey: PluginKey<FloatingToolbarPluginState>;
/**
* Creates a floating toolbar plugin for the ProseMirror editor.
*
* This factory function creates a SafePlugin that manages floating toolbars in the editor.
* It processes an array of floating toolbar handlers and determines which toolbar configuration
* should be active based on the current editor state and selection.
*
* @param options - Configuration object for the floating toolbar plugin
* @param options.floatingToolbarHandlers - Array of handlers that return toolbar configurations
* @param options.getIntl - Function that returns the IntlShape instance for internationalization
* @param options.providerFactory - Factory for creating various providers used by the editor
* @returns A SafePlugin instance that manages floating toolbar state and behavior
*/
export declare function floatingToolbarPluginFactory(options: {
api: ExtractInjectionAPI<FloatingToolbarPlugin> | undefined;
floatingToolbarHandlers: Array<FloatingToolbarHandler>;
getIntl: () => IntlShape;
providerFactory: ProviderFactory;
}): SafePlugin<{
getConfigWithNodeInfo: (editorState: EditorState) => ConfigWithNodeInfo | null | undefined;
}>;