@atlaskit/editor-plugin-loom 1.0.2 → 2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-plugin-loom
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#85470](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/85470) [`32cb4d4ca34f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32cb4d4ca34f) - Update loom plugin to take in interface and remove SDK references
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 1.0.2
4
14
 
5
15
  ### Patch Changes
@@ -15,7 +15,8 @@ var _pmPlugin = require("./pm-plugin");
15
15
  var _ToolbarButton = _interopRequireDefault(require("./ui/ToolbarButton"));
16
16
  var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
17
17
  var _api$analytics;
18
- var api = _ref.api;
18
+ var config = _ref.config,
19
+ api = _ref.api;
19
20
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
20
21
  return {
21
22
  name: 'loom',
@@ -23,7 +24,10 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
23
24
  return [{
24
25
  name: 'loom',
25
26
  plugin: function plugin() {
26
- return (0, _pmPlugin.createPlugin)(api);
27
+ return (0, _pmPlugin.createPlugin)({
28
+ config: config,
29
+ api: api
30
+ });
27
31
  }
28
32
  }];
29
33
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -14,8 +13,6 @@ var _monitoring = require("@atlaskit/editor-common/monitoring");
14
13
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
15
14
  var _state = require("@atlaskit/editor-prosemirror/state");
16
15
  var _commands = require("./commands");
17
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
16
  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; }
20
17
  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) { (0, _defineProperty2.default)(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; }
21
18
  var LoomPluginAction = exports.LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
@@ -26,9 +23,10 @@ var LoomPluginAction = exports.LoomPluginAction = /*#__PURE__*/function (LoomPlu
26
23
  return LoomPluginAction;
27
24
  }({});
28
25
  var loomPluginKey = exports.loomPluginKey = new _state.PluginKey('loom');
29
- var LOOM_SDK_PUBLIC_APP_ID = 'e1cff63a-8ca2-4c2c-ad41-d61c54beb16a';
30
- var createPlugin = exports.createPlugin = function createPlugin(api) {
26
+ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
31
27
  var _api$analytics;
28
+ var config = _ref.config,
29
+ api = _ref.api;
32
30
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
33
31
  return new _safePlugin.SafePlugin({
34
32
  key: loomPluginKey,
@@ -77,89 +75,55 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
77
75
  },
78
76
  view: function view(editorView) {
79
77
  var setupLoom = /*#__PURE__*/function () {
80
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
78
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
81
79
  var _api$core3, _api$analytics3;
82
- var _yield$import, isSupported, setup, _yield$isSupported, supported, error, _api$core, _api$analytics2, _yield$setup, configureButton, loomButton, sdkButton;
83
- return _regenerator.default.wrap(function _callee2$(_context2) {
84
- while (1) switch (_context2.prev = _context2.next) {
80
+ var clientResult, _api$core, _api$analytics2, attachToButton, loomButton;
81
+ return _regenerator.default.wrap(function _callee$(_context) {
82
+ while (1) switch (_context.prev = _context.next) {
85
83
  case 0:
86
- _context2.next = 2;
87
- return Promise.resolve().then(function () {
88
- return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-loom-sdk" */'@loomhq/record-sdk'));
89
- });
84
+ _context.next = 2;
85
+ return config.loomProvider.getClient();
90
86
  case 2:
91
- _yield$import = _context2.sent;
92
- isSupported = _yield$import.isSupported;
93
- setup = _yield$import.setup;
94
- _context2.next = 7;
95
- return isSupported();
96
- case 7:
97
- _yield$isSupported = _context2.sent;
98
- supported = _yield$isSupported.supported;
99
- error = _yield$isSupported.error;
100
- if (supported) {
101
- _context2.next = 15;
87
+ clientResult = _context.sent;
88
+ if (!(clientResult.status === 'error')) {
89
+ _context.next = 8;
102
90
  break;
103
91
  }
104
- // Keep plugin state update and analytics separate to avoid accidentally not updating
105
- // plugin state due to collab-edit filtering out transactions with steps
106
92
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute((0, _commands.disableLoom)({
107
- error: error
93
+ error: clientResult.message
108
94
  }));
109
- (0, _monitoring.logException)(new Error(error), {
95
+ (0, _monitoring.logException)(new Error(clientResult.message), {
110
96
  location: 'editor-plugin-loom/sdk-initialisation'
111
97
  });
112
- // We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
113
- // filters out any transactions with steps (even analytics) when it's initialising
114
98
  api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
115
99
  action: _analytics.ACTION.ERRORED,
116
100
  actionSubject: _analytics.ACTION_SUBJECT.LOOM,
117
101
  eventType: _analytics.EVENT_TYPE.OPERATIONAL,
118
102
  attributes: {
119
- error: error
103
+ error: clientResult.message
120
104
  }
121
105
  });
122
- return _context2.abrupt("return");
123
- case 15:
124
- _context2.next = 17;
125
- return setup({
126
- publicAppId: LOOM_SDK_PUBLIC_APP_ID
127
- });
128
- case 17:
129
- _yield$setup = _context2.sent;
130
- configureButton = _yield$setup.configureButton;
131
- // Hidden element to work around the SDK API
106
+ return _context.abrupt("return");
107
+ case 8:
108
+ attachToButton = clientResult.client.attachToButton; // Hidden element to work around the SDK API
132
109
  loomButton = document.createElement('button');
133
- sdkButton = configureButton({
134
- element: loomButton
135
- }); // Attach insertion logic to the event handlers on the SDK
136
- sdkButton.on('insert-click', /*#__PURE__*/function () {
137
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(video) {
110
+ attachToButton({
111
+ button: loomButton,
112
+ onInsert: function onInsert(video) {
138
113
  var _api$hyperlink, _api$core2;
139
- var state, dispatch, pos;
140
- return _regenerator.default.wrap(function _callee$(_context) {
141
- while (1) switch (_context.prev = _context.next) {
142
- case 0:
143
- state = editorView.state, dispatch = editorView.dispatch;
144
- pos = editorView.state.selection.from;
145
- api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 || _api$hyperlink.actions.insertLink(_analytics.INPUT_METHOD.TYPEAHEAD, pos,
146
- // from === to, don't replace text to avoid accidental content loss
147
- pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
148
- )(state, dispatch);
149
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute((0, _commands.insertVideo)({
150
- editorAnalyticsAPI: editorAnalyticsAPI,
151
- video: video
152
- }));
153
- case 4:
154
- case "end":
155
- return _context.stop();
156
- }
157
- }, _callee);
158
- }));
159
- return function (_x) {
160
- return _ref2.apply(this, arguments);
161
- };
162
- }());
114
+ var state = editorView.state,
115
+ dispatch = editorView.dispatch;
116
+ var pos = editorView.state.selection.from;
117
+ api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 || _api$hyperlink.actions.insertLink(_analytics.INPUT_METHOD.TYPEAHEAD, pos,
118
+ // from === to, don't replace text to avoid accidental content loss
119
+ pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
120
+ )(state, dispatch);
121
+ api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute((0, _commands.insertVideo)({
122
+ editorAnalyticsAPI: editorAnalyticsAPI,
123
+ video: video
124
+ }));
125
+ }
126
+ });
163
127
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute((0, _commands.enableLoom)({
164
128
  loomButton: loomButton
165
129
  }));
@@ -170,17 +134,19 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
170
134
  actionSubject: _analytics.ACTION_SUBJECT.LOOM,
171
135
  eventType: _analytics.EVENT_TYPE.OPERATIONAL
172
136
  });
173
- case 24:
137
+ case 13:
174
138
  case "end":
175
- return _context2.stop();
139
+ return _context.stop();
176
140
  }
177
- }, _callee2);
141
+ }, _callee);
178
142
  }));
179
143
  return function setupLoom() {
180
- return _ref.apply(this, arguments);
144
+ return _ref2.apply(this, arguments);
181
145
  };
182
146
  }();
183
- setupLoom();
147
+ if (config) {
148
+ setupLoom();
149
+ }
184
150
  return {};
185
151
  }
186
152
  });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -7,6 +7,7 @@ import { recordVideo, recordVideoFailed } from './commands';
7
7
  import { createPlugin, loomPluginKey } from './pm-plugin';
8
8
  import LoomToolbarButton from './ui/ToolbarButton';
9
9
  export const loomPlugin = ({
10
+ config,
10
11
  api
11
12
  }) => {
12
13
  var _api$analytics;
@@ -15,7 +16,10 @@ export const loomPlugin = ({
15
16
  name: 'loom',
16
17
  pmPlugins: () => [{
17
18
  name: 'loom',
18
- plugin: () => createPlugin(api)
19
+ plugin: () => createPlugin({
20
+ config,
21
+ api
22
+ })
19
23
  }],
20
24
  getSharedState(editorState) {
21
25
  if (!editorState) {
@@ -11,8 +11,10 @@ export let LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
11
11
  return LoomPluginAction;
12
12
  }({});
13
13
  export const loomPluginKey = new PluginKey('loom');
14
- const LOOM_SDK_PUBLIC_APP_ID = 'e1cff63a-8ca2-4c2c-ad41-d61c54beb16a';
15
- export const createPlugin = api => {
14
+ export const createPlugin = ({
15
+ config,
16
+ api
17
+ }) => {
16
18
  var _api$analytics;
17
19
  const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
18
20
  return new SafePlugin({
@@ -67,66 +69,49 @@ export const createPlugin = api => {
67
69
  view(editorView) {
68
70
  const setupLoom = async () => {
69
71
  var _api$core3, _api$analytics3;
70
- // Asynchronously check if the Loom SDK is supported
71
- // it hits a Loom API so could take a while
72
- const {
73
- isSupported,
74
- setup
75
- } = await import( /* webpackChunkName: "@atlaskit-internal_editor-loom-sdk" */'@loomhq/record-sdk');
76
- const {
77
- supported,
78
- error
79
- } = await isSupported();
80
- if (!supported) {
72
+ const clientResult = await config.loomProvider.getClient();
73
+ if (clientResult.status === 'error') {
81
74
  var _api$core, _api$analytics2;
82
- // Keep plugin state update and analytics separate to avoid accidentally not updating
83
- // plugin state due to collab-edit filtering out transactions with steps
84
75
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(disableLoom({
85
- error
76
+ error: clientResult.message
86
77
  }));
87
- logException(new Error(error), {
78
+ logException(new Error(clientResult.message), {
88
79
  location: 'editor-plugin-loom/sdk-initialisation'
89
80
  });
90
- // We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
91
- // filters out any transactions with steps (even analytics) when it's initialising
92
81
  api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent({
93
82
  action: ACTION.ERRORED,
94
83
  actionSubject: ACTION_SUBJECT.LOOM,
95
84
  eventType: EVENT_TYPE.OPERATIONAL,
96
85
  attributes: {
97
- error
86
+ error: clientResult.message
98
87
  }
99
88
  });
100
89
  return;
101
90
  }
102
91
  const {
103
- configureButton
104
- } = await setup({
105
- publicAppId: LOOM_SDK_PUBLIC_APP_ID
106
- });
92
+ attachToButton
93
+ } = clientResult.client;
107
94
 
108
95
  // Hidden element to work around the SDK API
109
96
  const loomButton = document.createElement('button');
110
- const sdkButton = configureButton({
111
- element: loomButton
112
- });
113
-
114
- // Attach insertion logic to the event handlers on the SDK
115
- sdkButton.on('insert-click', async video => {
116
- var _api$hyperlink, _api$core2;
117
- const {
118
- state,
119
- dispatch
120
- } = editorView;
121
- const pos = editorView.state.selection.from;
122
- api === null || api === void 0 ? void 0 : (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, pos,
123
- // from === to, don't replace text to avoid accidental content loss
124
- pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
125
- )(state, dispatch);
126
- api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(insertVideo({
127
- editorAnalyticsAPI,
128
- video
129
- }));
97
+ attachToButton({
98
+ button: loomButton,
99
+ onInsert: video => {
100
+ var _api$hyperlink, _api$core2;
101
+ const {
102
+ state,
103
+ dispatch
104
+ } = editorView;
105
+ const pos = editorView.state.selection.from;
106
+ api === null || api === void 0 ? void 0 : (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, pos,
107
+ // from === to, don't replace text to avoid accidental content loss
108
+ pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
109
+ )(state, dispatch);
110
+ api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(insertVideo({
111
+ editorAnalyticsAPI,
112
+ video
113
+ }));
114
+ }
130
115
  });
131
116
  api === null || api === void 0 ? void 0 : (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute(enableLoom({
132
117
  loomButton
@@ -139,7 +124,9 @@ export const createPlugin = api => {
139
124
  eventType: EVENT_TYPE.OPERATIONAL
140
125
  });
141
126
  };
142
- setupLoom();
127
+ if (config) {
128
+ setupLoom();
129
+ }
143
130
  return {};
144
131
  }
145
132
  });
File without changes
@@ -8,7 +8,8 @@ import { createPlugin, loomPluginKey } from './pm-plugin';
8
8
  import LoomToolbarButton from './ui/ToolbarButton';
9
9
  export var loomPlugin = function loomPlugin(_ref) {
10
10
  var _api$analytics;
11
- var api = _ref.api;
11
+ var config = _ref.config,
12
+ api = _ref.api;
12
13
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
13
14
  return {
14
15
  name: 'loom',
@@ -16,7 +17,10 @@ export var loomPlugin = function loomPlugin(_ref) {
16
17
  return [{
17
18
  name: 'loom',
18
19
  plugin: function plugin() {
19
- return createPlugin(api);
20
+ return createPlugin({
21
+ config: config,
22
+ api: api
23
+ });
20
24
  }
21
25
  }];
22
26
  },
@@ -16,9 +16,10 @@ export var LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
16
16
  return LoomPluginAction;
17
17
  }({});
18
18
  export var loomPluginKey = new PluginKey('loom');
19
- var LOOM_SDK_PUBLIC_APP_ID = 'e1cff63a-8ca2-4c2c-ad41-d61c54beb16a';
20
- export var createPlugin = function createPlugin(api) {
19
+ export var createPlugin = function createPlugin(_ref) {
21
20
  var _api$analytics;
21
+ var config = _ref.config,
22
+ api = _ref.api;
22
23
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
23
24
  return new SafePlugin({
24
25
  key: loomPluginKey,
@@ -67,87 +68,55 @@ export var createPlugin = function createPlugin(api) {
67
68
  },
68
69
  view: function view(editorView) {
69
70
  var setupLoom = /*#__PURE__*/function () {
70
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
71
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
71
72
  var _api$core3, _api$analytics3;
72
- var _yield$import, isSupported, setup, _yield$isSupported, supported, error, _api$core, _api$analytics2, _yield$setup, configureButton, loomButton, sdkButton;
73
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
74
- while (1) switch (_context2.prev = _context2.next) {
73
+ var clientResult, _api$core, _api$analytics2, attachToButton, loomButton;
74
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
75
+ while (1) switch (_context.prev = _context.next) {
75
76
  case 0:
76
- _context2.next = 2;
77
- return import( /* webpackChunkName: "@atlaskit-internal_editor-loom-sdk" */'@loomhq/record-sdk');
77
+ _context.next = 2;
78
+ return config.loomProvider.getClient();
78
79
  case 2:
79
- _yield$import = _context2.sent;
80
- isSupported = _yield$import.isSupported;
81
- setup = _yield$import.setup;
82
- _context2.next = 7;
83
- return isSupported();
84
- case 7:
85
- _yield$isSupported = _context2.sent;
86
- supported = _yield$isSupported.supported;
87
- error = _yield$isSupported.error;
88
- if (supported) {
89
- _context2.next = 15;
80
+ clientResult = _context.sent;
81
+ if (!(clientResult.status === 'error')) {
82
+ _context.next = 8;
90
83
  break;
91
84
  }
92
- // Keep plugin state update and analytics separate to avoid accidentally not updating
93
- // plugin state due to collab-edit filtering out transactions with steps
94
85
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(disableLoom({
95
- error: error
86
+ error: clientResult.message
96
87
  }));
97
- logException(new Error(error), {
88
+ logException(new Error(clientResult.message), {
98
89
  location: 'editor-plugin-loom/sdk-initialisation'
99
90
  });
100
- // We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
101
- // filters out any transactions with steps (even analytics) when it's initialising
102
91
  api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
103
92
  action: ACTION.ERRORED,
104
93
  actionSubject: ACTION_SUBJECT.LOOM,
105
94
  eventType: EVENT_TYPE.OPERATIONAL,
106
95
  attributes: {
107
- error: error
96
+ error: clientResult.message
108
97
  }
109
98
  });
110
- return _context2.abrupt("return");
111
- case 15:
112
- _context2.next = 17;
113
- return setup({
114
- publicAppId: LOOM_SDK_PUBLIC_APP_ID
115
- });
116
- case 17:
117
- _yield$setup = _context2.sent;
118
- configureButton = _yield$setup.configureButton;
119
- // Hidden element to work around the SDK API
99
+ return _context.abrupt("return");
100
+ case 8:
101
+ attachToButton = clientResult.client.attachToButton; // Hidden element to work around the SDK API
120
102
  loomButton = document.createElement('button');
121
- sdkButton = configureButton({
122
- element: loomButton
123
- }); // Attach insertion logic to the event handlers on the SDK
124
- sdkButton.on('insert-click', /*#__PURE__*/function () {
125
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(video) {
103
+ attachToButton({
104
+ button: loomButton,
105
+ onInsert: function onInsert(video) {
126
106
  var _api$hyperlink, _api$core2;
127
- var state, dispatch, pos;
128
- return _regeneratorRuntime.wrap(function _callee$(_context) {
129
- while (1) switch (_context.prev = _context.next) {
130
- case 0:
131
- state = editorView.state, dispatch = editorView.dispatch;
132
- pos = editorView.state.selection.from;
133
- api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 || _api$hyperlink.actions.insertLink(INPUT_METHOD.TYPEAHEAD, pos,
134
- // from === to, don't replace text to avoid accidental content loss
135
- pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
136
- )(state, dispatch);
137
- api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(insertVideo({
138
- editorAnalyticsAPI: editorAnalyticsAPI,
139
- video: video
140
- }));
141
- case 4:
142
- case "end":
143
- return _context.stop();
144
- }
145
- }, _callee);
146
- }));
147
- return function (_x) {
148
- return _ref2.apply(this, arguments);
149
- };
150
- }());
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
+ });
151
120
  api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(enableLoom({
152
121
  loomButton: loomButton
153
122
  }));
@@ -158,17 +127,19 @@ export var createPlugin = function createPlugin(api) {
158
127
  actionSubject: ACTION_SUBJECT.LOOM,
159
128
  eventType: EVENT_TYPE.OPERATIONAL
160
129
  });
161
- case 24:
130
+ case 13:
162
131
  case "end":
163
- return _context2.stop();
132
+ return _context.stop();
164
133
  }
165
- }, _callee2);
134
+ }, _callee);
166
135
  }));
167
136
  return function setupLoom() {
168
- return _ref.apply(this, arguments);
137
+ return _ref2.apply(this, arguments);
169
138
  };
170
139
  }();
171
- setupLoom();
140
+ if (config) {
141
+ setupLoom();
142
+ }
172
143
  return {};
173
144
  }
174
145
  });
File without changes
@@ -1,11 +1,12 @@
1
- import type { LoomVideo, SDKUnsupportedReasons } from '@loomhq/record-sdk';
1
+ import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
2
2
  import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand } from '@atlaskit/editor-common/types';
4
+ import type { VideoMeta } from './types';
4
5
  export declare const enableLoom: ({ loomButton }: {
5
6
  loomButton: HTMLButtonElement;
6
7
  }) => EditorCommand;
7
8
  export declare const disableLoom: ({ error }: {
8
- error: SDKUnsupportedReasons | undefined;
9
+ error: string;
9
10
  }) => EditorCommand;
10
11
  export declare const recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
11
12
  inputMethod: INPUT_METHOD;
@@ -18,5 +19,5 @@ export declare const recordVideoFailed: ({ inputMethod, error, editorAnalyticsAP
18
19
  }) => EditorCommand;
19
20
  export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
20
21
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
21
- video: LoomVideo;
22
+ video: VideoMeta;
22
23
  }) => EditorCommand;
@@ -1,3 +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, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, } from './types';
@@ -2,7 +2,9 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
4
4
  import type { LoomPluginState } from './pm-plugin';
5
+ import type { LoomPluginOptions } from './types';
5
6
  export type LoomPlugin = NextEditorPlugin<'loom', {
7
+ pluginConfiguration: LoomPluginOptions;
6
8
  dependencies: [
7
9
  OptionalPlugin<AnalyticsPlugin>,
8
10
  HyperlinkPlugin
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { LoomPlugin } from './plugin';
6
+ import type { LoomPluginOptions } from './types';
6
7
  export interface LoomPluginState {
7
8
  isEnabled: boolean;
8
9
  loomButton: HTMLButtonElement | null;
@@ -16,4 +17,7 @@ export declare enum LoomPluginAction {
16
17
  INSERT_VIDEO = 3
17
18
  }
18
19
  export declare const loomPluginKey: PluginKey<LoomPluginState>;
19
- export declare const createPlugin: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => SafePlugin<LoomPluginState>;
20
+ export declare const createPlugin: ({ config, api, }: {
21
+ config: LoomPluginOptions;
22
+ api: ExtractInjectionAPI<LoomPlugin> | undefined;
23
+ }) => SafePlugin<LoomPluginState>;
@@ -0,0 +1,27 @@
1
+ export type VideoMeta = {
2
+ sharedUrl: string;
3
+ title: string;
4
+ duration?: number;
5
+ };
6
+ type LoomClient = {
7
+ attachToButton: (options: {
8
+ button: HTMLElement;
9
+ onInsert: (videoMeta: VideoMeta) => void;
10
+ }) => void;
11
+ };
12
+ export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
13
+ export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
14
+ export type GetClientResult = {
15
+ status: 'loaded';
16
+ client: LoomClient;
17
+ } | {
18
+ status: 'error';
19
+ message: LoomPluginErrorMessages | LoomSDKErrorMessages;
20
+ };
21
+ export type GetClient = Promise<GetClientResult>;
22
+ export type LoomPluginOptions = {
23
+ loomProvider: {
24
+ getClient: () => GetClient;
25
+ };
26
+ };
27
+ export {};
@@ -3,6 +3,7 @@ import type { WrappedComponentProps } from 'react-intl-next';
3
3
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
4
4
  disabled: boolean;
5
5
  api: import("@atlaskit/editor-common/types").PublicPluginAPI<[import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"loom", {
6
+ pluginConfiguration: import("..").LoomPluginOptions;
6
7
  dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
7
8
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
8
9
  sharedState: {
@@ -42,7 +43,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
42
43
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
43
44
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>];
44
45
  sharedState: import("..").LoomPluginState | undefined;
45
- }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
46
+ }, import("..").LoomPluginOptions>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
46
47
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
47
48
  sharedState: {
48
49
  createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
@@ -84,6 +85,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
84
85
  WrappedComponent: React.ComponentType<{
85
86
  disabled: boolean;
86
87
  api: import("@atlaskit/editor-common/types").PublicPluginAPI<[import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"loom", {
88
+ pluginConfiguration: import("..").LoomPluginOptions;
87
89
  dependencies: [import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
88
90
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
89
91
  sharedState: {
@@ -123,7 +125,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
123
125
  sharedState: import("@atlaskit/editor-common/link").HyperlinkState | undefined;
124
126
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>];
125
127
  sharedState: import("..").LoomPluginState | undefined;
126
- }, undefined>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
128
+ }, import("..").LoomPluginOptions>, import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
127
129
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
128
130
  sharedState: {
129
131
  createAnalyticsEvent: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | null;
@@ -1,11 +1,12 @@
1
- import type { LoomVideo, SDKUnsupportedReasons } from '@loomhq/record-sdk';
1
+ import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
2
2
  import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import type { EditorCommand } from '@atlaskit/editor-common/types';
4
+ import type { VideoMeta } from './types';
4
5
  export declare const enableLoom: ({ loomButton }: {
5
6
  loomButton: HTMLButtonElement;
6
7
  }) => EditorCommand;
7
8
  export declare const disableLoom: ({ error }: {
8
- error: SDKUnsupportedReasons | undefined;
9
+ error: string;
9
10
  }) => EditorCommand;
10
11
  export declare const recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
11
12
  inputMethod: INPUT_METHOD;
@@ -18,5 +19,5 @@ export declare const recordVideoFailed: ({ inputMethod, error, editorAnalyticsAP
18
19
  }) => EditorCommand;
19
20
  export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
20
21
  editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
21
- video: LoomVideo;
22
+ video: VideoMeta;
22
23
  }) => EditorCommand;
@@ -1,3 +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, VideoMeta, GetClient, GetClientResult, LoomPluginErrorMessages, LoomSDKErrorMessages, } from './types';
@@ -2,7 +2,9 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
4
4
  import type { LoomPluginState } from './pm-plugin';
5
+ import type { LoomPluginOptions } from './types';
5
6
  export type LoomPlugin = NextEditorPlugin<'loom', {
7
+ pluginConfiguration: LoomPluginOptions;
6
8
  dependencies: [
7
9
  OptionalPlugin<AnalyticsPlugin>,
8
10
  HyperlinkPlugin
@@ -3,6 +3,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
5
5
  import type { LoomPlugin } from './plugin';
6
+ import type { LoomPluginOptions } from './types';
6
7
  export interface LoomPluginState {
7
8
  isEnabled: boolean;
8
9
  loomButton: HTMLButtonElement | null;
@@ -16,4 +17,7 @@ export declare enum LoomPluginAction {
16
17
  INSERT_VIDEO = 3
17
18
  }
18
19
  export declare const loomPluginKey: PluginKey<LoomPluginState>;
19
- export declare const createPlugin: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => SafePlugin<LoomPluginState>;
20
+ export declare const createPlugin: ({ config, api, }: {
21
+ config: LoomPluginOptions;
22
+ api: ExtractInjectionAPI<LoomPlugin> | undefined;
23
+ }) => SafePlugin<LoomPluginState>;
@@ -0,0 +1,27 @@
1
+ export type VideoMeta = {
2
+ sharedUrl: string;
3
+ title: string;
4
+ duration?: number;
5
+ };
6
+ type LoomClient = {
7
+ attachToButton: (options: {
8
+ button: HTMLElement;
9
+ onInsert: (videoMeta: VideoMeta) => void;
10
+ }) => void;
11
+ };
12
+ export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
13
+ export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
14
+ export type GetClientResult = {
15
+ status: 'loaded';
16
+ client: LoomClient;
17
+ } | {
18
+ status: 'error';
19
+ message: LoomPluginErrorMessages | LoomSDKErrorMessages;
20
+ };
21
+ export type GetClient = Promise<GetClientResult>;
22
+ export type LoomPluginOptions = {
23
+ loomProvider: {
24
+ getClient: () => GetClient;
25
+ };
26
+ };
27
+ export {};
@@ -4,6 +4,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
4
4
  disabled: boolean;
5
5
  api: import("@atlaskit/editor-common/types").PublicPluginAPI<[
6
6
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"loom", {
7
+ pluginConfiguration: import("..").LoomPluginOptions;
7
8
  dependencies: [
8
9
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
9
10
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
@@ -52,7 +53,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
52
53
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>
53
54
  ];
54
55
  sharedState: import("..").LoomPluginState | undefined;
55
- }, undefined>,
56
+ }, import("..").LoomPluginOptions>,
56
57
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
57
58
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
58
59
  sharedState: {
@@ -104,6 +105,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
104
105
  disabled: boolean;
105
106
  api: import("@atlaskit/editor-common/types").PublicPluginAPI<[
106
107
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"loom", {
108
+ pluginConfiguration: import("..").LoomPluginOptions;
107
109
  dependencies: [
108
110
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
109
111
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
@@ -152,7 +154,7 @@ declare const _default: React.FC<import("react-intl-next").WithIntlProps<{
152
154
  }, import("@atlaskit/editor-common/types").HyperlinkPluginOptions | undefined>
153
155
  ];
154
156
  sharedState: import("..").LoomPluginState | undefined;
155
- }, undefined>,
157
+ }, import("..").LoomPluginOptions>,
156
158
  import("@atlaskit/editor-common/types").OptionalPlugin<import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"analytics", {
157
159
  pluginConfiguration: import("@atlaskit/editor-plugin-analytics").AnalyticsPluginOptions;
158
160
  sharedState: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-loom",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "Loom plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,9 +36,9 @@
36
36
  ".": "./src/index.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/editor-common": "^78.17.0",
39
+ "@atlaskit/editor-common": "^78.23.0",
40
40
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
41
- "@atlaskit/editor-plugin-hyperlink": "^1.1.0",
41
+ "@atlaskit/editor-plugin-hyperlink": "^1.4.0",
42
42
  "@atlaskit/editor-prosemirror": "3.0.0",
43
43
  "@atlaskit/icon": "^22.1.0",
44
44
  "@babel/runtime": "^7.0.0",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@atlaskit/editor-plugin-base": "^1.0.0",
53
- "@atlaskit/editor-plugin-card": "^1.2.0",
53
+ "@atlaskit/editor-plugin-card": "^1.4.0",
54
54
  "@atlaskit/editor-plugin-copy-button": "^1.0.0",
55
55
  "@atlaskit/editor-plugin-decorations": "^1.0.0",
56
56
  "@atlaskit/editor-plugin-editor-disabled": "^1.0.0",