UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

42 lines (41 loc) 1.22 kB
/// <reference types="react" /> import * as React from 'react'; import { EditorView, PluginKey } from '../../../prosemirror'; import { EventDispatcher } from '../../event-dispatcher'; export interface State { [name: string]: any; } export interface Props { eventDispatcher?: EventDispatcher; editorView?: EditorView; plugins: { [name: string]: PluginKey; }; render: (pluginsState: State) => React.ReactElement<any>; } /** * Wraps component in a high order component that watches state changes of given plugins * and passes those states to the wrapped component. * * Example: * <WithPluginState * eventDispatcher={eventDispatcher} * editorView={editorView} * plugins={{ * hyperlink: hyperlinkPluginKey * }} * render={renderComponent} * /> * * renderComponent: ({ hyperlink }) => React.Compoment; */ export default class WithPluginState extends React.Component<State, any> { state: {}; private listeners; private handlePluginStateChange(propName, pluginState); private subscribe(props); componentWillMount(): void; componentWillReceiveProps(nextProps: Props, prevProps: Props): void; componentWillUnmount(): void; render(): any; }