@atlaskit/editor-plugin-loom 0.1.1 → 0.2.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 +16 -0
- package/dist/cjs/plugin.js +5 -23
- package/dist/cjs/pm-plugin.js +22 -35
- package/dist/es2019/plugin.js +2 -23
- package/dist/es2019/pm-plugin.js +14 -28
- package/dist/esm/plugin.js +6 -21
- package/dist/esm/pm-plugin.js +23 -36
- package/dist/types/pm-plugin.d.ts +1 -4
- package/dist/types-ts4.5/pm-plugin.d.ts +1 -4
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-loom
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#59421](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59421) [`3747754f8ab0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3747754f8ab0) - NO-ISSUE Added the capability to directly trigger an analytics event as an action to the editor analytics plugin
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 0.1.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
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
|
});
|
|
8
7
|
exports.loomPlugin = void 0;
|
|
9
|
-
var _react =
|
|
10
|
-
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
11
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
@@ -15,28 +13,12 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
15
13
|
var _commands = require("./commands");
|
|
16
14
|
var _pmPlugin = require("./pm-plugin");
|
|
17
15
|
var _ToolbarButton = _interopRequireDefault(require("./ui/ToolbarButton"));
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
16
|
var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
21
17
|
var _api$analytics;
|
|
22
18
|
var api = _ref.api;
|
|
23
19
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
24
20
|
return {
|
|
25
21
|
name: 'loom',
|
|
26
|
-
usePluginHook: function usePluginHook(_ref2) {
|
|
27
|
-
var editorView = _ref2.editorView;
|
|
28
|
-
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
29
|
-
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
30
|
-
(0, _react.useLayoutEffect)(function () {
|
|
31
|
-
var dispatch = editorView.dispatch,
|
|
32
|
-
tr = editorView.state.tr;
|
|
33
|
-
tr.setMeta(_pmPlugin.loomPluginKey, {
|
|
34
|
-
type: _pmPlugin.LoomPluginAction.SET_ANALYTICS_FUNCTION,
|
|
35
|
-
createAnalyticsEvent: createAnalyticsEvent
|
|
36
|
-
});
|
|
37
|
-
dispatch(tr);
|
|
38
|
-
}, [createAnalyticsEvent, editorView]);
|
|
39
|
-
},
|
|
40
22
|
pmPlugins: function pmPlugins() {
|
|
41
23
|
return [{
|
|
42
24
|
name: 'loom',
|
|
@@ -53,8 +35,8 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
53
35
|
},
|
|
54
36
|
pluginsOptions: {
|
|
55
37
|
// Enable inserting Loom recordings through the slash command
|
|
56
|
-
quickInsert: function quickInsert(
|
|
57
|
-
var formatMessage =
|
|
38
|
+
quickInsert: function quickInsert(_ref2) {
|
|
39
|
+
var formatMessage = _ref2.formatMessage;
|
|
58
40
|
return [{
|
|
59
41
|
id: 'loom',
|
|
60
42
|
title: formatMessage(_messages.toolbarInsertBlockMessages.recordVideo),
|
|
@@ -93,8 +75,8 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
93
75
|
}
|
|
94
76
|
},
|
|
95
77
|
// Enable inserting Loom recordings through main toolbar
|
|
96
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
97
|
-
var disabled =
|
|
78
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
|
|
79
|
+
var disabled = _ref3.disabled;
|
|
98
80
|
return /*#__PURE__*/_react.default.createElement(_ToolbarButton.default, {
|
|
99
81
|
disabled: disabled,
|
|
100
82
|
api: api
|
package/dist/cjs/pm-plugin.js
CHANGED
|
@@ -23,7 +23,6 @@ var LoomPluginAction = exports.LoomPluginAction = /*#__PURE__*/function (LoomPlu
|
|
|
23
23
|
LoomPluginAction[LoomPluginAction["DISABLE"] = 1] = "DISABLE";
|
|
24
24
|
LoomPluginAction[LoomPluginAction["RECORD_VIDEO"] = 2] = "RECORD_VIDEO";
|
|
25
25
|
LoomPluginAction[LoomPluginAction["INSERT_VIDEO"] = 3] = "INSERT_VIDEO";
|
|
26
|
-
LoomPluginAction[LoomPluginAction["SET_ANALYTICS_FUNCTION"] = 4] = "SET_ANALYTICS_FUNCTION";
|
|
27
26
|
return LoomPluginAction;
|
|
28
27
|
}({});
|
|
29
28
|
var loomPluginKey = exports.loomPluginKey = new _state.PluginKey('loom');
|
|
@@ -39,30 +38,23 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
39
38
|
isEnabled: false,
|
|
40
39
|
loomButton: null,
|
|
41
40
|
isRecordingVideo: false,
|
|
42
|
-
error: undefined
|
|
43
|
-
createAnalyticsEvent: undefined
|
|
41
|
+
error: undefined
|
|
44
42
|
};
|
|
45
43
|
},
|
|
46
44
|
apply: function apply(tr, pluginState) {
|
|
47
45
|
var _tr$getMeta, _pluginState$loomButt;
|
|
48
46
|
var action = (_tr$getMeta = tr.getMeta(loomPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
49
47
|
switch (action) {
|
|
50
|
-
case LoomPluginAction.SET_ANALYTICS_FUNCTION:
|
|
51
|
-
var _tr$getMeta2 = tr.getMeta(loomPluginKey),
|
|
52
|
-
createAnalyticsEvent = _tr$getMeta2.createAnalyticsEvent;
|
|
53
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
54
|
-
createAnalyticsEvent: createAnalyticsEvent
|
|
55
|
-
});
|
|
56
48
|
case LoomPluginAction.ENABLE:
|
|
57
|
-
var _tr$
|
|
58
|
-
loomButton = _tr$
|
|
49
|
+
var _tr$getMeta2 = tr.getMeta(loomPluginKey),
|
|
50
|
+
loomButton = _tr$getMeta2.loomButton;
|
|
59
51
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
60
52
|
isEnabled: true,
|
|
61
53
|
loomButton: loomButton
|
|
62
54
|
});
|
|
63
55
|
case LoomPluginAction.DISABLE:
|
|
64
|
-
var _tr$
|
|
65
|
-
error = _tr$
|
|
56
|
+
var _tr$getMeta3 = tr.getMeta(loomPluginKey),
|
|
57
|
+
error = _tr$getMeta3.error;
|
|
66
58
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
67
59
|
isEnabled: false,
|
|
68
60
|
loomButton: null,
|
|
@@ -86,7 +78,8 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
86
78
|
view: function view(editorView) {
|
|
87
79
|
var setupLoom = /*#__PURE__*/function () {
|
|
88
80
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
89
|
-
var
|
|
81
|
+
var _api$analytics3;
|
|
82
|
+
var _yield$import, isSupported, setup, _yield$isSupported, supported, error, _api$analytics2, _yield$setup, configureButton, loomButton, sdkButton;
|
|
90
83
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
91
84
|
while (1) switch (_context2.prev = _context2.next) {
|
|
92
85
|
case 0:
|
|
@@ -105,7 +98,7 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
105
98
|
supported = _yield$isSupported.supported;
|
|
106
99
|
error = _yield$isSupported.error;
|
|
107
100
|
if (supported) {
|
|
108
|
-
_context2.next =
|
|
101
|
+
_context2.next = 15;
|
|
109
102
|
break;
|
|
110
103
|
}
|
|
111
104
|
// Keep plugin state update and analytics separate to avoid accidentally not updating
|
|
@@ -118,24 +111,21 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
118
111
|
});
|
|
119
112
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
120
113
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
attributes: {
|
|
128
|
-
error: error
|
|
129
|
-
}
|
|
114
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
|
|
115
|
+
action: _analytics.ACTION.ERRORED,
|
|
116
|
+
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
117
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
118
|
+
attributes: {
|
|
119
|
+
error: error
|
|
130
120
|
}
|
|
131
121
|
});
|
|
132
122
|
return _context2.abrupt("return");
|
|
133
|
-
case
|
|
134
|
-
_context2.next =
|
|
123
|
+
case 15:
|
|
124
|
+
_context2.next = 17;
|
|
135
125
|
return setup({
|
|
136
126
|
publicAppId: LOOM_SDK_PUBLIC_APP_ID
|
|
137
127
|
});
|
|
138
|
-
case
|
|
128
|
+
case 17:
|
|
139
129
|
_yield$setup = _context2.sent;
|
|
140
130
|
configureButton = _yield$setup.configureButton;
|
|
141
131
|
// Hidden element to work around the SDK API
|
|
@@ -175,15 +165,12 @@ var createPlugin = exports.createPlugin = function createPlugin(api) {
|
|
|
175
165
|
}));
|
|
176
166
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
177
167
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
183
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
184
|
-
}
|
|
168
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
|
|
169
|
+
action: _analytics.ACTION.INITIALISED,
|
|
170
|
+
actionSubject: _analytics.ACTION_SUBJECT.LOOM,
|
|
171
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
185
172
|
});
|
|
186
|
-
case
|
|
173
|
+
case 24:
|
|
187
174
|
case "end":
|
|
188
175
|
return _context2.stop();
|
|
189
176
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
|
|
5
4
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
5
|
import { IconLoom } from '@atlaskit/editor-common/quick-insert';
|
|
7
6
|
import { recordVideo, recordVideoFailed } from './commands';
|
|
8
|
-
import { createPlugin,
|
|
7
|
+
import { createPlugin, loomPluginKey } from './pm-plugin';
|
|
9
8
|
import LoomToolbarButton from './ui/ToolbarButton';
|
|
10
9
|
export const loomPlugin = ({
|
|
11
10
|
api
|
|
@@ -14,26 +13,6 @@ export const loomPlugin = ({
|
|
|
14
13
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
15
14
|
return {
|
|
16
15
|
name: 'loom',
|
|
17
|
-
usePluginHook({
|
|
18
|
-
editorView
|
|
19
|
-
}) {
|
|
20
|
-
const {
|
|
21
|
-
createAnalyticsEvent
|
|
22
|
-
} = useAnalyticsEvents();
|
|
23
|
-
useLayoutEffect(() => {
|
|
24
|
-
const {
|
|
25
|
-
dispatch,
|
|
26
|
-
state: {
|
|
27
|
-
tr
|
|
28
|
-
}
|
|
29
|
-
} = editorView;
|
|
30
|
-
tr.setMeta(loomPluginKey, {
|
|
31
|
-
type: LoomPluginAction.SET_ANALYTICS_FUNCTION,
|
|
32
|
-
createAnalyticsEvent
|
|
33
|
-
});
|
|
34
|
-
dispatch(tr);
|
|
35
|
-
}, [createAnalyticsEvent, editorView]);
|
|
36
|
-
},
|
|
37
16
|
pmPlugins: () => [{
|
|
38
17
|
name: 'loom',
|
|
39
18
|
plugin: () => createPlugin(api)
|
package/dist/es2019/pm-plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE,
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -8,7 +8,6 @@ export let LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
|
|
|
8
8
|
LoomPluginAction[LoomPluginAction["DISABLE"] = 1] = "DISABLE";
|
|
9
9
|
LoomPluginAction[LoomPluginAction["RECORD_VIDEO"] = 2] = "RECORD_VIDEO";
|
|
10
10
|
LoomPluginAction[LoomPluginAction["INSERT_VIDEO"] = 3] = "INSERT_VIDEO";
|
|
11
|
-
LoomPluginAction[LoomPluginAction["SET_ANALYTICS_FUNCTION"] = 4] = "SET_ANALYTICS_FUNCTION";
|
|
12
11
|
return LoomPluginAction;
|
|
13
12
|
}({});
|
|
14
13
|
export const loomPluginKey = new PluginKey('loom');
|
|
@@ -23,21 +22,12 @@ export const createPlugin = api => {
|
|
|
23
22
|
isEnabled: false,
|
|
24
23
|
loomButton: null,
|
|
25
24
|
isRecordingVideo: false,
|
|
26
|
-
error: undefined
|
|
27
|
-
createAnalyticsEvent: undefined
|
|
25
|
+
error: undefined
|
|
28
26
|
}),
|
|
29
27
|
apply: (tr, pluginState) => {
|
|
30
28
|
var _tr$getMeta, _pluginState$loomButt;
|
|
31
29
|
const action = (_tr$getMeta = tr.getMeta(loomPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
32
30
|
switch (action) {
|
|
33
|
-
case LoomPluginAction.SET_ANALYTICS_FUNCTION:
|
|
34
|
-
const {
|
|
35
|
-
createAnalyticsEvent
|
|
36
|
-
} = tr.getMeta(loomPluginKey);
|
|
37
|
-
return {
|
|
38
|
-
...pluginState,
|
|
39
|
-
createAnalyticsEvent
|
|
40
|
-
};
|
|
41
31
|
case LoomPluginAction.ENABLE:
|
|
42
32
|
const {
|
|
43
33
|
loomButton
|
|
@@ -76,6 +66,7 @@ export const createPlugin = api => {
|
|
|
76
66
|
},
|
|
77
67
|
view(editorView) {
|
|
78
68
|
const setupLoom = async () => {
|
|
69
|
+
var _api$analytics3;
|
|
79
70
|
// Asynchronously check if the Loom SDK is supported
|
|
80
71
|
// it hits a Loom API so could take a while
|
|
81
72
|
const {
|
|
@@ -87,6 +78,7 @@ export const createPlugin = api => {
|
|
|
87
78
|
error
|
|
88
79
|
} = await isSupported();
|
|
89
80
|
if (!supported) {
|
|
81
|
+
var _api$analytics2;
|
|
90
82
|
// Keep plugin state update and analytics separate to avoid accidentally not updating
|
|
91
83
|
// plugin state due to collab-edit filtering out transactions with steps
|
|
92
84
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(disableLoom({
|
|
@@ -97,15 +89,12 @@ export const createPlugin = api => {
|
|
|
97
89
|
});
|
|
98
90
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
99
91
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
attributes: {
|
|
107
|
-
error
|
|
108
|
-
}
|
|
92
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.fireAnalyticsEvent({
|
|
93
|
+
action: ACTION.ERRORED,
|
|
94
|
+
actionSubject: ACTION_SUBJECT.LOOM,
|
|
95
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
96
|
+
attributes: {
|
|
97
|
+
error
|
|
109
98
|
}
|
|
110
99
|
});
|
|
111
100
|
return;
|
|
@@ -144,13 +133,10 @@ export const createPlugin = api => {
|
|
|
144
133
|
}));
|
|
145
134
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
146
135
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
actionSubject: ACTION_SUBJECT.LOOM,
|
|
152
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
153
|
-
}
|
|
136
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.fireAnalyticsEvent({
|
|
137
|
+
action: ACTION.INITIALISED,
|
|
138
|
+
actionSubject: ACTION_SUBJECT.LOOM,
|
|
139
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
154
140
|
});
|
|
155
141
|
};
|
|
156
142
|
setupLoom();
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
|
|
5
4
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
6
5
|
import { IconLoom } from '@atlaskit/editor-common/quick-insert';
|
|
7
6
|
import { recordVideo, recordVideoFailed } from './commands';
|
|
8
|
-
import { createPlugin,
|
|
7
|
+
import { createPlugin, loomPluginKey } from './pm-plugin';
|
|
9
8
|
import LoomToolbarButton from './ui/ToolbarButton';
|
|
10
9
|
export var loomPlugin = function loomPlugin(_ref) {
|
|
11
10
|
var _api$analytics;
|
|
@@ -13,20 +12,6 @@ export var loomPlugin = function loomPlugin(_ref) {
|
|
|
13
12
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
14
13
|
return {
|
|
15
14
|
name: 'loom',
|
|
16
|
-
usePluginHook: function usePluginHook(_ref2) {
|
|
17
|
-
var editorView = _ref2.editorView;
|
|
18
|
-
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
19
|
-
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
20
|
-
useLayoutEffect(function () {
|
|
21
|
-
var dispatch = editorView.dispatch,
|
|
22
|
-
tr = editorView.state.tr;
|
|
23
|
-
tr.setMeta(loomPluginKey, {
|
|
24
|
-
type: LoomPluginAction.SET_ANALYTICS_FUNCTION,
|
|
25
|
-
createAnalyticsEvent: createAnalyticsEvent
|
|
26
|
-
});
|
|
27
|
-
dispatch(tr);
|
|
28
|
-
}, [createAnalyticsEvent, editorView]);
|
|
29
|
-
},
|
|
30
15
|
pmPlugins: function pmPlugins() {
|
|
31
16
|
return [{
|
|
32
17
|
name: 'loom',
|
|
@@ -43,8 +28,8 @@ export var loomPlugin = function loomPlugin(_ref) {
|
|
|
43
28
|
},
|
|
44
29
|
pluginsOptions: {
|
|
45
30
|
// Enable inserting Loom recordings through the slash command
|
|
46
|
-
quickInsert: function quickInsert(
|
|
47
|
-
var formatMessage =
|
|
31
|
+
quickInsert: function quickInsert(_ref2) {
|
|
32
|
+
var formatMessage = _ref2.formatMessage;
|
|
48
33
|
return [{
|
|
49
34
|
id: 'loom',
|
|
50
35
|
title: formatMessage(toolbarInsertBlockMessages.recordVideo),
|
|
@@ -83,8 +68,8 @@ export var loomPlugin = function loomPlugin(_ref) {
|
|
|
83
68
|
}
|
|
84
69
|
},
|
|
85
70
|
// Enable inserting Loom recordings through main toolbar
|
|
86
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
87
|
-
var disabled =
|
|
71
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
|
|
72
|
+
var disabled = _ref3.disabled;
|
|
88
73
|
return /*#__PURE__*/React.createElement(LoomToolbarButton, {
|
|
89
74
|
disabled: disabled,
|
|
90
75
|
api: api
|
package/dist/esm/pm-plugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
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
5
|
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,
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
8
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
9
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -13,7 +13,6 @@ export var LoomPluginAction = /*#__PURE__*/function (LoomPluginAction) {
|
|
|
13
13
|
LoomPluginAction[LoomPluginAction["DISABLE"] = 1] = "DISABLE";
|
|
14
14
|
LoomPluginAction[LoomPluginAction["RECORD_VIDEO"] = 2] = "RECORD_VIDEO";
|
|
15
15
|
LoomPluginAction[LoomPluginAction["INSERT_VIDEO"] = 3] = "INSERT_VIDEO";
|
|
16
|
-
LoomPluginAction[LoomPluginAction["SET_ANALYTICS_FUNCTION"] = 4] = "SET_ANALYTICS_FUNCTION";
|
|
17
16
|
return LoomPluginAction;
|
|
18
17
|
}({});
|
|
19
18
|
export var loomPluginKey = new PluginKey('loom');
|
|
@@ -29,30 +28,23 @@ export var createPlugin = function createPlugin(api) {
|
|
|
29
28
|
isEnabled: false,
|
|
30
29
|
loomButton: null,
|
|
31
30
|
isRecordingVideo: false,
|
|
32
|
-
error: undefined
|
|
33
|
-
createAnalyticsEvent: undefined
|
|
31
|
+
error: undefined
|
|
34
32
|
};
|
|
35
33
|
},
|
|
36
34
|
apply: function apply(tr, pluginState) {
|
|
37
35
|
var _tr$getMeta, _pluginState$loomButt;
|
|
38
36
|
var action = (_tr$getMeta = tr.getMeta(loomPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
39
37
|
switch (action) {
|
|
40
|
-
case LoomPluginAction.SET_ANALYTICS_FUNCTION:
|
|
41
|
-
var _tr$getMeta2 = tr.getMeta(loomPluginKey),
|
|
42
|
-
createAnalyticsEvent = _tr$getMeta2.createAnalyticsEvent;
|
|
43
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
44
|
-
createAnalyticsEvent: createAnalyticsEvent
|
|
45
|
-
});
|
|
46
38
|
case LoomPluginAction.ENABLE:
|
|
47
|
-
var _tr$
|
|
48
|
-
loomButton = _tr$
|
|
39
|
+
var _tr$getMeta2 = tr.getMeta(loomPluginKey),
|
|
40
|
+
loomButton = _tr$getMeta2.loomButton;
|
|
49
41
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
50
42
|
isEnabled: true,
|
|
51
43
|
loomButton: loomButton
|
|
52
44
|
});
|
|
53
45
|
case LoomPluginAction.DISABLE:
|
|
54
|
-
var _tr$
|
|
55
|
-
error = _tr$
|
|
46
|
+
var _tr$getMeta3 = tr.getMeta(loomPluginKey),
|
|
47
|
+
error = _tr$getMeta3.error;
|
|
56
48
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
57
49
|
isEnabled: false,
|
|
58
50
|
loomButton: null,
|
|
@@ -76,7 +68,8 @@ export var createPlugin = function createPlugin(api) {
|
|
|
76
68
|
view: function view(editorView) {
|
|
77
69
|
var setupLoom = /*#__PURE__*/function () {
|
|
78
70
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
79
|
-
var
|
|
71
|
+
var _api$analytics3;
|
|
72
|
+
var _yield$import, isSupported, setup, _yield$isSupported, supported, error, _api$analytics2, _yield$setup, configureButton, loomButton, sdkButton;
|
|
80
73
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
81
74
|
while (1) switch (_context2.prev = _context2.next) {
|
|
82
75
|
case 0:
|
|
@@ -93,7 +86,7 @@ export var createPlugin = function createPlugin(api) {
|
|
|
93
86
|
supported = _yield$isSupported.supported;
|
|
94
87
|
error = _yield$isSupported.error;
|
|
95
88
|
if (supported) {
|
|
96
|
-
_context2.next =
|
|
89
|
+
_context2.next = 15;
|
|
97
90
|
break;
|
|
98
91
|
}
|
|
99
92
|
// Keep plugin state update and analytics separate to avoid accidentally not updating
|
|
@@ -106,24 +99,21 @@ export var createPlugin = function createPlugin(api) {
|
|
|
106
99
|
});
|
|
107
100
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
108
101
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
attributes: {
|
|
116
|
-
error: error
|
|
117
|
-
}
|
|
102
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.fireAnalyticsEvent({
|
|
103
|
+
action: ACTION.ERRORED,
|
|
104
|
+
actionSubject: ACTION_SUBJECT.LOOM,
|
|
105
|
+
eventType: EVENT_TYPE.OPERATIONAL,
|
|
106
|
+
attributes: {
|
|
107
|
+
error: error
|
|
118
108
|
}
|
|
119
109
|
});
|
|
120
110
|
return _context2.abrupt("return");
|
|
121
|
-
case
|
|
122
|
-
_context2.next =
|
|
111
|
+
case 15:
|
|
112
|
+
_context2.next = 17;
|
|
123
113
|
return setup({
|
|
124
114
|
publicAppId: LOOM_SDK_PUBLIC_APP_ID
|
|
125
115
|
});
|
|
126
|
-
case
|
|
116
|
+
case 17:
|
|
127
117
|
_yield$setup = _context2.sent;
|
|
128
118
|
configureButton = _yield$setup.configureButton;
|
|
129
119
|
// Hidden element to work around the SDK API
|
|
@@ -163,15 +153,12 @@ export var createPlugin = function createPlugin(api) {
|
|
|
163
153
|
}));
|
|
164
154
|
// We're not combining the analytics steps into the enable / disable commands because the collab-edit plugin
|
|
165
155
|
// filters out any transactions with steps (even analytics) when it's initialising
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
actionSubject: ACTION_SUBJECT.LOOM,
|
|
171
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
172
|
-
}
|
|
156
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.fireAnalyticsEvent({
|
|
157
|
+
action: ACTION.INITIALISED,
|
|
158
|
+
actionSubject: ACTION_SUBJECT.LOOM,
|
|
159
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
173
160
|
});
|
|
174
|
-
case
|
|
161
|
+
case 24:
|
|
175
162
|
case "end":
|
|
176
163
|
return _context2.stop();
|
|
177
164
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
|
|
2
|
-
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -9,14 +8,12 @@ export interface LoomPluginState {
|
|
|
9
8
|
loomButton: HTMLButtonElement | null;
|
|
10
9
|
isRecordingVideo: boolean;
|
|
11
10
|
error: SDKUnsupportedReasons | undefined;
|
|
12
|
-
createAnalyticsEvent: CreateUIAnalyticsEvent | undefined;
|
|
13
11
|
}
|
|
14
12
|
export declare enum LoomPluginAction {
|
|
15
13
|
ENABLE = 0,
|
|
16
14
|
DISABLE = 1,
|
|
17
15
|
RECORD_VIDEO = 2,
|
|
18
|
-
INSERT_VIDEO = 3
|
|
19
|
-
SET_ANALYTICS_FUNCTION = 4
|
|
16
|
+
INSERT_VIDEO = 3
|
|
20
17
|
}
|
|
21
18
|
export declare const loomPluginKey: PluginKey<LoomPluginState>;
|
|
22
19
|
export declare const createPlugin: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => SafePlugin<LoomPluginState>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SDKUnsupportedReasons } from '@loomhq/record-sdk';
|
|
2
|
-
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
3
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -9,14 +8,12 @@ export interface LoomPluginState {
|
|
|
9
8
|
loomButton: HTMLButtonElement | null;
|
|
10
9
|
isRecordingVideo: boolean;
|
|
11
10
|
error: SDKUnsupportedReasons | undefined;
|
|
12
|
-
createAnalyticsEvent: CreateUIAnalyticsEvent | undefined;
|
|
13
11
|
}
|
|
14
12
|
export declare enum LoomPluginAction {
|
|
15
13
|
ENABLE = 0,
|
|
16
14
|
DISABLE = 1,
|
|
17
15
|
RECORD_VIDEO = 2,
|
|
18
|
-
INSERT_VIDEO = 3
|
|
19
|
-
SET_ANALYTICS_FUNCTION = 4
|
|
16
|
+
INSERT_VIDEO = 3
|
|
20
17
|
}
|
|
21
18
|
export declare const loomPluginKey: PluginKey<LoomPluginState>;
|
|
22
19
|
export declare const createPlugin: (api: ExtractInjectionAPI<LoomPlugin> | undefined) => SafePlugin<LoomPluginState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-loom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Loom plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"website": {
|
|
15
15
|
"name": "EditorPluginLoom",
|
|
16
16
|
"category": "Components"
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"runReact18": false
|
|
18
19
|
},
|
|
19
20
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
20
21
|
"main": "dist/cjs/index.js",
|
|
@@ -35,10 +36,9 @@
|
|
|
35
36
|
".": "./src/index.ts"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@atlaskit/
|
|
39
|
-
"@atlaskit/editor-
|
|
40
|
-
"@atlaskit/editor-plugin-
|
|
41
|
-
"@atlaskit/editor-plugin-hyperlink": "^0.6.0",
|
|
39
|
+
"@atlaskit/editor-common": "^76.36.0",
|
|
40
|
+
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
41
|
+
"@atlaskit/editor-plugin-hyperlink": "^0.7.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
43
43
|
"@atlaskit/icon": "^22.0.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@atlaskit/editor-plugin-base": "^0.
|
|
53
|
-
"@atlaskit/editor-plugin-card": "^0.
|
|
52
|
+
"@atlaskit/editor-plugin-base": "^0.3.0",
|
|
53
|
+
"@atlaskit/editor-plugin-card": "^0.16.0",
|
|
54
54
|
"@atlaskit/editor-plugin-copy-button": "^1.0.0",
|
|
55
55
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
56
56
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|