UNPKG

@atlaskit/editor-plugin-loom

Version:

Loom plugin for @atlaskit/editor-core

48 lines • 2.04 kB
import React from 'react'; import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums'; import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages/insert-block'; import { logException } from '@atlaskit/editor-common/monitoring/error'; import VideoIcon from '@atlaskit/icon/core/video'; import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled'; import { recordVideo, recordVideoFailed } from '../pm-plugins/commands'; import { loomPluginKey } from '../pm-plugins/main'; export const getQuickInsertItem = editorAnalyticsAPI => ({ formatMessage }) => [{ id: 'loom', title: formatMessage(toolbarInsertBlockMessages.recordVideo), description: formatMessage(toolbarInsertBlockMessages.recordVideoDescription), keywords: ['loom', 'record', 'video'], priority: 800, isDisabledOffline: true, icon: () => /*#__PURE__*/React.createElement(VideoIcon, { label: "", color: isExperimentEnabled('platform_editor_slash_command') ? undefined : "var(--ds-icon-subtle, #505258)", spacing: "spacious" }), action(insert, editorState) { var _recordVideo; const tr = insert(undefined); const loomState = loomPluginKey.getState(editorState); if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) { var _recordVideoFailed; const errorMessage = loomState === null || loomState === void 0 ? void 0 : loomState.error; logException(new Error(errorMessage), { location: 'editor-plugin-loom/quick-insert-record-video' }); return (_recordVideoFailed = recordVideoFailed({ inputMethod: INPUT_METHOD.QUICK_INSERT, error: errorMessage, editorAnalyticsAPI })({ tr })) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false; } return (_recordVideo = recordVideo({ inputMethod: INPUT_METHOD.QUICK_INSERT, editorAnalyticsAPI })({ tr })) !== null && _recordVideo !== void 0 ? _recordVideo : false; } }];