@atlaskit/editor-plugin-loom 2.8.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/commands.js +109 -2
  3. package/dist/cjs/plugin.js +12 -58
  4. package/dist/cjs/pm-plugin.js +2 -78
  5. package/dist/cjs/types.js +5 -1
  6. package/dist/cjs/ui/PrimaryToolbarButton.js +99 -0
  7. package/dist/cjs/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +43 -24
  8. package/dist/cjs/ui/quickInsert.js +56 -0
  9. package/dist/es2019/commands.js +93 -0
  10. package/dist/es2019/plugin.js +15 -57
  11. package/dist/es2019/pm-plugin.js +3 -64
  12. package/dist/es2019/types.js +1 -0
  13. package/dist/es2019/ui/PrimaryToolbarButton.js +84 -0
  14. package/dist/es2019/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +40 -22
  15. package/dist/es2019/ui/quickInsert.js +44 -0
  16. package/dist/esm/commands.js +107 -1
  17. package/dist/esm/plugin.js +13 -58
  18. package/dist/esm/pm-plugin.js +3 -79
  19. package/dist/esm/types.js +1 -0
  20. package/dist/esm/ui/PrimaryToolbarButton.js +90 -0
  21. package/dist/esm/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +39 -21
  22. package/dist/esm/ui/quickInsert.js +49 -0
  23. package/dist/types/commands.d.ts +5 -1
  24. package/dist/types/index.d.ts +1 -1
  25. package/dist/types/plugin.d.ts +14 -3
  26. package/dist/types/types.d.ts +32 -1
  27. package/dist/types/ui/PrimaryToolbarButton.d.ts +4 -0
  28. package/dist/types/ui/ToolbarButtonComponent.d.ts +20 -0
  29. package/dist/types/ui/quickInsert.d.ts +3 -0
  30. package/dist/types-ts4.5/commands.d.ts +5 -1
  31. package/dist/types-ts4.5/index.d.ts +1 -1
  32. package/dist/types-ts4.5/plugin.d.ts +14 -3
  33. package/dist/types-ts4.5/types.d.ts +32 -1
  34. package/dist/types-ts4.5/ui/PrimaryToolbarButton.d.ts +4 -0
  35. package/dist/types-ts4.5/ui/ToolbarButtonComponent.d.ts +20 -0
  36. package/dist/types-ts4.5/ui/quickInsert.d.ts +3 -0
  37. package/package.json +5 -3
  38. package/.eslintrc.js +0 -6
  39. package/dist/types/ui/ToolbarButton.d.ts +0 -798
  40. package/dist/types-ts4.5/ui/ToolbarButton.d.ts +0 -956
@@ -1,12 +1,8 @@
1
- import React from 'react';
2
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
- import { logException } from '@atlaskit/editor-common/monitoring';
5
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
6
- import { LoomIcon } from '@atlaskit/logo';
7
- import { insertLoom as _insertLoom, recordVideo, recordVideoFailed } from './commands';
2
+ import { insertLoom as _insertLoom, recordVideo, setupLoom } from './commands';
8
3
  import { createPlugin, loomPluginKey } from './pm-plugin';
9
- import LoomToolbarButton from './ui/ToolbarButton';
4
+ import { loomPrimaryToolbarComponent } from './ui/PrimaryToolbarButton';
5
+ import { getQuickInsertItem } from './ui/quickInsert';
10
6
  export var loomPlugin = function loomPlugin(_ref) {
11
7
  var _api$analytics, _api$primaryToolbar;
12
8
  var config = _ref.config,
@@ -19,18 +15,7 @@ export var loomPlugin = function loomPlugin(_ref) {
19
15
  var editorViewRef = {
20
16
  current: null
21
17
  };
22
- var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
23
- var disabled = _ref2.disabled,
24
- appearance = _ref2.appearance;
25
- if (!config.shouldShowToolbarButton) {
26
- return null;
27
- }
28
- return /*#__PURE__*/React.createElement(LoomToolbarButton, {
29
- disabled: disabled,
30
- api: api,
31
- appearance: appearance
32
- });
33
- };
18
+ var primaryToolbarComponent = loomPrimaryToolbarComponent(config, api);
34
19
  api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
35
20
  name: 'loom',
36
21
  component: primaryToolbarComponent
@@ -41,6 +26,10 @@ export var loomPlugin = function loomPlugin(_ref) {
41
26
  recordVideo: recordVideo,
42
27
  insertLoom: function insertLoom(video, positionType) {
43
28
  return _insertLoom(editorViewRef.current, api, video, positionType);
29
+ },
30
+ initLoom: function initLoom(_ref2) {
31
+ var loomProvider = _ref2.loomProvider;
32
+ return setupLoom(loomProvider, api, editorViewRef.current, true);
44
33
  }
45
34
  },
46
35
  pmPlugins: function pmPlugins() {
@@ -78,45 +67,11 @@ export var loomPlugin = function loomPlugin(_ref) {
78
67
  },
79
68
  pluginsOptions: {
80
69
  // Enable inserting Loom recordings through the slash command
81
- quickInsert: function quickInsert(_ref3) {
82
- var formatMessage = _ref3.formatMessage;
83
- return [{
84
- id: 'loom',
85
- title: formatMessage(toolbarInsertBlockMessages.recordVideo),
86
- description: formatMessage(toolbarInsertBlockMessages.recordVideoDescription),
87
- keywords: ['loom', 'record', 'video'],
88
- priority: 800,
89
- icon: function icon() {
90
- return /*#__PURE__*/React.createElement(LoomIcon, {
91
- appearance: "brand"
92
- });
93
- },
94
- action: function action(insert, editorState) {
95
- var _recordVideo;
96
- var tr = insert(undefined);
97
- var loomState = loomPluginKey.getState(editorState);
98
- if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) {
99
- var _recordVideoFailed;
100
- var errorMessage = loomState === null || loomState === void 0 ? void 0 : loomState.error;
101
- logException(new Error(errorMessage), {
102
- location: 'editor-plugin-loom/quick-insert-record-video'
103
- });
104
- return (_recordVideoFailed = recordVideoFailed({
105
- inputMethod: INPUT_METHOD.QUICK_INSERT,
106
- error: errorMessage,
107
- editorAnalyticsAPI: editorAnalyticsAPI
108
- })({
109
- tr: tr
110
- })) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false;
111
- }
112
- return (_recordVideo = recordVideo({
113
- inputMethod: INPUT_METHOD.QUICK_INSERT,
114
- editorAnalyticsAPI: editorAnalyticsAPI
115
- })({
116
- tr: tr
117
- })) !== null && _recordVideo !== void 0 ? _recordVideo : false;
118
- }
119
- }];
70
+ quickInsert: function quickInsert(intl) {
71
+ if (config.loomProvider) {
72
+ return getQuickInsertItem(editorAnalyticsAPI)(intl);
73
+ }
74
+ return [];
120
75
  }
121
76
  },
122
77
  // Enable inserting Loom recordings through main toolbar
@@ -1,13 +1,9 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
2
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
- import { logException } from '@atlaskit/editor-common/monitoring';
8
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
9
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
10
- import { disableLoom, enableLoom, insertVideo } from './commands';
6
+ import { setupLoom } from './commands';
11
7
  export var LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
12
8
  LoomPluginAction[LoomPluginAction["ENABLE"] = 0] = "ENABLE";
13
9
  LoomPluginAction[LoomPluginAction["DISABLE"] = 1] = "DISABLE";
@@ -17,10 +13,8 @@ export var LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
17
13
  }({});
18
14
  export var loomPluginKey = new PluginKey('loom');
19
15
  export var createPlugin = function createPlugin(_ref) {
20
- var _api$analytics;
21
16
  var config = _ref.config,
22
17
  api = _ref.api;
23
- var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
24
18
  return new SafePlugin({
25
19
  key: loomPluginKey,
26
20
  state: {
@@ -67,78 +61,8 @@ export var createPlugin = function createPlugin(_ref) {
67
61
  }
68
62
  },
69
63
  view: function view(editorView) {
70
- var setupLoom = /*#__PURE__*/function () {
71
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
72
- var _api$core3, _api$analytics3;
73
- var clientResult, _api$core, _api$analytics2, attachToButton, loomButton;
74
- return _regeneratorRuntime.wrap(function _callee$(_context) {
75
- while (1) switch (_context.prev = _context.next) {
76
- case 0:
77
- _context.next = 2;
78
- return config.loomProvider.getClient();
79
- case 2:
80
- clientResult = _context.sent;
81
- if (!(clientResult.status === 'error')) {
82
- _context.next = 8;
83
- break;
84
- }
85
- api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(disableLoom({
86
- error: clientResult.message
87
- }));
88
- logException(new Error(clientResult.message), {
89
- location: 'editor-plugin-loom/sdk-initialisation'
90
- });
91
- api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
92
- action: ACTION.ERRORED,
93
- actionSubject: ACTION_SUBJECT.LOOM,
94
- eventType: EVENT_TYPE.OPERATIONAL,
95
- attributes: {
96
- error: clientResult.message
97
- }
98
- });
99
- return _context.abrupt("return");
100
- case 8:
101
- attachToButton = clientResult.client.attachToButton; // Hidden element to work around the SDK API
102
- loomButton = document.createElement('button');
103
- attachToButton({
104
- button: loomButton,
105
- onInsert: function onInsert(video) {
106
- var _api$hyperlink, _api$core2;
107
- var state = editorView.state,
108
- dispatch = editorView.dispatch;
109
- var pos = editorView.state.selection.from;
110
- api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 || _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, pos,
111
- // from === to, don't replace text to avoid accidental content loss
112
- pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
113
- )(state, dispatch);
114
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(insertVideo({
115
- editorAnalyticsAPI: editorAnalyticsAPI,
116
- video: video
117
- }));
118
- }
119
- });
120
- api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(enableLoom({
121
- loomButton: loomButton
122
- }));
123
- // We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
124
- // filters out any transactions with steps (even analytics) when it's initialising
125
- api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
126
- action: ACTION.INITIALISED,
127
- actionSubject: ACTION_SUBJECT.LOOM,
128
- eventType: EVENT_TYPE.OPERATIONAL
129
- });
130
- case 13:
131
- case "end":
132
- return _context.stop();
133
- }
134
- }, _callee);
135
- }));
136
- return function setupLoom() {
137
- return _ref2.apply(this, arguments);
138
- };
139
- }();
140
- if (config) {
141
- setupLoom();
64
+ if (config.loomProvider) {
65
+ setupLoom(config.loomProvider, api, editorView);
142
66
  }
143
67
  return {};
144
68
  }
package/dist/esm/types.js CHANGED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,90 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["onClickBeforeInit", "isDisabled", "href"];
4
+ /**
5
+ * @jsxRuntime classic
6
+ * @jsx jsx
7
+ */
8
+ import React, { useCallback } from 'react';
9
+
10
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
+ import { jsx } from '@emotion/react';
12
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
13
+ import { executeRecordVideo } from '../commands';
14
+ import { loomPluginKey } from '../pm-plugin';
15
+ import ToolbarButtonComponent from './ToolbarButtonComponent';
16
+ var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(editorView, disabled, appearance, api) {
17
+ return /*#__PURE__*/React.forwardRef(function (props, ref) {
18
+ var _loomPluginKey$getSta;
19
+ var onClickBeforeInit = props.onClickBeforeInit,
20
+ _props$isDisabled = props.isDisabled,
21
+ isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
22
+ href = props.href,
23
+ restProps = _objectWithoutProperties(props, _excluded);
24
+ var isLoomEnabled = (_loomPluginKey$getSta = loomPluginKey.getState(editorView.state)) === null || _loomPluginKey$getSta === void 0 ? void 0 : _loomPluginKey$getSta.isEnabled;
25
+ var handleOnClick = useCallback(function (e) {
26
+ if (isLoomEnabled) {
27
+ executeRecordVideo(api);
28
+ } else {
29
+ onClickBeforeInit && onClickBeforeInit(e);
30
+ }
31
+ }, [isLoomEnabled, onClickBeforeInit]);
32
+ return jsx(ToolbarButtonComponent, _extends({
33
+ ref: ref,
34
+ hideTooltip: !!(restProps.onMouseEnter || restProps.onMouseLeave)
35
+ // Ignore href if Loom is enabled so that it doesn't interfere with recording
36
+ ,
37
+ href: isLoomEnabled ? undefined : href,
38
+ disabled: disabled || isDisabled,
39
+ api: api,
40
+ appearance: appearance,
41
+ onClick: function onClick(e) {
42
+ return handleOnClick(e);
43
+ }
44
+ }, restProps));
45
+ });
46
+ };
47
+ var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
48
+ var disabled = _ref.disabled,
49
+ api = _ref.api,
50
+ appearance = _ref.appearance;
51
+ var handleOnClick = useCallback(function () {
52
+ return executeRecordVideo(api);
53
+ }, [api]);
54
+ var _useSharedPluginState = useSharedPluginState(api, ['loom']),
55
+ loomState = _useSharedPluginState.loomState;
56
+ if (!loomState) {
57
+ return null;
58
+ }
59
+ return jsx(ToolbarButtonComponent
60
+ // Disable the icon while the SDK isn't initialised
61
+ , {
62
+ disabled: disabled || !(loomState !== null && loomState !== void 0 && loomState.isEnabled),
63
+ api: api,
64
+ appearance: appearance,
65
+ onClick: handleOnClick
66
+ });
67
+ };
68
+ export var loomPrimaryToolbarComponent = function loomPrimaryToolbarComponent(config, api) {
69
+ return function (_ref2) {
70
+ var disabled = _ref2.disabled,
71
+ appearance = _ref2.appearance,
72
+ editorView = _ref2.editorView;
73
+ if (config.shouldShowToolbarButton === false) {
74
+ return null;
75
+ }
76
+ if (config.renderButton) {
77
+ return config.renderButton(CustomisableLoomToolbarButton(editorView, disabled, appearance, api));
78
+ }
79
+ if (config.shouldShowToolbarButton) {
80
+ return jsx(LoomToolbarButtonWrapper
81
+ // Disable the icon while the SDK isn't initialised
82
+ , {
83
+ disabled: disabled,
84
+ api: api,
85
+ appearance: appearance
86
+ });
87
+ }
88
+ return null;
89
+ };
90
+ };
@@ -2,49 +2,67 @@
2
2
  * @jsxRuntime classic
3
3
  * @jsx jsx
4
4
  */
5
+ import React from 'react';
6
+
5
7
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
8
  import { jsx } from '@emotion/react';
7
9
  import { injectIntl } from 'react-intl-next';
8
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
10
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
11
  import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
11
12
  import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
12
13
  import { LoomIcon } from '@atlaskit/logo';
13
14
  import { fg } from '@atlaskit/platform-feature-flags';
14
- import { recordVideo } from '../commands';
15
15
  // This const is derived from the breakpoint where the toolbar hides its icons. It is used to hide the text in the AI button.
16
16
  // Derived from values from platform/packages/editor/editor-core/src/ui/Appearance/FullPage/MainToolbar.tsx
17
17
  var LOOM_BUTTON_WIDTH_BREAKPOINT = 1076;
18
- var LoomToolbarButton = function LoomToolbarButton(_ref) {
18
+ var LoomToolbarButtonInternal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
19
19
  var disabled = _ref.disabled,
20
20
  api = _ref.api,
21
21
  appearance = _ref.appearance,
22
- formatMessage = _ref.intl.formatMessage;
22
+ formatMessage = _ref.intl.formatMessage,
23
+ selected = _ref.selected,
24
+ onBlur = _ref.onBlur,
25
+ onFocus = _ref.onFocus,
26
+ onKeyDown = _ref.onKeyDown,
27
+ onMouseEnter = _ref.onMouseEnter,
28
+ onMouseLeave = _ref.onMouseLeave,
29
+ ariaControls = _ref['aria-controls'],
30
+ ariaExpanded = _ref['aria-expanded'],
31
+ ariaHasPopup = _ref['aria-haspopup'],
32
+ dataDsLevel = _ref['data-ds--level'],
33
+ onClick = _ref.onClick,
34
+ href = _ref.href,
35
+ target = _ref.target,
36
+ hideTooltip = _ref.hideTooltip;
23
37
  var _useSharedPluginState = useSharedPluginState(api, ['loom', 'width']),
24
- loomState = _useSharedPluginState.loomState,
25
38
  widthState = _useSharedPluginState.widthState;
26
- if (!loomState) {
27
- return null;
28
- }
29
39
  var label = formatMessage(appearance === 'comment' ? toolbarInsertBlockMessages.addLoomVideoComment : toolbarInsertBlockMessages.addLoomVideo);
30
40
  var shouldShowRecordText = fg('platform.editor.plugin.loom.responsive-menu_4at4a') && ((widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0) > LOOM_BUTTON_WIDTH_BREAKPOINT;
31
41
  return jsx(ToolbarButton, {
42
+ hideTooltip: hideTooltip,
43
+ ref: ref,
44
+ href: href,
32
45
  buttonId: TOOLBAR_BUTTON.RECORD_VIDEO,
33
- onClick: function onClick() {
34
- var _api$core, _api$analytics;
35
- return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(recordVideo({
36
- inputMethod: INPUT_METHOD.TOOLBAR,
37
- editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
38
- }));
39
- }
40
- // Disable the icon while the SDK isn't initialised
41
- ,
42
- disabled: disabled || !(loomState !== null && loomState !== void 0 && loomState.isEnabled),
46
+ disabled: disabled,
43
47
  title: label,
44
48
  iconBefore: jsx(LoomIcon, {
45
49
  label: label,
46
50
  size: "small"
47
- })
51
+ }),
52
+ selected: selected,
53
+ onBlur: onBlur,
54
+ onFocus: onFocus,
55
+ onKeyDown: onKeyDown,
56
+ onMouseEnter: onMouseEnter,
57
+ onMouseLeave: onMouseLeave,
58
+ "aria-controls": ariaControls,
59
+ "aria-expanded": ariaExpanded,
60
+ "aria-haspopup": ariaHasPopup,
61
+ "data-ds--level": dataDsLevel,
62
+ onClick: onClick,
63
+ target: target
48
64
  }, shouldShowRecordText && formatMessage(toolbarInsertBlockMessages.recordLoomShortTitle));
49
- };
50
- export default injectIntl(LoomToolbarButton);
65
+ });
66
+ export default injectIntl(LoomToolbarButtonInternal, {
67
+ forwardRef: true
68
+ });
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
+ import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
+ import { logException } from '@atlaskit/editor-common/monitoring';
5
+ import { LoomIcon } from '@atlaskit/logo';
6
+ import { recordVideo, recordVideoFailed } from '../commands';
7
+ import { loomPluginKey } from '../pm-plugin';
8
+ export var getQuickInsertItem = function getQuickInsertItem(editorAnalyticsAPI) {
9
+ return function (_ref) {
10
+ var formatMessage = _ref.formatMessage;
11
+ return [{
12
+ id: 'loom',
13
+ title: formatMessage(toolbarInsertBlockMessages.recordVideo),
14
+ description: formatMessage(toolbarInsertBlockMessages.recordVideoDescription),
15
+ keywords: ['loom', 'record', 'video'],
16
+ priority: 800,
17
+ icon: function icon() {
18
+ return /*#__PURE__*/React.createElement(LoomIcon, {
19
+ appearance: "brand"
20
+ });
21
+ },
22
+ action: function action(insert, editorState) {
23
+ var _recordVideo;
24
+ var tr = insert(undefined);
25
+ var loomState = loomPluginKey.getState(editorState);
26
+ if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) {
27
+ var _recordVideoFailed;
28
+ var errorMessage = loomState === null || loomState === void 0 ? void 0 : loomState.error;
29
+ logException(new Error(errorMessage), {
30
+ location: 'editor-plugin-loom/quick-insert-record-video'
31
+ });
32
+ return (_recordVideoFailed = recordVideoFailed({
33
+ inputMethod: INPUT_METHOD.QUICK_INSERT,
34
+ error: errorMessage,
35
+ editorAnalyticsAPI: editorAnalyticsAPI
36
+ })({
37
+ tr: tr
38
+ })) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false;
39
+ }
40
+ return (_recordVideo = recordVideo({
41
+ inputMethod: INPUT_METHOD.QUICK_INSERT,
42
+ editorAnalyticsAPI: editorAnalyticsAPI
43
+ })({
44
+ tr: tr
45
+ })) !== null && _recordVideo !== void 0 ? _recordVideo : false;
46
+ }
47
+ }];
48
+ };
49
+ };
@@ -4,7 +4,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { LoomPlugin } from './plugin';
7
- import type { PositionType, VideoMeta } from './types';
7
+ import type { LoomProviderOptions, PositionType, VideoMeta } from './types';
8
8
  export declare const enableLoom: ({ loomButton }: {
9
9
  loomButton: HTMLButtonElement;
10
10
  }) => EditorCommand;
@@ -25,3 +25,7 @@ export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
25
25
  video: VideoMeta;
26
26
  }) => EditorCommand;
27
27
  export declare const insertLoom: (editorView: EditorView | null, api: ExtractInjectionAPI<LoomPlugin> | undefined, video: VideoMeta, positionType: PositionType) => boolean;
28
+ export declare const executeRecordVideo: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => void;
29
+ export declare const setupLoom: (loomProvider: LoomProviderOptions, api: ExtractInjectionAPI<LoomPlugin> | undefined, editorView: EditorView | null, isAfterEditorLoaded?: boolean) => Promise<{
30
+ error?: string;
31
+ }>;
@@ -1,4 +1,4 @@
1
1
  export { loomPlugin } from './plugin';
2
2
  export type { LoomPlugin } from './plugin';
3
3
  export type { LoomPluginState } from './pm-plugin';
4
- export type { LoomPluginOptions, LoomProviderOptions, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, } from './types';
4
+ export type { LoomPluginOptions, LoomProviderOptions, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, ButtonComponentProps, ButtonComponent, RenderButton, } from './types';
@@ -1,19 +1,21 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
+ import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
7
8
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
8
9
  import type { LoomPluginState } from './pm-plugin';
9
- import type { LoomPluginOptions, PositionType, VideoMeta } from './types';
10
+ import type { LoomPluginOptions, LoomProviderOptions, PositionType, VideoMeta } from './types';
10
11
  export type LoomPlugin = NextEditorPlugin<'loom', {
11
12
  pluginConfiguration: LoomPluginOptions;
12
13
  dependencies: [
13
14
  OptionalPlugin<AnalyticsPlugin>,
14
15
  WidthPlugin,
15
16
  HyperlinkPlugin,
16
- OptionalPlugin<PrimaryToolbarPlugin>
17
+ OptionalPlugin<PrimaryToolbarPlugin>,
18
+ OptionalPlugin<QuickInsertPlugin>
17
19
  ];
18
20
  sharedState: LoomPluginState | undefined;
19
21
  actions: {
@@ -29,6 +31,15 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
29
31
  * @returns {boolean} If the loom was successfully inserted
30
32
  */
31
33
  insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
34
+ /**
35
+ * Given loom provider, initialise loom SDK
36
+ * @returns error message if initialisation failed
37
+ */
38
+ initLoom: ({ loomProvider, }: {
39
+ loomProvider: LoomProviderOptions;
40
+ }) => Promise<{
41
+ error?: string;
42
+ }>;
32
43
  };
33
44
  }>;
34
45
  export declare const loomPlugin: LoomPlugin;
@@ -1,3 +1,5 @@
1
+ import type React from 'react';
2
+ import { type ButtonProps as AKButtonProps } from '@atlaskit/button';
1
3
  export type VideoMeta = {
2
4
  sharedUrl: string;
3
5
  title: string;
@@ -23,8 +25,37 @@ export type GetClient = Promise<GetClientResult>;
23
25
  export type LoomProviderOptions = {
24
26
  getClient: () => GetClient;
25
27
  };
26
- export type LoomPluginOptions = {
28
+ export interface ButtonComponentProps extends Pick<AKButtonProps, 'selected' | 'isDisabled' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onMouseEnter' | 'onMouseLeave' | 'aria-controls' | 'aria-expanded' | 'aria-haspopup' | 'href' | 'target'> {
29
+ 'data-ds--level'?: string;
30
+ /**
31
+ * on click handler that will only be called before the Loom SDK is initialised.
32
+ * Once the SDK is initialised, onClick will be handled by editor to start recording.
33
+ */
34
+ onClickBeforeInit?: (event: React.MouseEvent<HTMLElement>) => void;
35
+ }
36
+ export type ButtonComponent = React.ForwardRefExoticComponent<ButtonComponentProps & React.RefAttributes<HTMLElement>>;
37
+ export type RenderButton = (ButtonComponent: ButtonComponent) => JSX.Element | null;
38
+ type LoomPluginOptionsWithProvider = {
27
39
  loomProvider: LoomProviderOptions;
40
+ /**
41
+ * Customize the button component, e.g. adding pulse, a11y.
42
+ * @note When this is provided, `shouldShowToolbarButton` can be skipped and the button will still show. \
43
+ * If `shouldShowToolbarButton` is false, the button will not show regardless of this prop.
44
+ * @param ButtonComponent Loom toolbar button component (mainly UI)
45
+ */
46
+ renderButton?: RenderButton;
28
47
  shouldShowToolbarButton?: boolean;
29
48
  };
49
+ type LoomPluginOptionsWithoutProvider = {
50
+ loomProvider?: LoomProviderOptions;
51
+ /**
52
+ * Customize the button component, e.g. adding pulse, a11y.
53
+ * @note When this is provided, `shouldShowToolbarButton` can be skipped and the button will still show. \
54
+ * If `shouldShowToolbarButton` is false, the button will not show regardless of this prop.
55
+ * @param ButtonComponent Loom toolbar button component (mainly UI)
56
+ */
57
+ renderButton: RenderButton;
58
+ shouldShowToolbarButton?: boolean;
59
+ };
60
+ export type LoomPluginOptions = LoomPluginOptionsWithProvider | LoomPluginOptionsWithoutProvider;
30
61
  export {};
@@ -0,0 +1,4 @@
1
+ import type { ExtractInjectionAPI, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { LoomPlugin } from '../plugin';
3
+ import { type LoomPluginOptions } from '../types';
4
+ export declare const loomPrimaryToolbarComponent: (config: LoomPluginOptions, api: ExtractInjectionAPI<LoomPlugin> | undefined) => ToolbarUIComponentFactory;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import React from 'react';
6
+ import type { WrappedComponentProps } from 'react-intl-next';
7
+ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
+ import type { LoomPlugin } from '../plugin';
9
+ import { type ButtonComponentProps } from '../types';
10
+ interface Props extends Omit<ButtonComponentProps, 'onClickBeforeInit'> {
11
+ disabled: boolean;
12
+ appearance: EditorAppearance;
13
+ api: ExtractInjectionAPI<LoomPlugin> | undefined;
14
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
15
+ hideTooltip?: boolean;
16
+ }
17
+ declare const _default: React.ForwardRefExoticComponent<Pick<import("react-intl-next").WithIntlProps<React.PropsWithChildren<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>>, "children" | "key" | keyof Props | "forwardedRef"> & React.RefAttributes<any>> & {
18
+ WrappedComponent: React.ComponentType<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>;
19
+ };
20
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { type EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { QuickInsertHandlerFn } from '@atlaskit/editor-common/types';
3
+ export declare const getQuickInsertItem: (editorAnalyticsAPI?: EditorAnalyticsAPI) => QuickInsertHandlerFn;
@@ -4,7 +4,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
4
  import type { EditorCommand, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { LoomPlugin } from './plugin';
7
- import type { PositionType, VideoMeta } from './types';
7
+ import type { LoomProviderOptions, PositionType, VideoMeta } from './types';
8
8
  export declare const enableLoom: ({ loomButton }: {
9
9
  loomButton: HTMLButtonElement;
10
10
  }) => EditorCommand;
@@ -25,3 +25,7 @@ export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
25
25
  video: VideoMeta;
26
26
  }) => EditorCommand;
27
27
  export declare const insertLoom: (editorView: EditorView | null, api: ExtractInjectionAPI<LoomPlugin> | undefined, video: VideoMeta, positionType: PositionType) => boolean;
28
+ export declare const executeRecordVideo: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => void;
29
+ export declare const setupLoom: (loomProvider: LoomProviderOptions, api: ExtractInjectionAPI<LoomPlugin> | undefined, editorView: EditorView | null, isAfterEditorLoaded?: boolean) => Promise<{
30
+ error?: string;
31
+ }>;
@@ -1,4 +1,4 @@
1
1
  export { loomPlugin } from './plugin';
2
2
  export type { LoomPlugin } from './plugin';
3
3
  export type { LoomPluginState } from './pm-plugin';
4
- export type { LoomPluginOptions, LoomProviderOptions, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, } from './types';
4
+ export type { LoomPluginOptions, LoomProviderOptions, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, ButtonComponentProps, ButtonComponent, RenderButton, } from './types';
@@ -1,19 +1,21 @@
1
1
  import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
7
+ import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
7
8
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
8
9
  import type { LoomPluginState } from './pm-plugin';
9
- import type { LoomPluginOptions, PositionType, VideoMeta } from './types';
10
+ import type { LoomPluginOptions, LoomProviderOptions, PositionType, VideoMeta } from './types';
10
11
  export type LoomPlugin = NextEditorPlugin<'loom', {
11
12
  pluginConfiguration: LoomPluginOptions;
12
13
  dependencies: [
13
14
  OptionalPlugin<AnalyticsPlugin>,
14
15
  WidthPlugin,
15
16
  HyperlinkPlugin,
16
- OptionalPlugin<PrimaryToolbarPlugin>
17
+ OptionalPlugin<PrimaryToolbarPlugin>,
18
+ OptionalPlugin<QuickInsertPlugin>
17
19
  ];
18
20
  sharedState: LoomPluginState | undefined;
19
21
  actions: {
@@ -29,6 +31,15 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
29
31
  * @returns {boolean} If the loom was successfully inserted
30
32
  */
31
33
  insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
34
+ /**
35
+ * Given loom provider, initialise loom SDK
36
+ * @returns error message if initialisation failed
37
+ */
38
+ initLoom: ({ loomProvider, }: {
39
+ loomProvider: LoomProviderOptions;
40
+ }) => Promise<{
41
+ error?: string;
42
+ }>;
32
43
  };
33
44
  }>;
34
45
  export declare const loomPlugin: LoomPlugin;