@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
98 lines (97 loc) • 4.08 kB
TypeScript
import { MediaProvider, MediaState, MediaStateManager } from '@atlaskit/media-core';
import { MediaType } from './../../schema/nodes/media';
import { EditorState, EditorView, Plugin, PluginKey, Node as PMNode, Schema, Transaction } from '../../prosemirror';
import PickerFacade from './picker-facade';
import { MediaPluginOptions } from './media-plugin-options';
import { ProsemirrorGetPosHandler } from '../../nodeviews';
import { URLInfo } from './media-links';
import { Alignment, Display } from './single-image';
export declare type PluginStateChangeSubscriber = (state: MediaPluginState) => any;
export interface MediaNodeWithPosHandler {
node: PMNode;
getPos: ProsemirrorGetPosHandler;
}
export declare class MediaPluginState {
allowsMedia: boolean;
allowsUploads: boolean;
allowsLinks: boolean;
stateManager: MediaStateManager;
pickers: PickerFacade[];
binaryPicker?: PickerFacade;
ignoreLinks: boolean;
waitForMediaUpload: boolean;
private mediaNodes;
private options;
private view;
private pluginStateChangeSubscribers;
private useDefaultStateManager;
private destroyed;
private mediaProvider;
private errorReporter;
private popupPicker?;
private clipboardPicker?;
private dropzonePicker?;
private linkRanges;
constructor(state: EditorState<any>, options: MediaPluginOptions);
subscribe(cb: PluginStateChangeSubscriber): void;
unsubscribe(cb: PluginStateChangeSubscriber): void;
setMediaProvider: (mediaProvider?: Promise<MediaProvider> | undefined) => Promise<void>;
insertFile: (mediaState: MediaState) => void;
insertLinks: () => Promise<(string | undefined)[] | undefined>;
splitMediaGroup: () => boolean;
insertFileFromDataUrl: (url: string, fileName: string) => void;
showMediaPicker: () => 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) => Promise<void>;
setView(view: EditorView): void;
/**
* Called from React UI Component when user clicks on "Delete" icon
* inside of it
*/
handleMediaNodeRemoval: (node: PMNode, getPos: ProsemirrorGetPosHandler) => void;
/**
* This is called when media node is removed from media group node view
*/
cancelInFlightUpload(id: string): void;
/**
* Called from React UI Component on componentDidMount
*/
handleMediaNodeMount: (node: PMNode, getPos: ProsemirrorGetPosHandler) => void;
/**
* Called from React UI Component on componentWillUnmount and componentWillReceiveProps
* when React component's underlying node property is replaced with a new node
*/
handleMediaNodeUnmount: (oldNode: PMNode) => void;
align: (alignment: Alignment, display?: Display) => boolean;
destroy(): void;
findMediaNode: (id: string) => MediaNodeWithPosHandler | null;
detectLinkRangesInSteps: (tr: Transaction, oldState: EditorState<any>) => URLInfo[] | undefined;
private destroyPickers;
private initPickers(uploadParams, context);
private collectionFromProvider();
private handleMediaState;
private notifyPluginStateSubscribers;
private removeNodeById;
private replaceNodeWithPublicId;
removeSelectedMediaNode: () => boolean;
private isMediaNodeSelection();
/**
* Since we replace nodes with public id when node is finalized
* stateManager contains no information for public ids
*/
private getMediaNodeStateStatus;
}
export declare const stateKey: PluginKey;
export declare const createPlugin: (schema: Schema<any, any>, options: MediaPluginOptions) => Plugin;
declare const plugins: (schema: Schema<any, any>, options: MediaPluginOptions) => Plugin[];
export default plugins;
export interface MediaData {
id: string;
type?: MediaType;
}