@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
66 lines (65 loc) • 2.73 kB
TypeScript
import { MentionProvider, MentionDescription } from '@atlaskit/mention';
import { EditorState, EditorView, Schema, Plugin, PluginKey } from '../../prosemirror';
import ProviderFactory from '../../providerFactory';
import { Transaction } from '../../prosemirror/prosemirror-state/transaction';
export declare const stateKey: PluginKey;
export declare type MentionsStateSubscriber = (state: MentionsState) => any;
export declare type StateChangeHandler = (state: MentionsState) => any;
export declare type ProviderChangeHandler = (provider?: MentionProvider) => any;
export declare class MentionsState {
query?: string;
queryActive: boolean;
enabled: boolean;
anchorElement?: HTMLElement;
mentionProvider?: MentionProvider;
onSelectPrevious: () => boolean;
onSelectNext: () => boolean;
onSelectCurrent: () => boolean;
private changeHandlers;
private state;
private view;
private dirty;
private currentQueryResult?;
private queryResults;
private tokens;
private previousQueryResultCount;
constructor(state: EditorState<any>, providerFactory: ProviderFactory);
subscribe(cb: MentionsStateSubscriber): void;
unsubscribe(cb: MentionsStateSubscriber): void;
apply(tr: Transaction, state: EditorState<any>): void;
update(state: EditorState<any>): void;
private rangeHasNodeMatchingQuery(doc, from, to, query);
dismiss(): boolean;
generateDismissTransaction(tr?: Transaction): Transaction;
isEnabled(state?: EditorState<any>): boolean;
private findMentionQueryMarks(active?);
private findActiveMentionQueryMark();
insertMention(mentionData?: MentionDescription, queryMark?: {
start;
end;
}): void;
generateInsertMentionTransaction(mentionData?: MentionDescription, queryMark?: {
start;
end;
}, tr?: Transaction): Transaction;
isNextCharacterSpace(position: number, doc: any): boolean;
handleProvider: (name: string, provider: Promise<any>) => void;
setMentionProvider(provider?: Promise<MentionProvider>): Promise<MentionProvider>;
trySelectCurrent(): boolean;
tryInsertingPreviousMention(): void;
onMentionResult: (mentions: MentionDescription[], query: string) => void;
private isSubQueryOfCurrentQuery(query);
private findExactMatch(query, mentions);
private clearState();
setView(view: EditorView): void;
insertMentionQuery(): void;
}
export declare function createPlugin(providerFactory: ProviderFactory): Plugin;
export interface Mention {
name: string;
mentionName: string;
nickname?: string;
id: string;
}
declare const plugins: (schema: Schema<any, any>, providerFactory: any) => Plugin[];
export default plugins;