@atlaskit/editor-plugin-avatar-group 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +33 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/messages.js +14 -0
- package/dist/cjs/plugin.js +58 -0
- package/dist/cjs/ui/AvatarGroupPluginWrapper.js +52 -0
- package/dist/cjs/ui/avatars-with-plugin-state.js +42 -0
- package/dist/cjs/ui/avatars.js +73 -0
- package/dist/cjs/ui/colored-avatar-item.js +23 -0
- package/dist/cjs/ui/index.js +16 -0
- package/dist/cjs/ui/invite-to-edit.js +48 -0
- package/dist/cjs/ui/styles.js +17 -0
- package/dist/cjs/ui/to-avatar.js +30 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/messages.js +8 -0
- package/dist/es2019/plugin.js +54 -0
- package/dist/es2019/ui/AvatarGroupPluginWrapper.js +57 -0
- package/dist/es2019/ui/avatars-with-plugin-state.js +38 -0
- package/dist/es2019/ui/avatars.js +66 -0
- package/dist/es2019/ui/colored-avatar-item.js +16 -0
- package/dist/es2019/ui/index.js +3 -0
- package/dist/es2019/ui/invite-to-edit.js +35 -0
- package/dist/es2019/ui/styles.js +46 -0
- package/dist/es2019/ui/to-avatar.js +16 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/messages.js +8 -0
- package/dist/esm/plugin.js +51 -0
- package/dist/esm/ui/AvatarGroupPluginWrapper.js +46 -0
- package/dist/esm/ui/avatars-with-plugin-state.js +35 -0
- package/dist/esm/ui/avatars.js +66 -0
- package/dist/esm/ui/colored-avatar-item.js +16 -0
- package/dist/esm/ui/index.js +3 -0
- package/dist/esm/ui/invite-to-edit.js +37 -0
- package/dist/esm/ui/styles.js +10 -0
- package/dist/esm/ui/to-avatar.js +23 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/messages.d.ts +7 -0
- package/dist/types/plugin.d.ts +27 -0
- package/dist/types/ui/AvatarGroupPluginWrapper.d.ts +18 -0
- package/dist/types/ui/avatars-with-plugin-state.d.ts +80 -0
- package/dist/types/ui/avatars.d.ts +20 -0
- package/dist/types/ui/colored-avatar-item.d.ts +10 -0
- package/dist/types/ui/index.d.ts +3 -0
- package/dist/types/ui/invite-to-edit.d.ts +10 -0
- package/dist/types/ui/styles.d.ts +3 -0
- package/dist/types/ui/to-avatar.d.ts +30 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/messages.d.ts +7 -0
- package/dist/types-ts4.5/plugin.d.ts +27 -0
- package/dist/types-ts4.5/ui/AvatarGroupPluginWrapper.d.ts +18 -0
- package/dist/types-ts4.5/ui/avatars-with-plugin-state.d.ts +96 -0
- package/dist/types-ts4.5/ui/avatars.d.ts +22 -0
- package/dist/types-ts4.5/ui/colored-avatar-item.d.ts +12 -0
- package/dist/types-ts4.5/ui/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/invite-to-edit.d.ts +10 -0
- package/dist/types-ts4.5/ui/styles.d.ts +3 -0
- package/dist/types-ts4.5/ui/to-avatar.d.ts +37 -0
- package/package.json +110 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-avatar-group
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Editor plugin avatar group
|
|
2
|
+
|
|
3
|
+
Avatar Group plugin for @atlaskit/editor-core
|
|
4
|
+
|
|
5
|
+
The avatar-group plugin is just a placeholder for the AvatarsWithPluginState component so that it is properly integrated into the toolbar.
|
|
6
|
+
The avatar-group plugin itself doesn't do anything so all the pm-plugin related code has been removed.
|
|
7
|
+
|
|
8
|
+
**Note:** This component is designed for internal Atlassian development.
|
|
9
|
+
External contributors will be able to use this component but will not be able to submit issues.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
---
|
|
13
|
+
- **Install** - *yarn add @atlaskit/editor-plugin-avatar-group*
|
|
14
|
+
- **npm** - [@atlaskit/editor-plugin-avatar-group](https://www.npmjs.com/package/@atlaskit/editor-plugin-avatar-group)
|
|
15
|
+
- **Source** - [Bitbucket](https://bitbucket.org/atlassian/atlassian-frontend/src/master/packages/editor/editor-plugin-avatar-group)
|
|
16
|
+
- **Bundle** - [unpkg.com](https://unpkg.com/@atlaskit/editor-plugin-avatar-group/dist/)
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
---
|
|
20
|
+
**Internal use only**
|
|
21
|
+
|
|
22
|
+
@atlaskit/editor-plugin-avatar-group is intended for internal use by the @atlaskit/editor-core and as a plugin dependency of the Editor within your product.
|
|
23
|
+
|
|
24
|
+
Direct use of this component is not supported.
|
|
25
|
+
|
|
26
|
+
Please see [Atlaskit - Editor plugin avatar group](https://atlaskit.atlassian.com/packages/editor/editor-plugin-avatar-group) for documentation and examples for this package.
|
|
27
|
+
|
|
28
|
+
## Support
|
|
29
|
+
---
|
|
30
|
+
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
31
|
+
## License
|
|
32
|
+
---
|
|
33
|
+
Please see [Atlassian Frontend - License](https://developer.atlassian.com/cloud/framework/atlassian-frontend/#license) for more licensing information.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "avatarGroupPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _plugin.avatarGroupPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _plugin = require("./plugin");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.avatarGroupMessages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var avatarGroupMessages = exports.avatarGroupMessages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
editors: {
|
|
10
|
+
id: 'fabric.editor.editors',
|
|
11
|
+
defaultMessage: 'Editors',
|
|
12
|
+
description: 'classifying the people that are currently editing the document'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.avatarGroupPlugin = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _AvatarGroupPluginWrapper = _interopRequireDefault(require("./ui/AvatarGroupPluginWrapper"));
|
|
10
|
+
var _avatarsWithPluginState = _interopRequireDefault(require("./ui/avatars-with-plugin-state"));
|
|
11
|
+
var avatarGroupPlugin = exports.avatarGroupPlugin = function avatarGroupPlugin(_ref) {
|
|
12
|
+
var _api$featureFlags;
|
|
13
|
+
var props = _ref.config,
|
|
14
|
+
api = _ref.api;
|
|
15
|
+
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
16
|
+
return {
|
|
17
|
+
name: 'avatarGroup',
|
|
18
|
+
primaryToolbarComponent: props.showAvatarGroup ? function (_ref2) {
|
|
19
|
+
var _api$analytics;
|
|
20
|
+
var editorView = _ref2.editorView,
|
|
21
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
22
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
23
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
24
|
+
disabled = _ref2.disabled,
|
|
25
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
26
|
+
eventDispatcher = _ref2.eventDispatcher,
|
|
27
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_AvatarGroupPluginWrapper.default, {
|
|
29
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
30
|
+
editorView: editorView,
|
|
31
|
+
eventDispatcher: eventDispatcher,
|
|
32
|
+
collabEdit: props === null || props === void 0 ? void 0 : props.collabEdit,
|
|
33
|
+
takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
|
|
34
|
+
featureFlags: featureFlags,
|
|
35
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
36
|
+
editorAPI: api
|
|
37
|
+
});
|
|
38
|
+
} : undefined,
|
|
39
|
+
actions: {
|
|
40
|
+
getToolbarItem: function getToolbarItem(_ref3) {
|
|
41
|
+
var _api$featureFlags$sha, _api$featureFlags2, _api$analytics2;
|
|
42
|
+
var editorView = _ref3.editorView,
|
|
43
|
+
inviteToEditHandler = _ref3.inviteToEditHandler,
|
|
44
|
+
isInviteToEditButtonSelected = _ref3.isInviteToEditButtonSelected,
|
|
45
|
+
inviteToEditComponent = _ref3.inviteToEditComponent;
|
|
46
|
+
return /*#__PURE__*/_react.default.createElement(_avatarsWithPluginState.default, {
|
|
47
|
+
editorView: editorView,
|
|
48
|
+
featureFlags: (_api$featureFlags$sha = api === null || api === void 0 || (_api$featureFlags2 = api.featureFlags) === null || _api$featureFlags2 === void 0 ? void 0 : _api$featureFlags2.sharedState.currentState()) !== null && _api$featureFlags$sha !== void 0 ? _api$featureFlags$sha : {},
|
|
49
|
+
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
50
|
+
editorAPI: api,
|
|
51
|
+
inviteToEditHandler: inviteToEditHandler,
|
|
52
|
+
isInviteToEditButtonSelected: isInviteToEditButtonSelected,
|
|
53
|
+
inviteToEditComponent: inviteToEditComponent
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _reactIntlNext = require("react-intl-next");
|
|
12
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _messages = require("../messages");
|
|
14
|
+
var _avatarsWithPluginState = _interopRequireDefault(require("./avatars-with-plugin-state"));
|
|
15
|
+
var _templateObject, _templateObject2;
|
|
16
|
+
/** @jsx jsx */
|
|
17
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
18
|
+
var toolbarButtonWrapper = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n justify-content: flex-end;\n flex-grow: 0;\n align-items: center;\n & > div {\n margin-right: 0;\n }\n"])));
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
21
|
+
var toolbarButtonWrapperFullWidth = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n flex-grow: 1;\n"])), toolbarButtonWrapper);
|
|
22
|
+
var AvatarGroupPluginWrapper = function AvatarGroupPluginWrapper(props) {
|
|
23
|
+
var dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
|
|
24
|
+
featureFlags = props.featureFlags;
|
|
25
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
26
|
+
(0, _react.useEffect)(function () {
|
|
27
|
+
if (!dispatchAnalyticsEvent) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
dispatchAnalyticsEvent({
|
|
31
|
+
action: _analytics.ACTION.VIEWED,
|
|
32
|
+
actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
|
|
33
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.AVATAR_GROUP_PLUGIN,
|
|
34
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
35
|
+
});
|
|
36
|
+
}, [dispatchAnalyticsEvent]);
|
|
37
|
+
return (0, _react2.jsx)("div", {
|
|
38
|
+
"aria-label": intl.formatMessage(_messages.avatarGroupMessages.editors),
|
|
39
|
+
"data-testid": 'avatar-group-in-plugin',
|
|
40
|
+
css: props.takeFullWidth ? toolbarButtonWrapperFullWidth : toolbarButtonWrapper
|
|
41
|
+
}, (0, _react2.jsx)(_avatarsWithPluginState.default, {
|
|
42
|
+
editorView: props.editorView,
|
|
43
|
+
eventDispatcher: props.eventDispatcher,
|
|
44
|
+
inviteToEditComponent: props.collabEdit && props.collabEdit.inviteToEditComponent,
|
|
45
|
+
inviteToEditHandler: props.collabEdit && props.collabEdit.inviteToEditHandler,
|
|
46
|
+
isInviteToEditButtonSelected: props.collabEdit && props.collabEdit.isInviteToEditButtonSelected,
|
|
47
|
+
featureFlags: featureFlags,
|
|
48
|
+
editorAnalyticsAPI: props.editorAnalyticsAPI,
|
|
49
|
+
editorAPI: props.editorAPI
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
var _default = exports.default = AvatarGroupPluginWrapper;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
|
|
12
|
+
var _avatars = require("./avatars");
|
|
13
|
+
var _inviteToEdit = require("./invite-to-edit");
|
|
14
|
+
var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
|
|
15
|
+
var title = props.intl.formatMessage(_messages.default.inviteToEditButtonTitle);
|
|
16
|
+
var selected = props.isInviteToEditButtonSelected,
|
|
17
|
+
onClick = props.inviteToEditHandler,
|
|
18
|
+
Component = props.inviteToEditComponent,
|
|
19
|
+
editorView = props.editorView,
|
|
20
|
+
featureFlags = props.featureFlags,
|
|
21
|
+
editorAnalyticsAPI = props.editorAnalyticsAPI,
|
|
22
|
+
editorAPI = props.editorAPI;
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(editorAPI, ['collabEdit']),
|
|
24
|
+
collabEditState = _useSharedPluginState.collabEditState;
|
|
25
|
+
if (!collabEditState) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_avatars.Avatars, {
|
|
29
|
+
sessionId: collabEditState.sessionId,
|
|
30
|
+
participants: collabEditState.activeParticipants,
|
|
31
|
+
editorView: editorView,
|
|
32
|
+
featureFlags: featureFlags,
|
|
33
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
34
|
+
editorAPI: editorAPI
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_inviteToEdit.InviteToEditButton, {
|
|
36
|
+
title: title,
|
|
37
|
+
selected: selected,
|
|
38
|
+
onClick: onClick,
|
|
39
|
+
Component: Component
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
var _default = exports.default = (0, _reactIntlNext.injectIntl)(AvatarsWithPluginState);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.scrollToCollabCursor = exports.Avatars = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
10
|
+
var _avatarGroup = _interopRequireDefault(require("@atlaskit/avatar-group"));
|
|
11
|
+
var _analytics2 = require("@atlaskit/editor-common/analytics");
|
|
12
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _styles = require("./styles");
|
|
14
|
+
var _toAvatar = _interopRequireDefault(require("./to-avatar"));
|
|
15
|
+
/** @jsx jsx */
|
|
16
|
+
|
|
17
|
+
var scrollToCollabCursor = exports.scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI) {
|
|
18
|
+
var selectedUser = participants[index];
|
|
19
|
+
if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
|
|
20
|
+
var state = editorView.state;
|
|
21
|
+
var tr = state.tr;
|
|
22
|
+
var analyticsPayload = {
|
|
23
|
+
action: _analytics2.ACTION.MATCHED,
|
|
24
|
+
actionSubject: _analytics2.ACTION_SUBJECT.SELECTION,
|
|
25
|
+
eventType: _analytics2.EVENT_TYPE.TRACK
|
|
26
|
+
};
|
|
27
|
+
tr.setSelection(_state.Selection.near(tr.doc.resolve(selectedUser.cursorPos)));
|
|
28
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(analyticsPayload)(tr);
|
|
29
|
+
tr.scrollIntoView();
|
|
30
|
+
editorView.dispatch(tr);
|
|
31
|
+
if (!editorView.hasFocus()) {
|
|
32
|
+
editorView.focus();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var Avatars = exports.Avatars = /*#__PURE__*/_react.default.memo(function (props) {
|
|
37
|
+
var _props$participants;
|
|
38
|
+
var sessionId = props.sessionId,
|
|
39
|
+
editorView = props.editorView,
|
|
40
|
+
featureFlags = props.featureFlags,
|
|
41
|
+
editorAPI = props.editorAPI;
|
|
42
|
+
var participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
|
|
43
|
+
var avatars = participants.sort(function (p) {
|
|
44
|
+
return p.sessionId === sessionId ? -1 : 1;
|
|
45
|
+
}).map(function (participant) {
|
|
46
|
+
return (0, _toAvatar.default)(participant, editorAPI);
|
|
47
|
+
});
|
|
48
|
+
if (!avatars.length) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return (
|
|
52
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
53
|
+
(0, _react2.jsx)("div", {
|
|
54
|
+
css: _styles.avatarContainer
|
|
55
|
+
}, (0, _react2.jsx)(_avatarGroup.default, {
|
|
56
|
+
appearance: "stack",
|
|
57
|
+
size: "medium",
|
|
58
|
+
data: avatars,
|
|
59
|
+
maxCount: 3,
|
|
60
|
+
onAvatarClick: function onAvatarClick(_event, _analytics, index) {
|
|
61
|
+
if (!editorView) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var allowCollabAvatarScroll = featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.collabAvatarScroll;
|
|
65
|
+
|
|
66
|
+
// user does not need to scroll to their own position (index 0)
|
|
67
|
+
if (allowCollabAvatarScroll && index > 0) {
|
|
68
|
+
scrollToCollabCursor(editorView, participants, props.sessionId, index, props.editorAnalyticsAPI);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}), props.children)
|
|
72
|
+
);
|
|
73
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ColoredAvatarItem = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
9
|
+
var _styles = require("./styles");
|
|
10
|
+
/** @jsx jsx */
|
|
11
|
+
|
|
12
|
+
var ColoredAvatarItem = exports.ColoredAvatarItem = function ColoredAvatarItem(props) {
|
|
13
|
+
var _props$api;
|
|
14
|
+
var color = (_props$api = props.api) === null || _props$api === void 0 || (_props$api = _props$api.collabEdit) === null || _props$api === void 0 || (_props$api = _props$api.actions) === null || _props$api === void 0 ? void 0 : _props$api.getAvatarColor(props.sessionId).color.solid;
|
|
15
|
+
var avatar = props.name.substr(0, 1).toUpperCase();
|
|
16
|
+
return (
|
|
17
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
18
|
+
(0, _react.jsx)("div", {
|
|
19
|
+
css: (0, _styles.badge)(color || _colors.R100),
|
|
20
|
+
"data-testid": "editor-collab-badge"
|
|
21
|
+
}, avatar)
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "AvatarGroupPluginWrapper", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _AvatarGroupPluginWrapper.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.default = void 0;
|
|
14
|
+
var _avatarsWithPluginState = _interopRequireDefault(require("./avatars-with-plugin-state"));
|
|
15
|
+
var _AvatarGroupPluginWrapper = _interopRequireDefault(require("./AvatarGroupPluginWrapper"));
|
|
16
|
+
var _default = exports.default = _avatarsWithPluginState.default;
|
|
@@ -0,0 +1,48 @@
|
|
|
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.InviteToEditButton = void 0;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
11
|
+
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
12
|
+
var _add = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/add"));
|
|
13
|
+
var _styles = require("./styles");
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
/** @jsx jsx */
|
|
17
|
+
|
|
18
|
+
var ID = function ID(props) {
|
|
19
|
+
return (0, _react2.jsx)(_react.Fragment, null, props.children);
|
|
20
|
+
};
|
|
21
|
+
var InviteToEditButton = exports.InviteToEditButton = function InviteToEditButton(props) {
|
|
22
|
+
var Component = props.Component,
|
|
23
|
+
onClick = props.onClick,
|
|
24
|
+
selected = props.selected,
|
|
25
|
+
title = props.title;
|
|
26
|
+
var iconBefore = _react.default.useMemo(function () {
|
|
27
|
+
return (0, _react2.jsx)(_add.default, {
|
|
28
|
+
label: title
|
|
29
|
+
});
|
|
30
|
+
}, [title]);
|
|
31
|
+
if (!Component && !onClick) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var Wrapper = Component ? Component : ID;
|
|
35
|
+
return (
|
|
36
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
37
|
+
(0, _react2.jsx)("div", {
|
|
38
|
+
css: _styles.inviteTeamWrapper
|
|
39
|
+
}, (0, _react2.jsx)(Wrapper, null, (0, _react2.jsx)(_uiMenu.ToolbarButton, {
|
|
40
|
+
className: "invite-to-edit",
|
|
41
|
+
onClick: onClick,
|
|
42
|
+
selected: selected,
|
|
43
|
+
title: title,
|
|
44
|
+
titlePosition: "bottom",
|
|
45
|
+
iconBefore: iconBefore
|
|
46
|
+
})))
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.inviteTeamWrapper = exports.badge = exports.avatarContainer = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _react = require("@emotion/react");
|
|
10
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
13
|
+
var inviteTeamWrapper = exports.inviteTeamWrapper = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n border-radius: 50%;\n min-width: ", ";\n margin-left: ", ";\n"])), "var(--ds-background-neutral, ".concat(_colors.N20, ")"), "var(--ds-space-400, 32px)", "var(--ds-space-negative-050, -4px)");
|
|
14
|
+
var avatarContainer = exports.avatarContainer = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-right: ", ";\n display: flex;\n align-items: center;\n\n // ED-13102: This is to override list styles that come from the\n // .wiki-content class in Confluence that should not apply within\n // the toolbar. Has to be extra specific to override.\n && > ul {\n list-style-type: none;\n }\n\n div:last-child button.invite-to-edit {\n border-radius: 50%;\n height: 32px;\n width: 32px;\n padding: ", ";\n }\n"])), "var(--ds-space-100, 8px)", "var(--ds-space-025, 2px)");
|
|
15
|
+
var badge = exports.badge = function badge(color) {
|
|
16
|
+
return (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n position: absolute;\n right: 1px;\n bottom: 1px;\n width: 13px;\n height: 13px;\n z-index: ", ";\n border-radius: 3px;\n background: ", ";\n color: ", ";\n font-size: ", ";\n line-height: 0;\n padding-top: 7px;\n text-align: center;\n box-shadow: 0 0 1px ", ";\n box-sizing: border-box;\n"])), _editorSharedStyles.akEditorSmallZIndex, color, "var(--ds-text-inverse, #fff)", (0, _editorSharedStyles.relativeFontSizeToBase16)(9), "var(--ds-border-inverse, #fff)");
|
|
17
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
11
|
+
var _coloredAvatarItem = require("./colored-avatar-item");
|
|
12
|
+
var toAvatar = function toAvatar(participant, api) {
|
|
13
|
+
return {
|
|
14
|
+
name: participant.name,
|
|
15
|
+
src: participant.avatar,
|
|
16
|
+
size: 'medium',
|
|
17
|
+
presence: /*#__PURE__*/_react.default.createElement(_coloredAvatarItem.ColoredAvatarItem, {
|
|
18
|
+
api: api,
|
|
19
|
+
name: participant.name,
|
|
20
|
+
sessionId: participant.sessionId
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var _default = exports.default = (0, _memoizeOne.default)(toAvatar, function participantEquals(_ref, _ref2) {
|
|
25
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref, 1),
|
|
26
|
+
a = _ref3[0];
|
|
27
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref2, 1),
|
|
28
|
+
b = _ref4[0];
|
|
29
|
+
return a.name === b.name && a.avatar === b.avatar && a.sessionId === b.sessionId;
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { avatarGroupPlugin } from './plugin';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const avatarGroupMessages = defineMessages({
|
|
3
|
+
editors: {
|
|
4
|
+
id: 'fabric.editor.editors',
|
|
5
|
+
defaultMessage: 'Editors',
|
|
6
|
+
description: 'classifying the people that are currently editing the document'
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import AvatarGroupPluginWrapper from './ui/AvatarGroupPluginWrapper';
|
|
3
|
+
import AvatarsWithPluginState from './ui/avatars-with-plugin-state';
|
|
4
|
+
export const avatarGroupPlugin = ({
|
|
5
|
+
config: props,
|
|
6
|
+
api
|
|
7
|
+
}) => {
|
|
8
|
+
var _api$featureFlags;
|
|
9
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
10
|
+
return {
|
|
11
|
+
name: 'avatarGroup',
|
|
12
|
+
primaryToolbarComponent: props.showAvatarGroup ? ({
|
|
13
|
+
editorView,
|
|
14
|
+
popupsMountPoint,
|
|
15
|
+
popupsBoundariesElement,
|
|
16
|
+
popupsScrollableElement,
|
|
17
|
+
disabled,
|
|
18
|
+
isToolbarReducedSpacing,
|
|
19
|
+
eventDispatcher,
|
|
20
|
+
dispatchAnalyticsEvent
|
|
21
|
+
}) => {
|
|
22
|
+
var _api$analytics;
|
|
23
|
+
return /*#__PURE__*/React.createElement(AvatarGroupPluginWrapper, {
|
|
24
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
25
|
+
editorView: editorView,
|
|
26
|
+
eventDispatcher: eventDispatcher,
|
|
27
|
+
collabEdit: props === null || props === void 0 ? void 0 : props.collabEdit,
|
|
28
|
+
takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
|
|
29
|
+
featureFlags: featureFlags,
|
|
30
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
31
|
+
editorAPI: api
|
|
32
|
+
});
|
|
33
|
+
} : undefined,
|
|
34
|
+
actions: {
|
|
35
|
+
getToolbarItem: ({
|
|
36
|
+
editorView,
|
|
37
|
+
inviteToEditHandler,
|
|
38
|
+
isInviteToEditButtonSelected,
|
|
39
|
+
inviteToEditComponent
|
|
40
|
+
}) => {
|
|
41
|
+
var _api$featureFlags$sha, _api$featureFlags2, _api$analytics2;
|
|
42
|
+
return /*#__PURE__*/React.createElement(AvatarsWithPluginState, {
|
|
43
|
+
editorView: editorView,
|
|
44
|
+
featureFlags: (_api$featureFlags$sha = api === null || api === void 0 ? void 0 : (_api$featureFlags2 = api.featureFlags) === null || _api$featureFlags2 === void 0 ? void 0 : _api$featureFlags2.sharedState.currentState()) !== null && _api$featureFlags$sha !== void 0 ? _api$featureFlags$sha : {},
|
|
45
|
+
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions,
|
|
46
|
+
editorAPI: api,
|
|
47
|
+
inviteToEditHandler: inviteToEditHandler,
|
|
48
|
+
isInviteToEditButtonSelected: isInviteToEditButtonSelected,
|
|
49
|
+
inviteToEditComponent: inviteToEditComponent
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { useIntl } from 'react-intl-next';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { avatarGroupMessages } from '../messages';
|
|
7
|
+
import AvatarsWithPluginState from './avatars-with-plugin-state';
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
10
|
+
const toolbarButtonWrapper = css`
|
|
11
|
+
display: flex;
|
|
12
|
+
justify-content: flex-end;
|
|
13
|
+
flex-grow: 0;
|
|
14
|
+
align-items: center;
|
|
15
|
+
& > div {
|
|
16
|
+
margin-right: 0;
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
21
|
+
const toolbarButtonWrapperFullWidth = css`
|
|
22
|
+
${toolbarButtonWrapper}
|
|
23
|
+
flex-grow: 1;
|
|
24
|
+
`;
|
|
25
|
+
const AvatarGroupPluginWrapper = props => {
|
|
26
|
+
const {
|
|
27
|
+
dispatchAnalyticsEvent,
|
|
28
|
+
featureFlags
|
|
29
|
+
} = props;
|
|
30
|
+
const intl = useIntl();
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!dispatchAnalyticsEvent) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
dispatchAnalyticsEvent({
|
|
36
|
+
action: ACTION.VIEWED,
|
|
37
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
38
|
+
actionSubjectId: ACTION_SUBJECT_ID.AVATAR_GROUP_PLUGIN,
|
|
39
|
+
eventType: EVENT_TYPE.UI
|
|
40
|
+
});
|
|
41
|
+
}, [dispatchAnalyticsEvent]);
|
|
42
|
+
return jsx("div", {
|
|
43
|
+
"aria-label": intl.formatMessage(avatarGroupMessages.editors),
|
|
44
|
+
"data-testid": 'avatar-group-in-plugin',
|
|
45
|
+
css: props.takeFullWidth ? toolbarButtonWrapperFullWidth : toolbarButtonWrapper
|
|
46
|
+
}, jsx(AvatarsWithPluginState, {
|
|
47
|
+
editorView: props.editorView,
|
|
48
|
+
eventDispatcher: props.eventDispatcher,
|
|
49
|
+
inviteToEditComponent: props.collabEdit && props.collabEdit.inviteToEditComponent,
|
|
50
|
+
inviteToEditHandler: props.collabEdit && props.collabEdit.inviteToEditHandler,
|
|
51
|
+
isInviteToEditButtonSelected: props.collabEdit && props.collabEdit.isInviteToEditButtonSelected,
|
|
52
|
+
featureFlags: featureFlags,
|
|
53
|
+
editorAnalyticsAPI: props.editorAnalyticsAPI,
|
|
54
|
+
editorAPI: props.editorAPI
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
export default AvatarGroupPluginWrapper;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl-next';
|
|
3
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import messages from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { Avatars } from './avatars';
|
|
6
|
+
import { InviteToEditButton } from './invite-to-edit';
|
|
7
|
+
const AvatarsWithPluginState = props => {
|
|
8
|
+
const title = props.intl.formatMessage(messages.inviteToEditButtonTitle);
|
|
9
|
+
const {
|
|
10
|
+
isInviteToEditButtonSelected: selected,
|
|
11
|
+
inviteToEditHandler: onClick,
|
|
12
|
+
inviteToEditComponent: Component,
|
|
13
|
+
editorView,
|
|
14
|
+
featureFlags,
|
|
15
|
+
editorAnalyticsAPI,
|
|
16
|
+
editorAPI
|
|
17
|
+
} = props;
|
|
18
|
+
const {
|
|
19
|
+
collabEditState
|
|
20
|
+
} = useSharedPluginState(editorAPI, ['collabEdit']);
|
|
21
|
+
if (!collabEditState) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return /*#__PURE__*/React.createElement(Avatars, {
|
|
25
|
+
sessionId: collabEditState.sessionId,
|
|
26
|
+
participants: collabEditState.activeParticipants,
|
|
27
|
+
editorView: editorView,
|
|
28
|
+
featureFlags: featureFlags,
|
|
29
|
+
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
30
|
+
editorAPI: editorAPI
|
|
31
|
+
}, /*#__PURE__*/React.createElement(InviteToEditButton, {
|
|
32
|
+
title: title,
|
|
33
|
+
selected: selected,
|
|
34
|
+
onClick: onClick,
|
|
35
|
+
Component: Component
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
export default injectIntl(AvatarsWithPluginState);
|