UNPKG

@atlaskit/editor-plugin-loom

Version:

Loom plugin for @atlaskit/editor-core

47 lines 1.84 kB
import React from 'react'; import { INPUT_METHOD } from '@atlaskit/editor-common/analytics'; import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages'; import { logException } from '@atlaskit/editor-common/monitoring'; import VideoIcon from '@atlaskit/icon/core/video'; 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: "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; } }];