import React from 'react'; import { EditorPlugin } from '../../types'; import { WithProviders, Providers } from '@atlaskit/editor-common'; import { pluginKey as blockTypeStateKey } from '../block-type/pm-plugins/main'; import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key'; import { stateKey as hyperlinkPluginKey } from '../hyperlink/pm-plugins/main'; import { mentionPluginKey } from '../mentions'; import { pluginKey as layoutStateKey } from '../layout'; import { MacroState, insertMacroFromMacroBrowser } from '../macro'; import { emojiPluginKey } from '../emoji'; import WithPluginState from '../../ui/WithPluginState'; import ToolbarInsertBlock from './ui/ToolbarInsertBlock'; import { insertBlockTypesWithAnalytics } from '../block-type/commands'; import { startImageUpload } from '../image-upload/pm-plugins/commands'; import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/main'; import { INPUT_METHOD } from '../analytics'; import { stateKey as imageUploadStateKey } from '../image-upload/pm-plugins/plugin-key'; import { pluginKey as dateStateKey } from '../date/pm-plugins/plugin-key'; import { pluginKey as placeholderTextStateKey } from '../placeholder-text/plugin-key'; import { pluginKey as macroStateKey } from '../macro/plugin-key'; import { ToolbarSize } from '../../ui/Toolbar/types'; const toolbarSizeToButtons = (toolbarSize: ToolbarSize) => { switch (toolbarSize) { case ToolbarSize.XXL: case ToolbarSize.XL: case ToolbarSize.L: case ToolbarSize.M: return 7; case ToolbarSize.S: return 2; default: return 0; } }; export interface InsertBlockOptions { allowTables?: boolean; allowExpand?: boolean; insertMenuItems?: any; horizontalRuleEnabled?: boolean; nativeStatusSupported?: boolean; replacePlusMenuWithElementBrowser?: boolean; showElementBrowserLink?: boolean; allowLocalIdGenerationOnTables?: boolean; } /** * Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method * @param name Block name */ function handleInsertBlockType(name: string) { return insertBlockTypesWithAnalytics(name, INPUT_METHOD.TOOLBAR); } const insertBlockPlugin = (options: InsertBlockOptions = {}): EditorPlugin => ({ name: 'insertBlock', primaryToolbarComponent({ editorView, editorActions, dispatchAnalyticsEvent, providerFactory, popupsMountPoint, popupsBoundariesElement, popupsScrollableElement, toolbarSize, disabled, isToolbarReducedSpacing, isLastItem, }) { const buttons = toolbarSizeToButtons(toolbarSize); const renderNode = (providers: Providers) => { return ( ( )} /> ); }; return ( ); }, }); export default insertBlockPlugin;