UNPKG

@atlaskit/editor-plugin-loom

Version:

Loom plugin for @atlaskit/editor-core

52 lines 2.19 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 var getQuickInsertItem = function getQuickInsertItem(editorAnalyticsAPI) { return function (_ref) { var formatMessage = _ref.formatMessage; return [{ id: 'loom', title: formatMessage(toolbarInsertBlockMessages.recordVideo), description: formatMessage(toolbarInsertBlockMessages.recordVideoDescription), keywords: ['loom', 'record', 'video'], priority: 800, isDisabledOffline: true, icon: function icon() { return /*#__PURE__*/React.createElement(VideoIcon, { label: "", color: "var(--ds-icon-subtle, #505258)", spacing: "spacious" }); }, action: function action(insert, editorState) { var _recordVideo; var tr = insert(undefined); var loomState = loomPluginKey.getState(editorState); if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) { var _recordVideoFailed; var 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: editorAnalyticsAPI })({ tr: tr })) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false; } return (_recordVideo = recordVideo({ inputMethod: INPUT_METHOD.QUICK_INSERT, editorAnalyticsAPI: editorAnalyticsAPI })({ tr: tr })) !== null && _recordVideo !== void 0 ? _recordVideo : false; } }]; }; };