@atlaskit/editor-plugin-loom 5.1.2 → 5.1.4
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/loomPlugin.js +15 -6
- package/dist/cjs/ui/LoomMenuItem.js +99 -0
- package/dist/cjs/ui/toolbar-components.js +46 -0
- package/dist/es2019/loomPlugin.js +15 -6
- package/dist/es2019/ui/LoomMenuItem.js +91 -0
- package/dist/es2019/ui/toolbar-components.js +40 -0
- package/dist/esm/loomPlugin.js +15 -6
- package/dist/esm/ui/LoomMenuItem.js +91 -0
- package/dist/esm/ui/toolbar-components.js +39 -0
- package/dist/types/loomPluginType.d.ts +24 -22
- package/dist/types/pm-plugins/commands.d.ts +3 -3
- package/dist/types/pm-plugins/main.d.ts +3 -3
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/ui/LoomMenuItem.d.ts +6 -0
- package/dist/types/ui/ToolbarButtonComponent.d.ts +3 -3
- package/dist/types/ui/toolbar-components.d.ts +5 -0
- package/dist/types-ts4.5/loomPluginType.d.ts +24 -22
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/main.d.ts +3 -3
- package/dist/types-ts4.5/types/index.d.ts +3 -3
- package/dist/types-ts4.5/ui/LoomMenuItem.d.ts +6 -0
- package/dist/types-ts4.5/ui/ToolbarButtonComponent.d.ts +3 -3
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +5 -0
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-loom
|
|
2
2
|
|
|
3
|
+
## 5.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4ef462fecb522`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4ef462fecb522) -
|
|
8
|
+
[ux] [ED-29003] Register loom component as a dropdown menu item in overflow menu
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.1.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`265c1bf0cefa4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/265c1bf0cefa4) -
|
|
16
|
+
Sorted type and interface props to improve Atlaskit docs
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 5.1.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/loomPlugin.js
CHANGED
|
@@ -5,15 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loomPlugin = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
9
|
var _commands = require("./pm-plugins/commands");
|
|
9
10
|
var _main = require("./pm-plugins/main");
|
|
10
11
|
var _PrimaryToolbarButton = require("./ui/PrimaryToolbarButton");
|
|
11
12
|
var _quickInsert = require("./ui/quickInsert");
|
|
13
|
+
var _toolbarComponents = require("./ui/toolbar-components");
|
|
12
14
|
var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
13
|
-
var _api$analytics
|
|
15
|
+
var _api$analytics;
|
|
14
16
|
var config = _ref.config,
|
|
15
17
|
api = _ref.api;
|
|
16
18
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
19
|
+
var isNewToolbarEnabled = (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_migrate_loom', 'isEnabled', true);
|
|
17
20
|
|
|
18
21
|
// Workaround since we want to insert a loom via the `hyperlink` plugin for now.
|
|
19
22
|
// The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
|
|
@@ -22,10 +25,16 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
22
25
|
current: null
|
|
23
26
|
};
|
|
24
27
|
var primaryToolbarComponent = (0, _PrimaryToolbarButton.loomPrimaryToolbarComponent)(config, api);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
28
|
+
if (isNewToolbarEnabled) {
|
|
29
|
+
var _api$toolbar;
|
|
30
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(config, api));
|
|
31
|
+
} else {
|
|
32
|
+
var _api$primaryToolbar;
|
|
33
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
34
|
+
name: 'loom',
|
|
35
|
+
component: primaryToolbarComponent
|
|
36
|
+
});
|
|
37
|
+
}
|
|
29
38
|
return {
|
|
30
39
|
name: 'loom',
|
|
31
40
|
actions: {
|
|
@@ -81,6 +90,6 @@ var loomPlugin = exports.loomPlugin = function loomPlugin(_ref) {
|
|
|
81
90
|
}
|
|
82
91
|
},
|
|
83
92
|
// Enable inserting Loom recordings through main toolbar
|
|
84
|
-
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
93
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && !isNewToolbarEnabled ? primaryToolbarComponent : undefined
|
|
85
94
|
};
|
|
86
95
|
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LoomMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
13
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
|
+
var _commands = require("../pm-plugins/commands");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
var useLoomEnabled = function useLoomEnabled(api) {
|
|
17
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['loom'], function (states) {
|
|
18
|
+
var _states$loomState;
|
|
19
|
+
return {
|
|
20
|
+
loomEnabled: (_states$loomState = states.loomState) === null || _states$loomState === void 0 ? void 0 : _states$loomState.isEnabled
|
|
21
|
+
};
|
|
22
|
+
}),
|
|
23
|
+
loomEnabled = _useSharedPluginState.loomEnabled;
|
|
24
|
+
return loomEnabled;
|
|
25
|
+
};
|
|
26
|
+
var LoomMenuItem = exports.LoomMenuItem = function LoomMenuItem(_ref) {
|
|
27
|
+
var api = _ref.api,
|
|
28
|
+
renderButton = _ref.renderButton;
|
|
29
|
+
var loomEnabled = useLoomEnabled(api);
|
|
30
|
+
if (renderButton) {
|
|
31
|
+
return renderButton(CustomisableLoomMenuItem(api));
|
|
32
|
+
} else if (loomEnabled !== undefined) {
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(DefaultLoomMenuItem, {
|
|
34
|
+
api: api
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
|
|
39
|
+
return /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
|
|
40
|
+
var _ref2$isDisabled = _ref2.isDisabled,
|
|
41
|
+
isDisabled = _ref2$isDisabled === void 0 ? false : _ref2$isDisabled,
|
|
42
|
+
onClickBeforeInit = _ref2.onClickBeforeInit,
|
|
43
|
+
href = _ref2.href,
|
|
44
|
+
target = _ref2.target,
|
|
45
|
+
rel = _ref2.rel;
|
|
46
|
+
var loomEnabled = !!useLoomEnabled(api);
|
|
47
|
+
var handleOnClick = (0, _react.useCallback)(function (e) {
|
|
48
|
+
if (loomEnabled) {
|
|
49
|
+
(0, _commands.executeRecordVideo)(api);
|
|
50
|
+
} else if (onClickBeforeInit && e.type === 'click' && e.target instanceof HTMLElement) {
|
|
51
|
+
onClickBeforeInit(e);
|
|
52
|
+
}
|
|
53
|
+
}, [loomEnabled, onClickBeforeInit]);
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(MenuItemComponent, {
|
|
55
|
+
ref: ref
|
|
56
|
+
// Ignore href if Loom is enabled so that it doesn't interfere with recording
|
|
57
|
+
,
|
|
58
|
+
href: loomEnabled ? undefined : href,
|
|
59
|
+
disabled: isDisabled,
|
|
60
|
+
onClick: handleOnClick,
|
|
61
|
+
target: target,
|
|
62
|
+
rel: rel
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
var DefaultLoomMenuItem = function DefaultLoomMenuItem(_ref3) {
|
|
67
|
+
var api = _ref3.api;
|
|
68
|
+
var loomEnabled = useLoomEnabled(api);
|
|
69
|
+
var handleOnClick = (0, _react.useCallback)(function () {
|
|
70
|
+
return (0, _commands.executeRecordVideo)(api);
|
|
71
|
+
}, [api]);
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(MenuItemComponent, {
|
|
73
|
+
disabled: !loomEnabled,
|
|
74
|
+
onClick: handleOnClick
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
var MenuItemComponent = /*#__PURE__*/_react.default.forwardRef(function (_ref4, ref) {
|
|
78
|
+
var disabled = _ref4.disabled,
|
|
79
|
+
_onClick = _ref4.onClick,
|
|
80
|
+
href = _ref4.href,
|
|
81
|
+
target = _ref4.target,
|
|
82
|
+
rel = _ref4.rel;
|
|
83
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
84
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
85
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
86
|
+
formatMessage = _useIntl.formatMessage;
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
88
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.LoomIcon, {
|
|
89
|
+
label: ""
|
|
90
|
+
}),
|
|
91
|
+
isDisabled: disabled,
|
|
92
|
+
href: href,
|
|
93
|
+
target: target,
|
|
94
|
+
rel: rel,
|
|
95
|
+
onClick: function onClick(e) {
|
|
96
|
+
return _onClick(e);
|
|
97
|
+
}
|
|
98
|
+
}, formatMessage(editorAppearance === 'comment' ? _messages.toolbarInsertBlockMessages.addLoomVideoComment : _messages.toolbarInsertBlockMessages.addLoomVideo));
|
|
99
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getToolbarComponents = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
11
|
+
var _LoomMenuItem = require("./LoomMenuItem");
|
|
12
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(config, api) {
|
|
13
|
+
return [{
|
|
14
|
+
type: _toolbar.LOOM_MENU_SECTION.type,
|
|
15
|
+
key: _toolbar.LOOM_MENU_SECTION.key,
|
|
16
|
+
parents: [{
|
|
17
|
+
type: _toolbar.OVERFLOW_MENU.type,
|
|
18
|
+
key: _toolbar.OVERFLOW_MENU.key,
|
|
19
|
+
rank: _toolbar.OVERFLOW_MENU_RANK[_toolbar.LOOM_MENU_SECTION.key]
|
|
20
|
+
}, {
|
|
21
|
+
type: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR.type,
|
|
22
|
+
key: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR.key,
|
|
23
|
+
rank: _toolbar.OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK[_toolbar.LOOM_MENU_SECTION.key]
|
|
24
|
+
}],
|
|
25
|
+
component: function component(_ref) {
|
|
26
|
+
var children = _ref.children;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
28
|
+
hasSeparator: true
|
|
29
|
+
}, children);
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
type: _toolbar.LOOM_MENU_ITEM.type,
|
|
33
|
+
key: _toolbar.LOOM_MENU_ITEM.key,
|
|
34
|
+
parents: [{
|
|
35
|
+
type: _toolbar.LOOM_MENU_SECTION.type,
|
|
36
|
+
key: _toolbar.LOOM_MENU_SECTION.key,
|
|
37
|
+
rank: _toolbar.LOOM_MENU_SECTION_RANK[_toolbar.LOOM_MENU_ITEM.key]
|
|
38
|
+
}],
|
|
39
|
+
component: function component() {
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_LoomMenuItem.LoomMenuItem, {
|
|
41
|
+
api: api,
|
|
42
|
+
renderButton: config.renderButton
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}];
|
|
46
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { insertLoom, recordVideo, setupLoom } from './pm-plugins/commands';
|
|
3
4
|
import { createPlugin, loomPluginKey } from './pm-plugins/main';
|
|
4
5
|
import { loomPrimaryToolbarComponent } from './ui/PrimaryToolbarButton';
|
|
5
6
|
import { getQuickInsertItem } from './ui/quickInsert';
|
|
7
|
+
import { getToolbarComponents } from './ui/toolbar-components';
|
|
6
8
|
export const loomPlugin = ({
|
|
7
9
|
config,
|
|
8
10
|
api
|
|
9
11
|
}) => {
|
|
10
|
-
var _api$analytics
|
|
12
|
+
var _api$analytics;
|
|
11
13
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
14
|
+
const isNewToolbarEnabled = expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true);
|
|
12
15
|
|
|
13
16
|
// Workaround since we want to insert a loom via the `hyperlink` plugin for now.
|
|
14
17
|
// The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
|
|
@@ -17,10 +20,16 @@ export const loomPlugin = ({
|
|
|
17
20
|
current: null
|
|
18
21
|
};
|
|
19
22
|
const primaryToolbarComponent = loomPrimaryToolbarComponent(config, api);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
23
|
+
if (isNewToolbarEnabled) {
|
|
24
|
+
var _api$toolbar;
|
|
25
|
+
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents(config, api));
|
|
26
|
+
} else {
|
|
27
|
+
var _api$primaryToolbar;
|
|
28
|
+
api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
|
|
29
|
+
name: 'loom',
|
|
30
|
+
component: primaryToolbarComponent
|
|
31
|
+
});
|
|
32
|
+
}
|
|
24
33
|
return {
|
|
25
34
|
name: 'loom',
|
|
26
35
|
actions: {
|
|
@@ -71,6 +80,6 @@ export const loomPlugin = ({
|
|
|
71
80
|
}
|
|
72
81
|
},
|
|
73
82
|
// Enable inserting Loom recordings through main toolbar
|
|
74
|
-
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
83
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && !isNewToolbarEnabled ? primaryToolbarComponent : undefined
|
|
75
84
|
};
|
|
76
85
|
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { LoomIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
7
|
+
import { executeRecordVideo } from '../pm-plugins/commands';
|
|
8
|
+
const useLoomEnabled = api => {
|
|
9
|
+
const {
|
|
10
|
+
loomEnabled
|
|
11
|
+
} = useSharedPluginStateWithSelector(api, ['loom'], states => {
|
|
12
|
+
var _states$loomState;
|
|
13
|
+
return {
|
|
14
|
+
loomEnabled: (_states$loomState = states.loomState) === null || _states$loomState === void 0 ? void 0 : _states$loomState.isEnabled
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
return loomEnabled;
|
|
18
|
+
};
|
|
19
|
+
export const LoomMenuItem = ({
|
|
20
|
+
api,
|
|
21
|
+
renderButton
|
|
22
|
+
}) => {
|
|
23
|
+
const loomEnabled = useLoomEnabled(api);
|
|
24
|
+
if (renderButton) {
|
|
25
|
+
return renderButton(CustomisableLoomMenuItem(api));
|
|
26
|
+
} else if (loomEnabled !== undefined) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(DefaultLoomMenuItem, {
|
|
28
|
+
api: api
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const CustomisableLoomMenuItem = api => /*#__PURE__*/React.forwardRef(({
|
|
33
|
+
isDisabled = false,
|
|
34
|
+
onClickBeforeInit,
|
|
35
|
+
href,
|
|
36
|
+
target,
|
|
37
|
+
rel
|
|
38
|
+
}, ref) => {
|
|
39
|
+
const loomEnabled = !!useLoomEnabled(api);
|
|
40
|
+
const handleOnClick = useCallback(e => {
|
|
41
|
+
if (loomEnabled) {
|
|
42
|
+
executeRecordVideo(api);
|
|
43
|
+
} else if (onClickBeforeInit && e.type === 'click' && e.target instanceof HTMLElement) {
|
|
44
|
+
onClickBeforeInit(e);
|
|
45
|
+
}
|
|
46
|
+
}, [loomEnabled, onClickBeforeInit]);
|
|
47
|
+
return /*#__PURE__*/React.createElement(MenuItemComponent, {
|
|
48
|
+
ref: ref
|
|
49
|
+
// Ignore href if Loom is enabled so that it doesn't interfere with recording
|
|
50
|
+
,
|
|
51
|
+
href: loomEnabled ? undefined : href,
|
|
52
|
+
disabled: isDisabled,
|
|
53
|
+
onClick: handleOnClick,
|
|
54
|
+
target: target,
|
|
55
|
+
rel: rel
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
const DefaultLoomMenuItem = ({
|
|
59
|
+
api
|
|
60
|
+
}) => {
|
|
61
|
+
const loomEnabled = useLoomEnabled(api);
|
|
62
|
+
const handleOnClick = useCallback(() => executeRecordVideo(api), [api]);
|
|
63
|
+
return /*#__PURE__*/React.createElement(MenuItemComponent, {
|
|
64
|
+
disabled: !loomEnabled,
|
|
65
|
+
onClick: handleOnClick
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const MenuItemComponent = /*#__PURE__*/React.forwardRef(({
|
|
69
|
+
disabled,
|
|
70
|
+
onClick,
|
|
71
|
+
href,
|
|
72
|
+
target,
|
|
73
|
+
rel
|
|
74
|
+
}, ref) => {
|
|
75
|
+
const {
|
|
76
|
+
editorAppearance
|
|
77
|
+
} = useEditorToolbar();
|
|
78
|
+
const {
|
|
79
|
+
formatMessage
|
|
80
|
+
} = useIntl();
|
|
81
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
82
|
+
elemBefore: /*#__PURE__*/React.createElement(LoomIcon, {
|
|
83
|
+
label: ""
|
|
84
|
+
}),
|
|
85
|
+
isDisabled: disabled,
|
|
86
|
+
href: href,
|
|
87
|
+
target: target,
|
|
88
|
+
rel: rel,
|
|
89
|
+
onClick: e => onClick(e)
|
|
90
|
+
}, formatMessage(editorAppearance === 'comment' ? messages.addLoomVideoComment : messages.addLoomVideo));
|
|
91
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LOOM_MENU_SECTION, OVERFLOW_MENU_RANK, OVERFLOW_MENU, LOOM_MENU_ITEM, LOOM_MENU_SECTION_RANK, OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK, OVERFLOW_MENU_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { LoomMenuItem } from './LoomMenuItem';
|
|
5
|
+
export const getToolbarComponents = (config, api) => {
|
|
6
|
+
return [{
|
|
7
|
+
type: LOOM_MENU_SECTION.type,
|
|
8
|
+
key: LOOM_MENU_SECTION.key,
|
|
9
|
+
parents: [{
|
|
10
|
+
type: OVERFLOW_MENU.type,
|
|
11
|
+
key: OVERFLOW_MENU.key,
|
|
12
|
+
rank: OVERFLOW_MENU_RANK[LOOM_MENU_SECTION.key]
|
|
13
|
+
}, {
|
|
14
|
+
type: OVERFLOW_MENU_PRIMARY_TOOLBAR.type,
|
|
15
|
+
key: OVERFLOW_MENU_PRIMARY_TOOLBAR.key,
|
|
16
|
+
rank: OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK[LOOM_MENU_SECTION.key]
|
|
17
|
+
}],
|
|
18
|
+
component: ({
|
|
19
|
+
children
|
|
20
|
+
}) => {
|
|
21
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
22
|
+
hasSeparator: true
|
|
23
|
+
}, children);
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
type: LOOM_MENU_ITEM.type,
|
|
27
|
+
key: LOOM_MENU_ITEM.key,
|
|
28
|
+
parents: [{
|
|
29
|
+
type: LOOM_MENU_SECTION.type,
|
|
30
|
+
key: LOOM_MENU_SECTION.key,
|
|
31
|
+
rank: LOOM_MENU_SECTION_RANK[LOOM_MENU_ITEM.key]
|
|
32
|
+
}],
|
|
33
|
+
component: () => {
|
|
34
|
+
return /*#__PURE__*/React.createElement(LoomMenuItem, {
|
|
35
|
+
api: api,
|
|
36
|
+
renderButton: config.renderButton
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}];
|
|
40
|
+
};
|
package/dist/esm/loomPlugin.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
3
|
import { insertLoom as _insertLoom, recordVideo, setupLoom } from './pm-plugins/commands';
|
|
3
4
|
import { createPlugin, loomPluginKey } from './pm-plugins/main';
|
|
4
5
|
import { loomPrimaryToolbarComponent } from './ui/PrimaryToolbarButton';
|
|
5
6
|
import { getQuickInsertItem } from './ui/quickInsert';
|
|
7
|
+
import { getToolbarComponents } from './ui/toolbar-components';
|
|
6
8
|
export var loomPlugin = function loomPlugin(_ref) {
|
|
7
|
-
var _api$analytics
|
|
9
|
+
var _api$analytics;
|
|
8
10
|
var config = _ref.config,
|
|
9
11
|
api = _ref.api;
|
|
10
12
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
13
|
+
var isNewToolbarEnabled = expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && expValEquals('platform_editor_toolbar_migrate_loom', 'isEnabled', true);
|
|
11
14
|
|
|
12
15
|
// Workaround since we want to insert a loom via the `hyperlink` plugin for now.
|
|
13
16
|
// The hyperlink plugin (and the card plugin) are deeply tied into using the Prosemirror Command
|
|
@@ -16,10 +19,16 @@ export var loomPlugin = function loomPlugin(_ref) {
|
|
|
16
19
|
current: null
|
|
17
20
|
};
|
|
18
21
|
var primaryToolbarComponent = loomPrimaryToolbarComponent(config, api);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
22
|
+
if (isNewToolbarEnabled) {
|
|
23
|
+
var _api$toolbar;
|
|
24
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(config, api));
|
|
25
|
+
} else {
|
|
26
|
+
var _api$primaryToolbar;
|
|
27
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
28
|
+
name: 'loom',
|
|
29
|
+
component: primaryToolbarComponent
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
return {
|
|
24
33
|
name: 'loom',
|
|
25
34
|
actions: {
|
|
@@ -75,6 +84,6 @@ export var loomPlugin = function loomPlugin(_ref) {
|
|
|
75
84
|
}
|
|
76
85
|
},
|
|
77
86
|
// Enable inserting Loom recordings through main toolbar
|
|
78
|
-
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
87
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && !isNewToolbarEnabled ? primaryToolbarComponent : undefined
|
|
79
88
|
};
|
|
80
89
|
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { LoomIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
7
|
+
import { executeRecordVideo } from '../pm-plugins/commands';
|
|
8
|
+
var useLoomEnabled = function useLoomEnabled(api) {
|
|
9
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['loom'], function (states) {
|
|
10
|
+
var _states$loomState;
|
|
11
|
+
return {
|
|
12
|
+
loomEnabled: (_states$loomState = states.loomState) === null || _states$loomState === void 0 ? void 0 : _states$loomState.isEnabled
|
|
13
|
+
};
|
|
14
|
+
}),
|
|
15
|
+
loomEnabled = _useSharedPluginState.loomEnabled;
|
|
16
|
+
return loomEnabled;
|
|
17
|
+
};
|
|
18
|
+
export var LoomMenuItem = function LoomMenuItem(_ref) {
|
|
19
|
+
var api = _ref.api,
|
|
20
|
+
renderButton = _ref.renderButton;
|
|
21
|
+
var loomEnabled = useLoomEnabled(api);
|
|
22
|
+
if (renderButton) {
|
|
23
|
+
return renderButton(CustomisableLoomMenuItem(api));
|
|
24
|
+
} else if (loomEnabled !== undefined) {
|
|
25
|
+
return /*#__PURE__*/React.createElement(DefaultLoomMenuItem, {
|
|
26
|
+
api: api
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var CustomisableLoomMenuItem = function CustomisableLoomMenuItem(api) {
|
|
31
|
+
return /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
32
|
+
var _ref2$isDisabled = _ref2.isDisabled,
|
|
33
|
+
isDisabled = _ref2$isDisabled === void 0 ? false : _ref2$isDisabled,
|
|
34
|
+
onClickBeforeInit = _ref2.onClickBeforeInit,
|
|
35
|
+
href = _ref2.href,
|
|
36
|
+
target = _ref2.target,
|
|
37
|
+
rel = _ref2.rel;
|
|
38
|
+
var loomEnabled = !!useLoomEnabled(api);
|
|
39
|
+
var handleOnClick = useCallback(function (e) {
|
|
40
|
+
if (loomEnabled) {
|
|
41
|
+
executeRecordVideo(api);
|
|
42
|
+
} else if (onClickBeforeInit && e.type === 'click' && e.target instanceof HTMLElement) {
|
|
43
|
+
onClickBeforeInit(e);
|
|
44
|
+
}
|
|
45
|
+
}, [loomEnabled, onClickBeforeInit]);
|
|
46
|
+
return /*#__PURE__*/React.createElement(MenuItemComponent, {
|
|
47
|
+
ref: ref
|
|
48
|
+
// Ignore href if Loom is enabled so that it doesn't interfere with recording
|
|
49
|
+
,
|
|
50
|
+
href: loomEnabled ? undefined : href,
|
|
51
|
+
disabled: isDisabled,
|
|
52
|
+
onClick: handleOnClick,
|
|
53
|
+
target: target,
|
|
54
|
+
rel: rel
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var DefaultLoomMenuItem = function DefaultLoomMenuItem(_ref3) {
|
|
59
|
+
var api = _ref3.api;
|
|
60
|
+
var loomEnabled = useLoomEnabled(api);
|
|
61
|
+
var handleOnClick = useCallback(function () {
|
|
62
|
+
return executeRecordVideo(api);
|
|
63
|
+
}, [api]);
|
|
64
|
+
return /*#__PURE__*/React.createElement(MenuItemComponent, {
|
|
65
|
+
disabled: !loomEnabled,
|
|
66
|
+
onClick: handleOnClick
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
var MenuItemComponent = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
70
|
+
var disabled = _ref4.disabled,
|
|
71
|
+
_onClick = _ref4.onClick,
|
|
72
|
+
href = _ref4.href,
|
|
73
|
+
target = _ref4.target,
|
|
74
|
+
rel = _ref4.rel;
|
|
75
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
76
|
+
editorAppearance = _useEditorToolbar.editorAppearance;
|
|
77
|
+
var _useIntl = useIntl(),
|
|
78
|
+
formatMessage = _useIntl.formatMessage;
|
|
79
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
80
|
+
elemBefore: /*#__PURE__*/React.createElement(LoomIcon, {
|
|
81
|
+
label: ""
|
|
82
|
+
}),
|
|
83
|
+
isDisabled: disabled,
|
|
84
|
+
href: href,
|
|
85
|
+
target: target,
|
|
86
|
+
rel: rel,
|
|
87
|
+
onClick: function onClick(e) {
|
|
88
|
+
return _onClick(e);
|
|
89
|
+
}
|
|
90
|
+
}, formatMessage(editorAppearance === 'comment' ? messages.addLoomVideoComment : messages.addLoomVideo));
|
|
91
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LOOM_MENU_SECTION, OVERFLOW_MENU_RANK, OVERFLOW_MENU, LOOM_MENU_ITEM, LOOM_MENU_SECTION_RANK, OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK, OVERFLOW_MENU_PRIMARY_TOOLBAR } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { LoomMenuItem } from './LoomMenuItem';
|
|
5
|
+
export var getToolbarComponents = function getToolbarComponents(config, api) {
|
|
6
|
+
return [{
|
|
7
|
+
type: LOOM_MENU_SECTION.type,
|
|
8
|
+
key: LOOM_MENU_SECTION.key,
|
|
9
|
+
parents: [{
|
|
10
|
+
type: OVERFLOW_MENU.type,
|
|
11
|
+
key: OVERFLOW_MENU.key,
|
|
12
|
+
rank: OVERFLOW_MENU_RANK[LOOM_MENU_SECTION.key]
|
|
13
|
+
}, {
|
|
14
|
+
type: OVERFLOW_MENU_PRIMARY_TOOLBAR.type,
|
|
15
|
+
key: OVERFLOW_MENU_PRIMARY_TOOLBAR.key,
|
|
16
|
+
rank: OVERFLOW_MENU_PRIMARY_TOOLBAR_RANK[LOOM_MENU_SECTION.key]
|
|
17
|
+
}],
|
|
18
|
+
component: function component(_ref) {
|
|
19
|
+
var children = _ref.children;
|
|
20
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
21
|
+
hasSeparator: true
|
|
22
|
+
}, children);
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
type: LOOM_MENU_ITEM.type,
|
|
26
|
+
key: LOOM_MENU_ITEM.key,
|
|
27
|
+
parents: [{
|
|
28
|
+
type: LOOM_MENU_SECTION.type,
|
|
29
|
+
key: LOOM_MENU_SECTION.key,
|
|
30
|
+
rank: LOOM_MENU_SECTION_RANK[LOOM_MENU_ITEM.key]
|
|
31
|
+
}],
|
|
32
|
+
component: function component() {
|
|
33
|
+
return /*#__PURE__*/React.createElement(LoomMenuItem, {
|
|
34
|
+
api: api,
|
|
35
|
+
renderButton: config.renderButton
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}];
|
|
39
|
+
};
|
|
@@ -6,33 +6,12 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
8
|
import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
9
10
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
10
11
|
import type { LoomPluginState } from './pm-plugins/main';
|
|
11
12
|
import type { LoomPluginOptions, LoomProviderOptions, PositionType, VideoMeta } from './types';
|
|
12
13
|
export type LoomPlugin = NextEditorPlugin<'loom', {
|
|
13
|
-
pluginConfiguration: LoomPluginOptions;
|
|
14
|
-
dependencies: [
|
|
15
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
16
|
-
WidthPlugin,
|
|
17
|
-
HyperlinkPlugin,
|
|
18
|
-
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
19
|
-
OptionalPlugin<QuickInsertPlugin>,
|
|
20
|
-
OptionalPlugin<ConnectivityPlugin>
|
|
21
|
-
];
|
|
22
|
-
sharedState: LoomPluginState | undefined;
|
|
23
14
|
actions: {
|
|
24
|
-
recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
25
|
-
inputMethod: INPUT_METHOD;
|
|
26
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
27
|
-
}) => EditorCommand;
|
|
28
|
-
/**
|
|
29
|
-
* Insert loom into the document.
|
|
30
|
-
*
|
|
31
|
-
* @param video Video metadata (`sharedUrl` and `title`)
|
|
32
|
-
* @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
|
|
33
|
-
* @returns {boolean} If the loom was successfully inserted
|
|
34
|
-
*/
|
|
35
|
-
insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
|
|
36
15
|
/**
|
|
37
16
|
* Given loom provider, initialise loom SDK
|
|
38
17
|
* @returns error message if initialisation failed
|
|
@@ -42,5 +21,28 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
|
|
|
42
21
|
}) => Promise<{
|
|
43
22
|
error?: string;
|
|
44
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Insert loom into the document.
|
|
26
|
+
*
|
|
27
|
+
* @param video Video metadata (`sharedUrl` and `title`)
|
|
28
|
+
* @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
|
|
29
|
+
* @returns {boolean} If the loom was successfully inserted
|
|
30
|
+
*/
|
|
31
|
+
insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
|
|
32
|
+
recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
33
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
34
|
+
inputMethod: INPUT_METHOD;
|
|
35
|
+
}) => EditorCommand;
|
|
45
36
|
};
|
|
37
|
+
dependencies: [
|
|
38
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
39
|
+
WidthPlugin,
|
|
40
|
+
HyperlinkPlugin,
|
|
41
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
42
|
+
OptionalPlugin<QuickInsertPlugin>,
|
|
43
|
+
OptionalPlugin<ConnectivityPlugin>,
|
|
44
|
+
OptionalPlugin<ToolbarPlugin>
|
|
45
|
+
];
|
|
46
|
+
pluginConfiguration: LoomPluginOptions;
|
|
47
|
+
sharedState: LoomPluginState | undefined;
|
|
46
48
|
}>;
|
|
@@ -16,13 +16,13 @@ export declare const disableLoom: ({ error }: {
|
|
|
16
16
|
error: string;
|
|
17
17
|
}) => EditorCommand;
|
|
18
18
|
export declare const recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
19
|
-
inputMethod: INPUT_METHOD;
|
|
20
19
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
20
|
+
inputMethod: INPUT_METHOD;
|
|
21
21
|
}) => EditorCommand;
|
|
22
22
|
export declare const recordVideoFailed: ({ inputMethod, error, editorAnalyticsAPI, }: {
|
|
23
|
-
inputMethod: INPUT_METHOD;
|
|
24
|
-
error: SDKUnsupportedReasons | undefined;
|
|
25
23
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
24
|
+
error: SDKUnsupportedReasons | undefined;
|
|
25
|
+
inputMethod: INPUT_METHOD;
|
|
26
26
|
}) => EditorCommand;
|
|
27
27
|
export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
|
|
28
28
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
@@ -9,10 +9,10 @@ declare enum SDKUnsupportedReasons {
|
|
|
9
9
|
NoMediaStreamsSupport = "no-media-streams-support"
|
|
10
10
|
}
|
|
11
11
|
export interface LoomPluginState {
|
|
12
|
+
error: SDKUnsupportedReasons | undefined;
|
|
12
13
|
isEnabled: boolean;
|
|
13
|
-
loomButton: HTMLButtonElement | null;
|
|
14
14
|
isRecordingVideo: boolean;
|
|
15
|
-
|
|
15
|
+
loomButton: HTMLButtonElement | null;
|
|
16
16
|
}
|
|
17
17
|
export declare enum LoomPluginAction {
|
|
18
18
|
ENABLE = 0,
|
|
@@ -22,7 +22,7 @@ export declare enum LoomPluginAction {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const loomPluginKey: PluginKey<LoomPluginState>;
|
|
24
24
|
export declare const createPlugin: ({ config, api, }: {
|
|
25
|
-
config: LoomPluginOptions;
|
|
26
25
|
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
26
|
+
config: LoomPluginOptions;
|
|
27
27
|
}) => SafePlugin<LoomPluginState>;
|
|
28
28
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { type ButtonProps as AKButtonProps } from '@atlaskit/button';
|
|
3
3
|
export type VideoMeta = {
|
|
4
|
+
duration?: number;
|
|
4
5
|
sharedUrl: string;
|
|
5
6
|
title: string;
|
|
6
|
-
duration?: number;
|
|
7
7
|
};
|
|
8
8
|
type LoomClient = {
|
|
9
9
|
attachToButton: (options: {
|
|
@@ -15,11 +15,11 @@ export type PositionType = 'start' | 'end' | 'current';
|
|
|
15
15
|
export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
|
|
16
16
|
export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
|
|
17
17
|
export type GetClientResult = {
|
|
18
|
-
status: 'loaded';
|
|
19
18
|
client: LoomClient;
|
|
19
|
+
status: 'loaded';
|
|
20
20
|
} | {
|
|
21
|
-
status: 'error';
|
|
22
21
|
message: LoomPluginErrorMessages | LoomSDKErrorMessages;
|
|
22
|
+
status: 'error';
|
|
23
23
|
};
|
|
24
24
|
export type GetClient = Promise<GetClientResult>;
|
|
25
25
|
export type LoomProviderOptions = {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { LoomPlugin } from '../loomPluginType';
|
|
3
|
+
import type { LoomPluginOptions } from '../types';
|
|
4
|
+
export declare const LoomMenuItem: ({ api, renderButton, }: {
|
|
5
|
+
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
6
|
+
} & Pick<LoomPluginOptions, "renderButton">) => JSX.Element | null | undefined;
|
|
@@ -8,11 +8,11 @@ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-com
|
|
|
8
8
|
import type { LoomPlugin } from '../loomPluginType';
|
|
9
9
|
import { type ButtonComponentProps } from '../types';
|
|
10
10
|
interface Props extends Omit<ButtonComponentProps, 'onClickBeforeInit'> {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
appearance: EditorAppearance;
|
|
13
11
|
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
14
|
-
|
|
12
|
+
appearance: EditorAppearance;
|
|
13
|
+
disabled: boolean;
|
|
15
14
|
hideTooltip?: boolean;
|
|
15
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
16
16
|
}
|
|
17
17
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("react-intl-next").WithIntlProps<React.PropsWithChildren<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>>, "ref"> & React.RefAttributes<any>> & {
|
|
18
18
|
WrappedComponent: React.ComponentType<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { LoomPlugin } from '../loomPluginType';
|
|
4
|
+
import type { LoomPluginOptions } from '../types';
|
|
5
|
+
export declare const getToolbarComponents: (config: LoomPluginOptions, api: ExtractInjectionAPI<LoomPlugin> | undefined) => RegisterComponent[];
|
|
@@ -6,33 +6,12 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import type { HyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
8
|
import { type QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
|
|
9
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
9
10
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
10
11
|
import type { LoomPluginState } from './pm-plugins/main';
|
|
11
12
|
import type { LoomPluginOptions, LoomProviderOptions, PositionType, VideoMeta } from './types';
|
|
12
13
|
export type LoomPlugin = NextEditorPlugin<'loom', {
|
|
13
|
-
pluginConfiguration: LoomPluginOptions;
|
|
14
|
-
dependencies: [
|
|
15
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
16
|
-
WidthPlugin,
|
|
17
|
-
HyperlinkPlugin,
|
|
18
|
-
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
19
|
-
OptionalPlugin<QuickInsertPlugin>,
|
|
20
|
-
OptionalPlugin<ConnectivityPlugin>
|
|
21
|
-
];
|
|
22
|
-
sharedState: LoomPluginState | undefined;
|
|
23
14
|
actions: {
|
|
24
|
-
recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
25
|
-
inputMethod: INPUT_METHOD;
|
|
26
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
27
|
-
}) => EditorCommand;
|
|
28
|
-
/**
|
|
29
|
-
* Insert loom into the document.
|
|
30
|
-
*
|
|
31
|
-
* @param video Video metadata (`sharedUrl` and `title`)
|
|
32
|
-
* @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
|
|
33
|
-
* @returns {boolean} If the loom was successfully inserted
|
|
34
|
-
*/
|
|
35
|
-
insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
|
|
36
15
|
/**
|
|
37
16
|
* Given loom provider, initialise loom SDK
|
|
38
17
|
* @returns error message if initialisation failed
|
|
@@ -42,5 +21,28 @@ export type LoomPlugin = NextEditorPlugin<'loom', {
|
|
|
42
21
|
}) => Promise<{
|
|
43
22
|
error?: string;
|
|
44
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Insert loom into the document.
|
|
26
|
+
*
|
|
27
|
+
* @param video Video metadata (`sharedUrl` and `title`)
|
|
28
|
+
* @param positionType {'start' | 'end' | 'current'} Where you want to insert the loom
|
|
29
|
+
* @returns {boolean} If the loom was successfully inserted
|
|
30
|
+
*/
|
|
31
|
+
insertLoom: (video: VideoMeta, positionType: PositionType) => boolean;
|
|
32
|
+
recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
33
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
34
|
+
inputMethod: INPUT_METHOD;
|
|
35
|
+
}) => EditorCommand;
|
|
45
36
|
};
|
|
37
|
+
dependencies: [
|
|
38
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
39
|
+
WidthPlugin,
|
|
40
|
+
HyperlinkPlugin,
|
|
41
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
42
|
+
OptionalPlugin<QuickInsertPlugin>,
|
|
43
|
+
OptionalPlugin<ConnectivityPlugin>,
|
|
44
|
+
OptionalPlugin<ToolbarPlugin>
|
|
45
|
+
];
|
|
46
|
+
pluginConfiguration: LoomPluginOptions;
|
|
47
|
+
sharedState: LoomPluginState | undefined;
|
|
46
48
|
}>;
|
|
@@ -16,13 +16,13 @@ export declare const disableLoom: ({ error }: {
|
|
|
16
16
|
error: string;
|
|
17
17
|
}) => EditorCommand;
|
|
18
18
|
export declare const recordVideo: ({ inputMethod, editorAnalyticsAPI, }: {
|
|
19
|
-
inputMethod: INPUT_METHOD;
|
|
20
19
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
20
|
+
inputMethod: INPUT_METHOD;
|
|
21
21
|
}) => EditorCommand;
|
|
22
22
|
export declare const recordVideoFailed: ({ inputMethod, error, editorAnalyticsAPI, }: {
|
|
23
|
-
inputMethod: INPUT_METHOD;
|
|
24
|
-
error: SDKUnsupportedReasons | undefined;
|
|
25
23
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
24
|
+
error: SDKUnsupportedReasons | undefined;
|
|
25
|
+
inputMethod: INPUT_METHOD;
|
|
26
26
|
}) => EditorCommand;
|
|
27
27
|
export declare const insertVideo: ({ editorAnalyticsAPI, video, }: {
|
|
28
28
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
@@ -9,10 +9,10 @@ declare enum SDKUnsupportedReasons {
|
|
|
9
9
|
NoMediaStreamsSupport = "no-media-streams-support"
|
|
10
10
|
}
|
|
11
11
|
export interface LoomPluginState {
|
|
12
|
+
error: SDKUnsupportedReasons | undefined;
|
|
12
13
|
isEnabled: boolean;
|
|
13
|
-
loomButton: HTMLButtonElement | null;
|
|
14
14
|
isRecordingVideo: boolean;
|
|
15
|
-
|
|
15
|
+
loomButton: HTMLButtonElement | null;
|
|
16
16
|
}
|
|
17
17
|
export declare enum LoomPluginAction {
|
|
18
18
|
ENABLE = 0,
|
|
@@ -22,7 +22,7 @@ export declare enum LoomPluginAction {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const loomPluginKey: PluginKey<LoomPluginState>;
|
|
24
24
|
export declare const createPlugin: ({ config, api, }: {
|
|
25
|
-
config: LoomPluginOptions;
|
|
26
25
|
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
26
|
+
config: LoomPluginOptions;
|
|
27
27
|
}) => SafePlugin<LoomPluginState>;
|
|
28
28
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { type ButtonProps as AKButtonProps } from '@atlaskit/button';
|
|
3
3
|
export type VideoMeta = {
|
|
4
|
+
duration?: number;
|
|
4
5
|
sharedUrl: string;
|
|
5
6
|
title: string;
|
|
6
|
-
duration?: number;
|
|
7
7
|
};
|
|
8
8
|
type LoomClient = {
|
|
9
9
|
attachToButton: (options: {
|
|
@@ -15,11 +15,11 @@ export type PositionType = 'start' | 'end' | 'current';
|
|
|
15
15
|
export type LoomPluginErrorMessages = 'is-supported-failure' | 'failed-to-initialise' | 'api-key-not-provided';
|
|
16
16
|
export type LoomSDKErrorMessages = 'incompatible-browser' | 'third-party-cookies-disabled' | 'no-media-streams-support';
|
|
17
17
|
export type GetClientResult = {
|
|
18
|
-
status: 'loaded';
|
|
19
18
|
client: LoomClient;
|
|
19
|
+
status: 'loaded';
|
|
20
20
|
} | {
|
|
21
|
-
status: 'error';
|
|
22
21
|
message: LoomPluginErrorMessages | LoomSDKErrorMessages;
|
|
22
|
+
status: 'error';
|
|
23
23
|
};
|
|
24
24
|
export type GetClient = Promise<GetClientResult>;
|
|
25
25
|
export type LoomProviderOptions = {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { LoomPlugin } from '../loomPluginType';
|
|
3
|
+
import type { LoomPluginOptions } from '../types';
|
|
4
|
+
export declare const LoomMenuItem: ({ api, renderButton, }: {
|
|
5
|
+
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
6
|
+
} & Pick<LoomPluginOptions, "renderButton">) => JSX.Element | null | undefined;
|
|
@@ -8,11 +8,11 @@ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-com
|
|
|
8
8
|
import type { LoomPlugin } from '../loomPluginType';
|
|
9
9
|
import { type ButtonComponentProps } from '../types';
|
|
10
10
|
interface Props extends Omit<ButtonComponentProps, 'onClickBeforeInit'> {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
appearance: EditorAppearance;
|
|
13
11
|
api: ExtractInjectionAPI<LoomPlugin> | undefined;
|
|
14
|
-
|
|
12
|
+
appearance: EditorAppearance;
|
|
13
|
+
disabled: boolean;
|
|
15
14
|
hideTooltip?: boolean;
|
|
15
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => void;
|
|
16
16
|
}
|
|
17
17
|
declare const _default: React.ForwardRefExoticComponent<Omit<import("react-intl-next").WithIntlProps<React.PropsWithChildren<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>>, "ref"> & React.RefAttributes<any>> & {
|
|
18
18
|
WrappedComponent: React.ComponentType<Props & WrappedComponentProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { LoomPlugin } from '../loomPluginType';
|
|
4
|
+
import type { LoomPluginOptions } from '../types';
|
|
5
|
+
export declare const getToolbarComponents: (config: LoomPluginOptions, api: ExtractInjectionAPI<LoomPlugin> | undefined) => RegisterComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-loom",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.4",
|
|
4
4
|
"description": "Loom plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,38 +31,38 @@
|
|
|
31
31
|
"*.compiled.css"
|
|
32
32
|
],
|
|
33
33
|
"atlaskit:src": "src/index.ts",
|
|
34
|
-
"af:exports": {
|
|
35
|
-
".": "./src/index.ts"
|
|
36
|
-
},
|
|
37
34
|
"dependencies": {
|
|
38
35
|
"@atlaskit/button": "^23.4.0",
|
|
39
36
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
40
37
|
"@atlaskit/editor-plugin-hyperlink": "^5.4.0",
|
|
41
38
|
"@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
|
|
42
39
|
"@atlaskit/editor-plugin-quick-insert": "^3.0.0",
|
|
40
|
+
"@atlaskit/editor-plugin-toolbar": "^0.4.0",
|
|
43
41
|
"@atlaskit/editor-plugin-width": "^4.0.0",
|
|
44
42
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
|
-
"@atlaskit/
|
|
43
|
+
"@atlaskit/editor-toolbar": "^0.5.0",
|
|
44
|
+
"@atlaskit/icon": "^28.1.0",
|
|
46
45
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
|
-
"@atlaskit/
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^11.9.0",
|
|
47
|
+
"@atlaskit/tokens": "^6.1.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
49
|
"@emotion/react": "^11.7.1",
|
|
50
50
|
"@loomhq/record-sdk": "^2.36.18"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^107.
|
|
53
|
+
"@atlaskit/editor-common": "^107.33.0",
|
|
54
54
|
"react": "^18.2.0",
|
|
55
55
|
"react-dom": "^18.2.0",
|
|
56
56
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@atlaskit/editor-plugin-base": "^4.1.0",
|
|
60
|
-
"@atlaskit/editor-plugin-card": "^7.
|
|
60
|
+
"@atlaskit/editor-plugin-card": "^7.6.0",
|
|
61
61
|
"@atlaskit/editor-plugin-copy-button": "^3.0.0",
|
|
62
|
-
"@atlaskit/editor-plugin-decorations": "^3.
|
|
62
|
+
"@atlaskit/editor-plugin-decorations": "^3.1.0",
|
|
63
63
|
"@atlaskit/editor-plugin-editor-disabled": "^3.0.0",
|
|
64
64
|
"@atlaskit/editor-plugin-feature-flags": "^2.0.0",
|
|
65
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^5.
|
|
65
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^5.2.0",
|
|
66
66
|
"@atlaskit/editor-plugin-grid": "^3.1.0",
|
|
67
67
|
"@testing-library/react": "^13.4.0",
|
|
68
68
|
"@testing-library/user-event": "^14.4.3",
|