@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
58 lines (57 loc) • 2.42 kB
TypeScript
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
import { type FireAnalyticsCallback } from '../analytics';
import type { BasePluginDependenciesAPI, CorePlugin, NextEditorPlugin, PluginDependenciesAPI } from '../types/next-editor-plugin';
type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>;
type SharedStateAPIProps = {
getEditorState: () => EditorState | undefined;
};
interface PluginInjectionAPIProps extends SharedStateAPIProps {
getEditorView: () => EditorView | undefined;
fireAnalyticsEvent?: FireAnalyticsCallback;
}
export type EditorStateDiff = {
readonly newEditorState: EditorState;
readonly oldEditorState: EditorState | undefined;
};
export declare class PluginsData {
}
export declare class SharedStateAPI {
private getEditorState;
private listeners;
constructor({ getEditorState }: SharedStateAPIProps);
createAPI(plugin: NextEditorPluginInitializedType | undefined): PluginDependenciesAPI<NextEditorPlugin<any, any>>['sharedState'];
private cleanupSubscription;
private updatesToNotifyQueue;
notifyListeners({ newEditorState, oldEditorState, plugins, }: EditorStateDiff & Record<'plugins', Map<string, NextEditorPluginInitializedType>>): void;
destroy(): void;
}
type EditorStateDelta = {
readonly newEditorState: EditorState;
readonly oldEditorState: EditorState;
};
interface PluginInjectionAPIDefinition {
api: () => {
[key: string]: BasePluginDependenciesAPI<any>;
};
onEditorViewUpdated: (props: EditorStateDelta) => void;
onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
}
type GenericAPIWithCore = {
core: PluginDependenciesAPI<CorePlugin>;
[key: string]: BasePluginDependenciesAPI<any>;
};
export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefinition {
private sharedStateAPI;
private actionsAPI;
private commandsAPI;
private plugins;
constructor({ getEditorState, getEditorView, fireAnalyticsEvent }: PluginInjectionAPIProps);
private createAPI;
api(): GenericAPIWithCore;
onEditorViewUpdated: ({ newEditorState, oldEditorState }: EditorStateDiff) => void;
onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void;
private addPlugin;
private getPluginByName;
}
export {};