@atlaskit/editor-plugin-loom 2.8.4 → 3.0.1
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 +22 -0
- package/dist/cjs/commands.js +109 -2
- package/dist/cjs/plugin.js +12 -58
- package/dist/cjs/pm-plugin.js +2 -78
- package/dist/cjs/types.js +5 -1
- package/dist/cjs/ui/PrimaryToolbarButton.js +99 -0
- package/dist/cjs/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +43 -24
- package/dist/cjs/ui/quickInsert.js +56 -0
- package/dist/es2019/commands.js +93 -0
- package/dist/es2019/plugin.js +15 -57
- package/dist/es2019/pm-plugin.js +3 -64
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/PrimaryToolbarButton.js +84 -0
- package/dist/es2019/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +40 -22
- package/dist/es2019/ui/quickInsert.js +44 -0
- package/dist/esm/commands.js +107 -1
- package/dist/esm/plugin.js +13 -58
- package/dist/esm/pm-plugin.js +3 -79
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/PrimaryToolbarButton.js +90 -0
- package/dist/esm/ui/{ToolbarButton.js → ToolbarButtonComponent.js} +39 -21
- package/dist/esm/ui/quickInsert.js +49 -0
- package/dist/types/commands.d.ts +5 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +14 -3
- package/dist/types/types.d.ts +32 -1
- package/dist/types/ui/PrimaryToolbarButton.d.ts +4 -0
- package/dist/types/ui/ToolbarButtonComponent.d.ts +20 -0
- package/dist/types/ui/quickInsert.d.ts +3 -0
- package/dist/types-ts4.5/commands.d.ts +5 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +14 -3
- package/dist/types-ts4.5/types.d.ts +32 -1
- package/dist/types-ts4.5/ui/PrimaryToolbarButton.d.ts +4 -0
- package/dist/types-ts4.5/ui/ToolbarButtonComponent.d.ts +20 -0
- package/dist/types-ts4.5/ui/quickInsert.d.ts +3 -0
- package/package.json +5 -3
- package/.eslintrc.js +0 -6
- package/dist/types/ui/ToolbarButton.d.ts +0 -800
- package/dist/types-ts4.5/ui/ToolbarButton.d.ts +0 -958
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-loom
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#143146](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/143146)
|
|
14
|
+
[`8f698f1278514`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8f698f1278514) -
|
|
15
|
+
[ux] [ED-24905] Main change: make loom plugin config, loomProvider, optional, and add optional
|
|
16
|
+
config, renderButton, to support customising loom button, e.g. adding pulse, spotlight. This
|
|
17
|
+
change is required to support loom cross-sell flow. In this flow, loom SDK will not be initialised
|
|
18
|
+
unless loomProvider is passed in. Once loomProvider is ready, `initLoom` action can be used to
|
|
19
|
+
initialise SDK. This change should be backwards compatible and will not impact the existing flow.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 2.8.4
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.recordVideoFailed = exports.recordVideo = exports.insertVideo = exports.insertLoom = exports.enableLoom = exports.disableLoom = void 0;
|
|
7
|
+
exports.setupLoom = exports.recordVideoFailed = exports.recordVideo = exports.insertVideo = exports.insertLoom = exports.executeRecordVideo = exports.enableLoom = exports.disableLoom = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
8
12
|
var _pmPlugin = require("./pm-plugin");
|
|
13
|
+
var _quickInsert = require("./ui/quickInsert");
|
|
9
14
|
var enableLoom = exports.enableLoom = function enableLoom(_ref) {
|
|
10
15
|
var loomButton = _ref.loomButton;
|
|
11
16
|
return function (_ref2) {
|
|
@@ -116,4 +121,106 @@ var insertLoom = exports.insertLoom = function insertLoom(editorView, api, video
|
|
|
116
121
|
to = _getPositions.to;
|
|
117
122
|
return (_api$hyperlink$action = api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.actions.insertLink(_analytics.INPUT_METHOD.TYPEAHEAD, from, to, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
|
|
118
123
|
)(state, dispatch)) !== null && _api$hyperlink$action !== void 0 ? _api$hyperlink$action : false;
|
|
119
|
-
};
|
|
124
|
+
};
|
|
125
|
+
var executeRecordVideo = exports.executeRecordVideo = function executeRecordVideo(api) {
|
|
126
|
+
var _api$core, _api$analytics;
|
|
127
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(recordVideo({
|
|
128
|
+
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
129
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
130
|
+
}));
|
|
131
|
+
};
|
|
132
|
+
var setupLoom = exports.setupLoom = /*#__PURE__*/function () {
|
|
133
|
+
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(loomProvider, api, editorView, isAfterEditorLoaded) {
|
|
134
|
+
var _api$core4;
|
|
135
|
+
var clientResult, _api$core2, _api$analytics2, attachToButton, loomButton, _api$analytics6;
|
|
136
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
137
|
+
while (1) switch (_context.prev = _context.next) {
|
|
138
|
+
case 0:
|
|
139
|
+
_context.next = 2;
|
|
140
|
+
return loomProvider.getClient();
|
|
141
|
+
case 2:
|
|
142
|
+
clientResult = _context.sent;
|
|
143
|
+
if (!(clientResult.status === 'error')) {
|
|
144
|
+
_context.next = 8;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(disableLoom({
|
|
148
|
+
error: clientResult.message
|
|
149
|
+
}));
|
|
150
|
+
(0, _monitoring.logException)(new Error(clientResult.message), {
|
|
151
|
+
location: 'editor-plugin-loom/sdk-initialisation'
|
|
152
|
+
});
|
|
153
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
|
|
154
|
+
action: _analytics.ACTION.ERRORED,
|
|
155
|
+
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
156
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
157
|
+
attributes: {
|
|
158
|
+
error: clientResult.message
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
return _context.abrupt("return", {
|
|
162
|
+
error: clientResult.message
|
|
163
|
+
});
|
|
164
|
+
case 8:
|
|
165
|
+
attachToButton = clientResult.client.attachToButton; // Hidden element to work around the SDK API
|
|
166
|
+
loomButton = document.createElement('button');
|
|
167
|
+
attachToButton({
|
|
168
|
+
button: loomButton,
|
|
169
|
+
onInsert: function onInsert(video) {
|
|
170
|
+
var _api$hyperlink2, _api$core3, _api$analytics3;
|
|
171
|
+
if (!editorView) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
var state = editorView.state,
|
|
175
|
+
dispatch = editorView.dispatch;
|
|
176
|
+
var pos = state.selection.from;
|
|
177
|
+
api === null || api === void 0 || (_api$hyperlink2 = api.hyperlink) === null || _api$hyperlink2 === void 0 || _api$hyperlink2.actions.insertLink(_analytics.INPUT_METHOD.TYPEAHEAD, pos,
|
|
178
|
+
// from === to, don't replace text to avoid accidental content loss
|
|
179
|
+
pos, video.sharedUrl, video.title, undefined, undefined, undefined, 'embed' // Convert to embed card instead of inline
|
|
180
|
+
)(state, dispatch);
|
|
181
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(insertVideo({
|
|
182
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions,
|
|
183
|
+
video: video
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref12) {
|
|
188
|
+
var tr = _ref12.tr;
|
|
189
|
+
enableLoom({
|
|
190
|
+
loomButton: loomButton
|
|
191
|
+
})({
|
|
192
|
+
tr: tr
|
|
193
|
+
});
|
|
194
|
+
if (isAfterEditorLoaded) {
|
|
195
|
+
var _api$quickInsert, _api$analytics4, _api$analytics5;
|
|
196
|
+
api === null || api === void 0 || (_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 || _api$quickInsert.commands.addQuickInsertItem((0, _quickInsert.getQuickInsertItem)(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions))({
|
|
197
|
+
tr: tr
|
|
198
|
+
});
|
|
199
|
+
api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || _api$analytics5.actions.attachAnalyticsEvent({
|
|
200
|
+
action: _analytics.ACTION.INITIALISED,
|
|
201
|
+
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
202
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
203
|
+
})(tr);
|
|
204
|
+
}
|
|
205
|
+
return tr;
|
|
206
|
+
});
|
|
207
|
+
if (!isAfterEditorLoaded) {
|
|
208
|
+
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
209
|
+
// filters out any transactions with steps (even analytics) when it's initialising
|
|
210
|
+
api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 || _api$analytics6.actions.fireAnalyticsEvent({
|
|
211
|
+
action: _analytics.ACTION.INITIALISED,
|
|
212
|
+
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
213
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return _context.abrupt("return", {});
|
|
217
|
+
case 14:
|
|
218
|
+
case "end":
|
|
219
|
+
return _context.stop();
|
|
220
|
+
}
|
|
221
|
+
}, _callee);
|
|
222
|
+
}));
|
|
223
|
+
return function setupLoom(_x, _x2, _x3, _x4) {
|
|
224
|
+
return _ref11.apply(this, arguments);
|
|
225
|
+
};
|
|
226
|
+
}();
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.loomPlugin = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
-
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
12
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
-
var _logo = require("@atlaskit/logo");
|
|
14
8
|
var _commands = require("./commands");
|
|
15
9
|
var _pmPlugin = require("./pm-plugin");
|
|
16
|
-
var
|
|
10
|
+
var _PrimaryToolbarButton = require("./ui/PrimaryToolbarButton");
|
|
11
|
+
var _quickInsert = require("./ui/quickInsert");
|
|
17
12
|
var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
18
13
|
var _api$analytics, _api$primaryToolbar;
|
|
19
14
|
var config = _ref.config,
|
|
@@ -26,18 +21,7 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
26
21
|
var editorViewRef = {
|
|
27
22
|
current: null
|
|
28
23
|
};
|
|
29
|
-
var primaryToolbarComponent =
|
|
30
|
-
var disabled = _ref2.disabled,
|
|
31
|
-
appearance = _ref2.appearance;
|
|
32
|
-
if (!config.shouldShowToolbarButton) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return /*#__PURE__*/_react.default.createElement(_ToolbarButton.default, {
|
|
36
|
-
disabled: disabled,
|
|
37
|
-
api: api,
|
|
38
|
-
appearance: appearance
|
|
39
|
-
});
|
|
40
|
-
};
|
|
24
|
+
var primaryToolbarComponent = (0, _PrimaryToolbarButton.loomPrimaryToolbarComponent)(config, api);
|
|
41
25
|
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
42
26
|
name: 'loom',
|
|
43
27
|
component: primaryToolbarComponent
|
|
@@ -48,6 +32,10 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
48
32
|
recordVideo: _commands.recordVideo,
|
|
49
33
|
insertLoom: function insertLoom(video, positionType) {
|
|
50
34
|
return (0, _commands.insertLoom)(editorViewRef.current, api, video, positionType);
|
|
35
|
+
},
|
|
36
|
+
initLoom: function initLoom(_ref2) {
|
|
37
|
+
var loomProvider = _ref2.loomProvider;
|
|
38
|
+
return (0, _commands.setupLoom)(loomProvider, api, editorViewRef.current, true);
|
|
51
39
|
}
|
|
52
40
|
},
|
|
53
41
|
pmPlugins: function pmPlugins() {
|
|
@@ -85,45 +73,11 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
85
73
|
},
|
|
86
74
|
pluginsOptions: {
|
|
87
75
|
// Enable inserting Loom recordings through the slash command
|
|
88
|
-
quickInsert: function quickInsert(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
description: formatMessage(_messages.toolbarInsertBlockMessages.recordVideoDescription),
|
|
94
|
-
keywords: ['loom', 'record', 'video'],
|
|
95
|
-
priority: 800,
|
|
96
|
-
icon: function icon() {
|
|
97
|
-
return /*#__PURE__*/_react.default.createElement(_logo.LoomIcon, {
|
|
98
|
-
appearance: "brand"
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
action: function action(insert, editorState) {
|
|
102
|
-
var _recordVideo;
|
|
103
|
-
var tr = insert(undefined);
|
|
104
|
-
var loomState = _pmPlugin.loomPluginKey.getState(editorState);
|
|
105
|
-
if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) {
|
|
106
|
-
var _recordVideoFailed;
|
|
107
|
-
var errorMessage = loomState === null || loomState === void 0 ? void 0 : loomState.error;
|
|
108
|
-
(0, _monitoring.logException)(new Error(errorMessage), {
|
|
109
|
-
location: 'editor-plugin-loom/quick-insert-record-video'
|
|
110
|
-
});
|
|
111
|
-
return (_recordVideoFailed = (0, _commands.recordVideoFailed)({
|
|
112
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
113
|
-
error: errorMessage,
|
|
114
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
115
|
-
})({
|
|
116
|
-
tr: tr
|
|
117
|
-
})) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false;
|
|
118
|
-
}
|
|
119
|
-
return (_recordVideo = (0, _commands.recordVideo)({
|
|
120
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
121
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
122
|
-
})({
|
|
123
|
-
tr: tr
|
|
124
|
-
})) !== null && _recordVideo !== void 0 ? _recordVideo : false;
|
|
125
|
-
}
|
|
126
|
-
}];
|
|
76
|
+
quickInsert: function quickInsert(intl) {
|
|
77
|
+
if (config.loomProvider) {
|
|
78
|
+
return (0, _quickInsert.getQuickInsertItem)(editorAnalyticsAPI)(intl);
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
127
81
|
}
|
|
128
82
|
},
|
|
129
83
|
// Enable inserting Loom recordings through main toolbar
|
package/dist/cjs/pm-plugin.js
CHANGED
|
@@ -5,11 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.loomPluginKey = exports.createPlugin = exports.LoomPluginAction = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
|
-
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
13
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
14
10
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
11
|
var _commands = require("./commands");
|
|
@@ -24,10 +20,8 @@ var LoomPluginAction = exports.LoomPluginAction = /*#__PURE__*/function (LoomPlu
|
|
|
24
20
|
}({});
|
|
25
21
|
var loomPluginKey = exports.loomPluginKey = new _state.PluginKey('loom');
|
|
26
22
|
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
27
|
-
var _api$analytics;
|
|
28
23
|
var config = _ref.config,
|
|
29
24
|
api = _ref.api;
|
|
30
|
-
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
31
25
|
return new _safePlugin.SafePlugin({
|
|
32
26
|
key: loomPluginKey,
|
|
33
27
|
state: {
|
|
@@ -74,78 +68,8 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
74
68
|
}
|
|
75
69
|
},
|
|
76
70
|
view: function view(editorView) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var _api$core3, _api$analytics3;
|
|
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) {
|
|
83
|
-
case 0:
|
|
84
|
-
_context.next = 2;
|
|
85
|
-
return config.loomProvider.getClient();
|
|
86
|
-
case 2:
|
|
87
|
-
clientResult = _context.sent;
|
|
88
|
-
if (!(clientResult.status === 'error')) {
|
|
89
|
-
_context.next = 8;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute((0, _commands.disableLoom)({
|
|
93
|
-
error: clientResult.message
|
|
94
|
-
}));
|
|
95
|
-
(0, _monitoring.logException)(new Error(clientResult.message), {
|
|
96
|
-
location: 'editor-plugin-loom/sdk-initialisation'
|
|
97
|
-
});
|
|
98
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
|
|
99
|
-
action: _analytics.ACTION.ERRORED,
|
|
100
|
-
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
101
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
102
|
-
attributes: {
|
|
103
|
-
error: clientResult.message
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
return _context.abrupt("return");
|
|
107
|
-
case 8:
|
|
108
|
-
attachToButton = clientResult.client.attachToButton; // Hidden element to work around the SDK API
|
|
109
|
-
loomButton = document.createElement('button');
|
|
110
|
-
attachToButton({
|
|
111
|
-
button: loomButton,
|
|
112
|
-
onInsert: function onInsert(video) {
|
|
113
|
-
var _api$hyperlink, _api$core2;
|
|
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
|
-
});
|
|
127
|
-
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute((0, _commands.enableLoom)({
|
|
128
|
-
loomButton: loomButton
|
|
129
|
-
}));
|
|
130
|
-
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
131
|
-
// filters out any transactions with steps (even analytics) when it's initialising
|
|
132
|
-
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
|
|
133
|
-
action: _analytics.ACTION.INITIALISED,
|
|
134
|
-
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
135
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
136
|
-
});
|
|
137
|
-
case 13:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context.stop();
|
|
140
|
-
}
|
|
141
|
-
}, _callee);
|
|
142
|
-
}));
|
|
143
|
-
return function setupLoom() {
|
|
144
|
-
return _ref2.apply(this, arguments);
|
|
145
|
-
};
|
|
146
|
-
}();
|
|
147
|
-
if (config) {
|
|
148
|
-
setupLoom();
|
|
71
|
+
if (config.loomProvider) {
|
|
72
|
+
(0, _commands.setupLoom)(config.loomProvider, api, editorView);
|
|
149
73
|
}
|
|
150
74
|
return {};
|
|
151
75
|
}
|
package/dist/cjs/types.js
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.loomPrimaryToolbarComponent = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _react2 = require("@emotion/react");
|
|
13
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
|
+
var _commands = require("../commands");
|
|
15
|
+
var _pmPlugin = require("../pm-plugin");
|
|
16
|
+
var _ToolbarButtonComponent = _interopRequireDefault(require("./ToolbarButtonComponent"));
|
|
17
|
+
var _excluded = ["onClickBeforeInit", "isDisabled", "href"];
|
|
18
|
+
/**
|
|
19
|
+
* @jsxRuntime classic
|
|
20
|
+
* @jsx jsx
|
|
21
|
+
*/
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
23
|
+
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); }
|
|
24
|
+
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 && {}.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; }
|
|
25
|
+
var CustomisableLoomToolbarButton = function CustomisableLoomToolbarButton(editorView, disabled, appearance, api) {
|
|
26
|
+
return /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
27
|
+
var _loomPluginKey$getSta;
|
|
28
|
+
var onClickBeforeInit = props.onClickBeforeInit,
|
|
29
|
+
_props$isDisabled = props.isDisabled,
|
|
30
|
+
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
31
|
+
href = props.href,
|
|
32
|
+
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
33
|
+
var isLoomEnabled = (_loomPluginKey$getSta = _pmPlugin.loomPluginKey.getState(editorView.state)) === null || _loomPluginKey$getSta === void 0 ? void 0 : _loomPluginKey$getSta.isEnabled;
|
|
34
|
+
var handleOnClick = (0, _react.useCallback)(function (e) {
|
|
35
|
+
if (isLoomEnabled) {
|
|
36
|
+
(0, _commands.executeRecordVideo)(api);
|
|
37
|
+
} else {
|
|
38
|
+
onClickBeforeInit && onClickBeforeInit(e);
|
|
39
|
+
}
|
|
40
|
+
}, [isLoomEnabled, onClickBeforeInit]);
|
|
41
|
+
return (0, _react2.jsx)(_ToolbarButtonComponent.default, (0, _extends2.default)({
|
|
42
|
+
ref: ref,
|
|
43
|
+
hideTooltip: !!(restProps.onMouseEnter || restProps.onMouseLeave)
|
|
44
|
+
// Ignore href if Loom is enabled so that it doesn't interfere with recording
|
|
45
|
+
,
|
|
46
|
+
href: isLoomEnabled ? undefined : href,
|
|
47
|
+
disabled: disabled || isDisabled,
|
|
48
|
+
api: api,
|
|
49
|
+
appearance: appearance,
|
|
50
|
+
onClick: function onClick(e) {
|
|
51
|
+
return handleOnClick(e);
|
|
52
|
+
}
|
|
53
|
+
}, restProps));
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var LoomToolbarButtonWrapper = function LoomToolbarButtonWrapper(_ref) {
|
|
57
|
+
var disabled = _ref.disabled,
|
|
58
|
+
api = _ref.api,
|
|
59
|
+
appearance = _ref.appearance;
|
|
60
|
+
var handleOnClick = (0, _react.useCallback)(function () {
|
|
61
|
+
return (0, _commands.executeRecordVideo)(api);
|
|
62
|
+
}, [api]);
|
|
63
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['loom']),
|
|
64
|
+
loomState = _useSharedPluginState.loomState;
|
|
65
|
+
if (!loomState) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return (0, _react2.jsx)(_ToolbarButtonComponent.default
|
|
69
|
+
// Disable the icon while the SDK isn't initialised
|
|
70
|
+
, {
|
|
71
|
+
disabled: disabled || !(loomState !== null && loomState !== void 0 && loomState.isEnabled),
|
|
72
|
+
api: api,
|
|
73
|
+
appearance: appearance,
|
|
74
|
+
onClick: handleOnClick
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var loomPrimaryToolbarComponent = exports.loomPrimaryToolbarComponent = function loomPrimaryToolbarComponent(config, api) {
|
|
78
|
+
return function (_ref2) {
|
|
79
|
+
var disabled = _ref2.disabled,
|
|
80
|
+
appearance = _ref2.appearance,
|
|
81
|
+
editorView = _ref2.editorView;
|
|
82
|
+
if (config.shouldShowToolbarButton === false) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (config.renderButton) {
|
|
86
|
+
return config.renderButton(CustomisableLoomToolbarButton(editorView, disabled, appearance, api));
|
|
87
|
+
}
|
|
88
|
+
if (config.shouldShowToolbarButton) {
|
|
89
|
+
return (0, _react2.jsx)(LoomToolbarButtonWrapper
|
|
90
|
+
// Disable the icon while the SDK isn't initialised
|
|
91
|
+
, {
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
api: api,
|
|
94
|
+
appearance: appearance
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
@@ -1,57 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
|
-
var _react = require("
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
8
10
|
var _reactIntlNext = require("react-intl-next");
|
|
9
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
13
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
13
14
|
var _logo = require("@atlaskit/logo");
|
|
14
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
-
var _commands = require("../commands");
|
|
16
16
|
/**
|
|
17
17
|
* @jsxRuntime classic
|
|
18
18
|
* @jsx jsx
|
|
19
19
|
*/
|
|
20
|
+
|
|
20
21
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
22
|
|
|
22
23
|
// This const is derived from the breakpoint where the toolbar hides its icons. It is used to hide the text in the AI button.
|
|
23
24
|
// Derived from values from platform/packages/editor/editor-core/src/ui/Appearance/FullPage/MainToolbar.tsx
|
|
24
25
|
var LOOM_BUTTON_WIDTH_BREAKPOINT = 1076;
|
|
25
|
-
var
|
|
26
|
+
var LoomToolbarButtonInternal = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
26
27
|
var disabled = _ref.disabled,
|
|
27
28
|
api = _ref.api,
|
|
28
29
|
appearance = _ref.appearance,
|
|
29
|
-
formatMessage = _ref.intl.formatMessage
|
|
30
|
+
formatMessage = _ref.intl.formatMessage,
|
|
31
|
+
selected = _ref.selected,
|
|
32
|
+
onBlur = _ref.onBlur,
|
|
33
|
+
onFocus = _ref.onFocus,
|
|
34
|
+
onKeyDown = _ref.onKeyDown,
|
|
35
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
36
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
37
|
+
ariaControls = _ref['aria-controls'],
|
|
38
|
+
ariaExpanded = _ref['aria-expanded'],
|
|
39
|
+
ariaHasPopup = _ref['aria-haspopup'],
|
|
40
|
+
dataDsLevel = _ref['data-ds--level'],
|
|
41
|
+
onClick = _ref.onClick,
|
|
42
|
+
href = _ref.href,
|
|
43
|
+
target = _ref.target,
|
|
44
|
+
hideTooltip = _ref.hideTooltip;
|
|
30
45
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['loom', 'width']),
|
|
31
|
-
loomState = _useSharedPluginState.loomState,
|
|
32
46
|
widthState = _useSharedPluginState.widthState;
|
|
33
|
-
if (!loomState) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
47
|
var label = formatMessage(appearance === 'comment' ? _messages.toolbarInsertBlockMessages.addLoomVideoComment : _messages.toolbarInsertBlockMessages.addLoomVideo);
|
|
37
48
|
var shouldShowRecordText = (0, _platformFeatureFlags.fg)('platform.editor.plugin.loom.responsive-menu_4at4a') && ((widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0) > LOOM_BUTTON_WIDTH_BREAKPOINT;
|
|
38
|
-
return (0,
|
|
49
|
+
return (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
|
50
|
+
hideTooltip: hideTooltip,
|
|
51
|
+
ref: ref,
|
|
52
|
+
href: href,
|
|
39
53
|
buttonId: _uiMenu.TOOLBAR_BUTTON.RECORD_VIDEO,
|
|
40
|
-
|
|
41
|
-
var _api$core, _api$analytics;
|
|
42
|
-
return api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute((0, _commands.recordVideo)({
|
|
43
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR,
|
|
44
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
// Disable the icon while the SDK isn't initialised
|
|
48
|
-
,
|
|
49
|
-
disabled: disabled || !(loomState !== null && loomState !== void 0 && loomState.isEnabled),
|
|
54
|
+
disabled: disabled,
|
|
50
55
|
title: label,
|
|
51
|
-
iconBefore: (0,
|
|
56
|
+
iconBefore: (0, _react2.jsx)(_logo.LoomIcon, {
|
|
52
57
|
label: label,
|
|
53
58
|
size: "small"
|
|
54
|
-
})
|
|
59
|
+
}),
|
|
60
|
+
selected: selected,
|
|
61
|
+
onBlur: onBlur,
|
|
62
|
+
onFocus: onFocus,
|
|
63
|
+
onKeyDown: onKeyDown,
|
|
64
|
+
onMouseEnter: onMouseEnter,
|
|
65
|
+
onMouseLeave: onMouseLeave,
|
|
66
|
+
"aria-controls": ariaControls,
|
|
67
|
+
"aria-expanded": ariaExpanded,
|
|
68
|
+
"aria-haspopup": ariaHasPopup,
|
|
69
|
+
"data-ds--level": dataDsLevel,
|
|
70
|
+
onClick: onClick,
|
|
71
|
+
target: target
|
|
55
72
|
}, shouldShowRecordText && formatMessage(_messages.toolbarInsertBlockMessages.recordLoomShortTitle));
|
|
56
|
-
};
|
|
57
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(
|
|
73
|
+
});
|
|
74
|
+
var _default = exports.default = (0, _reactIntlNext.injectIntl)(LoomToolbarButtonInternal, {
|
|
75
|
+
forwardRef: true
|
|
76
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getQuickInsertItem = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
|
+
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
12
|
+
var _logo = require("@atlaskit/logo");
|
|
13
|
+
var _commands = require("../commands");
|
|
14
|
+
var _pmPlugin = require("../pm-plugin");
|
|
15
|
+
var getQuickInsertItem = exports.getQuickInsertItem = function getQuickInsertItem(editorAnalyticsAPI) {
|
|
16
|
+
return function (_ref) {
|
|
17
|
+
var formatMessage = _ref.formatMessage;
|
|
18
|
+
return [{
|
|
19
|
+
id: 'loom',
|
|
20
|
+
title: formatMessage(_messages.toolbarInsertBlockMessages.recordVideo),
|
|
21
|
+
description: formatMessage(_messages.toolbarInsertBlockMessages.recordVideoDescription),
|
|
22
|
+
keywords: ['loom', 'record', 'video'],
|
|
23
|
+
priority: 800,
|
|
24
|
+
icon: function icon() {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_logo.LoomIcon, {
|
|
26
|
+
appearance: "brand"
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
action: function action(insert, editorState) {
|
|
30
|
+
var _recordVideo;
|
|
31
|
+
var tr = insert(undefined);
|
|
32
|
+
var loomState = _pmPlugin.loomPluginKey.getState(editorState);
|
|
33
|
+
if (!(loomState !== null && loomState !== void 0 && loomState.isEnabled)) {
|
|
34
|
+
var _recordVideoFailed;
|
|
35
|
+
var errorMessage = loomState === null || loomState === void 0 ? void 0 : loomState.error;
|
|
36
|
+
(0, _monitoring.logException)(new Error(errorMessage), {
|
|
37
|
+
location: 'editor-plugin-loom/quick-insert-record-video'
|
|
38
|
+
});
|
|
39
|
+
return (_recordVideoFailed = (0, _commands.recordVideoFailed)({
|
|
40
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
41
|
+
error: errorMessage,
|
|
42
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
43
|
+
})({
|
|
44
|
+
tr: tr
|
|
45
|
+
})) !== null && _recordVideoFailed !== void 0 ? _recordVideoFailed : false;
|
|
46
|
+
}
|
|
47
|
+
return (_recordVideo = (0, _commands.recordVideo)({
|
|
48
|
+
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT,
|
|
49
|
+
editorAnalyticsAPI: editorAnalyticsAPI
|
|
50
|
+
})({
|
|
51
|
+
tr: tr
|
|
52
|
+
})) !== null && _recordVideo !== void 0 ? _recordVideo : false;
|
|
53
|
+
}
|
|
54
|
+
}];
|
|
55
|
+
};
|
|
56
|
+
};
|