UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

54 lines (53 loc) 3.32 kB
import type { EditorState } from '@atlaskit/editor-prosemirror/state'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { NextEditorPlugin, PluginDependenciesAPI, PluginInjectionAPI } from '../types/next-editor-plugin'; type NextEditorPluginInitializedType = ReturnType<NextEditorPlugin<any>>; type SharedStateAPIProps = { getEditorState: () => EditorState | undefined; }; interface PluginInjectionAPIProps extends SharedStateAPIProps { getEditorView: () => EditorView | undefined; } 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: <T extends NextEditorPlugin<any, any>>() => PluginInjectionAPI<T extends NextEditorPlugin<infer Name, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata> ? Metadata : never>['dependencies']; onEditorViewUpdated: (props: EditorStateDelta) => void; onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void; } export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefinition { private sharedStateAPI; private actionsAPI; private commandsAPI; private plugins; constructor({ getEditorState, getEditorView }: PluginInjectionAPIProps); api<T extends NextEditorPlugin<any, any>>(): import("../types/next-editor-plugin").PublicPluginAPI<[ NextEditorPlugin<T extends import("./core-plugin").CorePlugin<infer Name extends string, any, any> ? Name : never, T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never>, ..."dependencies" extends keyof (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never) ? (T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"] extends (import("./core-plugin").CorePlugin<any, any, any> | import("../types/next-editor-plugin").OptionalPlugin<import("./core-plugin").CorePlugin<any, any, any>>)[] ? Exclude<(T extends NextEditorPlugin<any, infer Metadata extends import("../types/next-editor-plugin").NextEditorPluginMetadata> ? Metadata : never)["dependencies"], undefined> : [ ] : [ ] ]>; onEditorViewUpdated: ({ newEditorState, oldEditorState, }: EditorStateDiff) => void; onEditorPluginInitialized: (plugin: NextEditorPluginInitializedType) => void; private addPlugin; private getPluginByName; } export {};