@atlaskit/editor-plugin-mentions
Version:
Mentions plugin for @atlaskit/editor-core
46 lines (45 loc) • 2.31 kB
TypeScript
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import type { ResolvingMentionProvider } from '@atlaskit/mention/resource';
import type { MentionsPlugin } from '../mentionsPluginType';
import type { FireElementsChannelEvent, MentionPluginOptions, MentionPluginState } from '../types';
export declare const ACTIONS: {
COMMIT_PENDING_TYPED_AGENT_MENTION: string;
DISCARD_PENDING_TYPED_AGENT_MENTION: string;
SET_PENDING_TYPED_AGENT_MENTION: string;
SET_PROVIDER: string;
/**
* Dispatched from view().update() when async resolveMentionName() resolves
* for a pasted agent mention.
* Updates lastInsertedAgentMentionName so the nudge shows the correct name.
*/
RESOLVE_PASTED_AGENT_MENTION_NAME: string;
/**
* Dispatched from view().update() when async resolveMentionName() resolves
* with a non-OK status for a pasted agent mention.
* Clears pendingPastedAgentMention so no retry loop occurs.
*/
CLEAR_PENDING_PASTED_AGENT_MENTION: string;
};
/**
* Resolves the name of a pasted agent mention via the mention provider and
* dispatches the appropriate action to update plugin state.
*
* Handles both async (Promise) and synchronous cache-hit results:
* - On OK resolution → dispatches RESOLVE_PASTED_AGENT_MENTION_NAME so the nudge
* shows the correct agent name.
* - On non-OK result → dispatches CLEAR_PENDING_PASTED_AGENT_MENTION to prevent
* an infinite retry loop on subsequent update() calls.
*
* Guards against duplicate in-flight requests via pendingResolveMentionIds.
*/
export declare const resolveAndDispatchPastedAgentMentionName: (agentId: string, mentionProvider: ResolvingMentionProvider, pendingResolveMentionIds: Set<string>, view: EditorView) => void;
interface CreateMentionPlugin {
api?: ExtractInjectionAPI<MentionsPlugin>;
fireEvent: FireElementsChannelEvent;
options?: MentionPluginOptions;
pmPluginFactoryParams: PMPluginFactoryParams;
}
export declare function createMentionPlugin({ pmPluginFactoryParams, fireEvent, options, api, }: CreateMentionPlugin): SafePlugin<MentionPluginState>;
export {};