UNPKG

@atlaskit/editor-plugin-image-upload

Version:

Image upload plugin for @atlaskit/editor-core

39 lines 1.12 kB
import { insertActionForToolbar } from './pm-plugins/commands-toolbar'; // Ignored via go/ees005 // eslint-disable-next-line import/no-named-as-default import inputRulePlugin from './pm-plugins/input-rule'; import { createPlugin } from './pm-plugins/main'; import { stateKey } from './pm-plugins/plugin-key'; /** * Image upload plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor` * from `@atlaskit/editor-core`. */ export const imageUploadPlugin = () => { const uploadHandlerReference = { current: null }; return { name: 'imageUpload', getSharedState(editorState) { if (!editorState) { return undefined; } return stateKey.getState(editorState); }, actions: { startUpload: () => insertActionForToolbar(uploadHandlerReference) }, pmPlugins() { return [{ name: 'imageUpload', plugin: createPlugin(uploadHandlerReference) }, { name: 'imageUploadInputRule', plugin: ({ schema, featureFlags }) => inputRulePlugin(schema, featureFlags) }]; } }; };