UNPKG

@atlaskit/editor-plugin-media

Version:

Media plugin for @atlaskit/editor-core

122 lines (121 loc) 6.4 kB
import type { IntlShape } from 'react-intl-next'; import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema'; import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher'; import type { ContextIdentifierProvider, MediaProvider } from '@atlaskit/editor-common/provider-factory'; import { SafePlugin } from '@atlaskit/editor-common/safe-plugin'; import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types'; import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model'; import type { EditorState } from '@atlaskit/editor-prosemirror/state'; import type { EditorView } from '@atlaskit/editor-prosemirror/view'; import type { MediaClientConfig } from '@atlaskit/media-core'; import type { MediaPluginOptions } from '../media-plugin-options'; import type { MediaNextEditorPluginType } from '../next-plugin-type'; import type { MediaStateEventSubscriber } from '../picker-facade'; import PickerFacade from '../picker-facade'; import type { MediaOptions, MediaState, MediaStateStatus, getPosHandlerNode as ProsemirrorGetPosHandler } from '../types'; import type { MediaNodeWithPosHandler, MediaPluginState } from './types'; export type { MediaState, MediaProvider, MediaStateStatus }; export { stateKey } from './plugin-key'; export declare const MEDIA_CONTENT_WRAP_CLASS_NAME = "media-content-wrap"; export declare const MEDIA_PLUGIN_IS_RESIZING_KEY = "mediaSinglePlugin.isResizing"; export declare const MEDIA_PLUGIN_RESIZING_WIDTH_KEY = "mediaSinglePlugin.resizing-width"; export declare class MediaPluginStateImplementation implements MediaPluginState { allowsUploads: boolean; mediaClientConfig?: MediaClientConfig; uploadMediaClientConfig?: MediaClientConfig; ignoreLinks: boolean; waitForMediaUpload: boolean; allUploadsFinished: boolean; showDropzone: boolean; isFullscreen: boolean; element?: HTMLElement; layout: MediaSingleLayout; mediaNodes: MediaNodeWithPosHandler[]; options: MediaPluginOptions; mediaProvider?: MediaProvider; newInsertionBehaviour?: boolean; isResizing: boolean; resizingWidth: number; currentMaxWidth?: number; allowInlineImages: boolean; private view; private destroyed; private contextIdentifierProvider?; private errorReporter; private customPicker?; private removeOnCloseListener; private openMediaPickerBrowser?; private onPopupToggleCallback; private nodeCount; private taskManager; pickers: PickerFacade[]; pickerPromises: Array<Promise<PickerFacade>>; editingMediaSinglePos?: number; showEditingDialog?: boolean; mediaOptions?: MediaOptions; dispatch?: Dispatch; pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined; singletonCreatedAt: number; constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined); clone(): this; onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>; setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>; getMediaOptions: () => MediaPluginOptions; setIsResizing(isResizing: boolean): void; setResizingWidth(width: number): void; updateElement(): void; private isMediaSchemaNode; private getDomElement; /** * we insert a new file by inserting a initial state for that file. * * called when we insert a new file via the picker (connected via pickerfacade) */ insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string) => void; addPendingTask: (task: Promise<any>) => void; splitMediaGroup: () => boolean; onPopupPickerClose: () => void; showMediaPicker: () => void; setBrowseFn: (browseFn: () => void) => void; onPopupToggle: (onPopupToggleCallback: (isOpen: boolean) => void) => void; /** * Returns a promise that is resolved after all pending operations have been finished. * An optional timeout will cause the promise to reject if the operation takes too long * * NOTE: The promise will resolve even if some of the media have failed to process. */ waitForPendingTasks: (timeout?: number | undefined, lastTask?: Promise<MediaState | null> | undefined) => Promise<MediaState | null>; setView(view: EditorView): void; /** * Called from React UI Component when user clicks on "Delete" icon * inside of it */ handleMediaNodeRemoval: (node: PMNode | undefined, getPos: ProsemirrorGetPosHandler) => void; trackMediaNodeAddition: (node: PMNode) => void; trackMediaNodeRemoval: (node: PMNode) => void; /** * Called from React UI Component on componentDidMount */ handleMediaNodeMount: (node: PMNode, getPos: ProsemirrorGetPosHandler) => void; /** * Called from React UI Component on componentWillUnmount and UNSAFE_componentWillReceiveProps * when React component's underlying node property is replaced with a new node */ handleMediaNodeUnmount: (oldNode: PMNode) => void; handleMediaGroupUpdate: (oldNodes: PMNode[], newNodes: PMNode[]) => void; destroy(): void; findMediaNode: (id: string) => MediaNodeWithPosHandler | null; private destroyAllPickers; private destroyPickers; private initPickers; private getInputMethod; updateMediaSingleNodeAttrs: (id: string, attrs: object) => boolean | undefined; private collectionFromProvider; private handleMediaState; removeSelectedMediaContainer: () => boolean; selectedMediaContainerNode: () => PMNode | undefined; handleDrag: (dragState: 'enter' | 'leave') => void; updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void; } export declare const getMediaPluginState: (state: EditorState) => MediaPluginState; export declare const createPlugin: (_schema: Schema, options: MediaPluginOptions, reactContext: () => {}, getIntl: () => IntlShape, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined, dispatch?: Dispatch, mediaOptions?: MediaOptions, newInsertionBehaviour?: boolean) => SafePlugin<MediaPluginState>;