@atlaskit/editor-core 191.1.0 → 191.1.3
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 +8 -0
- package/afm-cc/tsconfig.json +3 -6
- package/dist/cjs/plugins/index.js +1 -8
- package/dist/cjs/presets/universal.js +10 -13
- package/dist/cjs/ui/Addon/click-area-helper.js +2 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +6 -12
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +1 -2
- package/dist/es2019/presets/universal.js +11 -14
- package/dist/es2019/ui/Addon/click-area-helper.js +2 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +1 -2
- package/dist/esm/presets/universal.js +11 -14
- package/dist/esm/ui/Addon/click-area-helper.js +2 -0
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/presets/default.d.ts +6 -36
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/presets/default.d.ts +6 -36
- package/docs/0-intro.tsx +252 -174
- package/docs/1-legacy-editor.tsx +268 -0
- package/package.json +5 -5
- package/dist/cjs/plugins/avatar-group/index.js +0 -40
- package/dist/cjs/plugins/avatar-group/messages.js +0 -14
- package/dist/cjs/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -49
- package/dist/cjs/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -42
- package/dist/cjs/plugins/avatar-group/ui/avatars.js +0 -70
- package/dist/cjs/plugins/avatar-group/ui/colored-avatar-item.js +0 -20
- package/dist/cjs/plugins/avatar-group/ui/index.js +0 -9
- package/dist/cjs/plugins/avatar-group/ui/invite-to-edit.js +0 -45
- package/dist/cjs/plugins/avatar-group/ui/styles.js +0 -17
- package/dist/cjs/plugins/avatar-group/ui/to-avatar.js +0 -30
- package/dist/es2019/plugins/avatar-group/index.js +0 -35
- package/dist/es2019/plugins/avatar-group/messages.js +0 -8
- package/dist/es2019/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -53
- package/dist/es2019/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -38
- package/dist/es2019/plugins/avatar-group/ui/avatars.js +0 -62
- package/dist/es2019/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
- package/dist/es2019/plugins/avatar-group/ui/index.js +0 -2
- package/dist/es2019/plugins/avatar-group/ui/invite-to-edit.js +0 -32
- package/dist/es2019/plugins/avatar-group/ui/styles.js +0 -46
- package/dist/es2019/plugins/avatar-group/ui/to-avatar.js +0 -16
- package/dist/esm/plugins/avatar-group/index.js +0 -33
- package/dist/esm/plugins/avatar-group/messages.js +0 -8
- package/dist/esm/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -42
- package/dist/esm/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -35
- package/dist/esm/plugins/avatar-group/ui/avatars.js +0 -62
- package/dist/esm/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
- package/dist/esm/plugins/avatar-group/ui/index.js +0 -2
- package/dist/esm/plugins/avatar-group/ui/invite-to-edit.js +0 -34
- package/dist/esm/plugins/avatar-group/ui/styles.js +0 -10
- package/dist/esm/plugins/avatar-group/ui/to-avatar.js +0 -23
- package/dist/types/plugins/avatar-group/index.d.ts +0 -19
- package/dist/types/plugins/avatar-group/messages.d.ts +0 -7
- package/dist/types/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
- package/dist/types/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -81
- package/dist/types/plugins/avatar-group/ui/avatars.d.ts +0 -17
- package/dist/types/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -10
- package/dist/types/plugins/avatar-group/ui/index.d.ts +0 -2
- package/dist/types/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
- package/dist/types/plugins/avatar-group/ui/styles.d.ts +0 -3
- package/dist/types/plugins/avatar-group/ui/to-avatar.d.ts +0 -30
- package/dist/types-ts4.5/plugins/avatar-group/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/avatar-group/messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
- package/dist/types-ts4.5/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -97
- package/dist/types-ts4.5/plugins/avatar-group/ui/avatars.d.ts +0 -19
- package/dist/types-ts4.5/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -12
- package/dist/types-ts4.5/plugins/avatar-group/ui/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
- package/dist/types-ts4.5/plugins/avatar-group/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/plugins/avatar-group/ui/to-avatar.d.ts +0 -37
- /package/docs/{1-labs.tsx → 2-labs.tsx} +0 -0
- /package/docs/{2-autoformatting.tsx → 3-autoformatting.tsx} +0 -0
- /package/docs/{3-annotations.tsx → 4-annotations.tsx} +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import AvatarGroupPluginWrapper from './ui/AvatarGroupPluginWrapper';
|
|
3
|
-
const avatarGroup = ({
|
|
4
|
-
config: props,
|
|
5
|
-
api
|
|
6
|
-
}) => {
|
|
7
|
-
var _api$featureFlags;
|
|
8
|
-
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
9
|
-
return {
|
|
10
|
-
name: 'avatarGroup',
|
|
11
|
-
primaryToolbarComponent({
|
|
12
|
-
editorView,
|
|
13
|
-
popupsMountPoint,
|
|
14
|
-
popupsBoundariesElement,
|
|
15
|
-
popupsScrollableElement,
|
|
16
|
-
disabled,
|
|
17
|
-
isToolbarReducedSpacing,
|
|
18
|
-
eventDispatcher,
|
|
19
|
-
dispatchAnalyticsEvent
|
|
20
|
-
}) {
|
|
21
|
-
var _api$analytics;
|
|
22
|
-
return /*#__PURE__*/React.createElement(AvatarGroupPluginWrapper, {
|
|
23
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
24
|
-
editorView: editorView,
|
|
25
|
-
eventDispatcher: eventDispatcher,
|
|
26
|
-
collabEdit: props === null || props === void 0 ? void 0 : props.collabEdit,
|
|
27
|
-
takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
|
|
28
|
-
featureFlags: featureFlags,
|
|
29
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
30
|
-
editorAPI: api
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export default avatarGroup;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { useEffect } from 'react';
|
|
3
|
-
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import AvatarsWithPluginState from './avatars-with-plugin-state';
|
|
5
|
-
import { useIntl } from 'react-intl-next';
|
|
6
|
-
import { avatarGroupMessages } from '../messages';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
const toolbarButtonWrapper = css`
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: flex-end;
|
|
11
|
-
flex-grow: 0;
|
|
12
|
-
align-items: center;
|
|
13
|
-
& > div {
|
|
14
|
-
margin-right: 0;
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
const toolbarButtonWrapperFullWidth = css`
|
|
18
|
-
${toolbarButtonWrapper}
|
|
19
|
-
flex-grow: 1;
|
|
20
|
-
`;
|
|
21
|
-
const AvatarGroupPluginWrapper = props => {
|
|
22
|
-
const {
|
|
23
|
-
dispatchAnalyticsEvent,
|
|
24
|
-
featureFlags
|
|
25
|
-
} = props;
|
|
26
|
-
const intl = useIntl();
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (!dispatchAnalyticsEvent) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
dispatchAnalyticsEvent({
|
|
32
|
-
action: ACTION.VIEWED,
|
|
33
|
-
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
34
|
-
actionSubjectId: ACTION_SUBJECT_ID.AVATAR_GROUP_PLUGIN,
|
|
35
|
-
eventType: EVENT_TYPE.UI
|
|
36
|
-
});
|
|
37
|
-
}, [dispatchAnalyticsEvent]);
|
|
38
|
-
return jsx("div", {
|
|
39
|
-
"aria-label": intl.formatMessage(avatarGroupMessages.editors),
|
|
40
|
-
"data-testid": 'avatar-group-in-plugin',
|
|
41
|
-
css: props.takeFullWidth ? toolbarButtonWrapperFullWidth : toolbarButtonWrapper
|
|
42
|
-
}, jsx(AvatarsWithPluginState, {
|
|
43
|
-
editorView: props.editorView,
|
|
44
|
-
eventDispatcher: props.eventDispatcher,
|
|
45
|
-
inviteToEditComponent: props.collabEdit && props.collabEdit.inviteToEditComponent,
|
|
46
|
-
inviteToEditHandler: props.collabEdit && props.collabEdit.inviteToEditHandler,
|
|
47
|
-
isInviteToEditButtonSelected: props.collabEdit && props.collabEdit.isInviteToEditButtonSelected,
|
|
48
|
-
featureFlags: featureFlags,
|
|
49
|
-
editorAnalyticsAPI: props.editorAnalyticsAPI,
|
|
50
|
-
editorAPI: props.editorAPI
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
export default AvatarGroupPluginWrapper;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl-next';
|
|
3
|
-
import messages from '../../../messages';
|
|
4
|
-
import { Avatars } from './avatars';
|
|
5
|
-
import { InviteToEditButton } from './invite-to-edit';
|
|
6
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
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);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import AvatarGroup from '@atlaskit/avatar-group';
|
|
5
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { avatarContainer } from './styles';
|
|
7
|
-
import toAvatar from './to-avatar';
|
|
8
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
9
|
-
export const scrollToCollabCursor = (editorView, participants, sessionId, index, editorAnalyticsAPI) => {
|
|
10
|
-
const selectedUser = participants[index];
|
|
11
|
-
if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
|
|
12
|
-
const {
|
|
13
|
-
state
|
|
14
|
-
} = editorView;
|
|
15
|
-
let tr = state.tr;
|
|
16
|
-
const analyticsPayload = {
|
|
17
|
-
action: ACTION.MATCHED,
|
|
18
|
-
actionSubject: ACTION_SUBJECT.SELECTION,
|
|
19
|
-
eventType: EVENT_TYPE.TRACK
|
|
20
|
-
};
|
|
21
|
-
tr.setSelection(Selection.near(tr.doc.resolve(selectedUser.cursorPos)));
|
|
22
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(analyticsPayload)(tr);
|
|
23
|
-
tr.scrollIntoView();
|
|
24
|
-
editorView.dispatch(tr);
|
|
25
|
-
if (!editorView.hasFocus()) {
|
|
26
|
-
editorView.focus();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const Avatars = /*#__PURE__*/React.memo(props => {
|
|
31
|
-
var _props$participants;
|
|
32
|
-
const {
|
|
33
|
-
sessionId,
|
|
34
|
-
editorView,
|
|
35
|
-
featureFlags,
|
|
36
|
-
editorAPI
|
|
37
|
-
} = props;
|
|
38
|
-
const participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
|
|
39
|
-
const avatars = participants.sort(p => p.sessionId === sessionId ? -1 : 1).map(participant => toAvatar(participant, editorAPI));
|
|
40
|
-
if (!avatars.length) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return jsx("div", {
|
|
44
|
-
css: avatarContainer
|
|
45
|
-
}, jsx(AvatarGroup, {
|
|
46
|
-
appearance: "stack",
|
|
47
|
-
size: "medium",
|
|
48
|
-
data: avatars,
|
|
49
|
-
maxCount: 3,
|
|
50
|
-
onAvatarClick: (_event, _analytics, index) => {
|
|
51
|
-
if (!editorView) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const allowCollabAvatarScroll = featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.collabAvatarScroll;
|
|
55
|
-
|
|
56
|
-
// user does not need to scroll to their own position (index 0)
|
|
57
|
-
if (allowCollabAvatarScroll && index > 0) {
|
|
58
|
-
scrollToCollabCursor(editorView, participants, props.sessionId, index, props.editorAnalyticsAPI);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}), props.children);
|
|
62
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
|
-
import { badge } from './styles';
|
|
4
|
-
import { R100 } from '@atlaskit/theme/colors';
|
|
5
|
-
export const ColoredAvatarItem = props => {
|
|
6
|
-
var _props$api, _props$api$collabEdit, _props$api$collabEdit2;
|
|
7
|
-
const color = (_props$api = props.api) === null || _props$api === void 0 ? void 0 : (_props$api$collabEdit = _props$api.collabEdit) === null || _props$api$collabEdit === void 0 ? void 0 : (_props$api$collabEdit2 = _props$api$collabEdit.actions) === null || _props$api$collabEdit2 === void 0 ? void 0 : _props$api$collabEdit2.getAvatarColor(props.sessionId).color.solid;
|
|
8
|
-
const avatar = props.name.substr(0, 1).toUpperCase();
|
|
9
|
-
return jsx("div", {
|
|
10
|
-
css: badge(color || R100),
|
|
11
|
-
"data-testid": "editor-collab-badge"
|
|
12
|
-
}, avatar);
|
|
13
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { Fragment } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import InviteTeamIcon from '@atlaskit/icon/glyph/editor/add';
|
|
5
|
-
import ToolbarButton from '../../../ui/ToolbarButton';
|
|
6
|
-
import { inviteTeamWrapper } from './styles';
|
|
7
|
-
const ID = props => jsx(Fragment, null, props.children);
|
|
8
|
-
export const InviteToEditButton = props => {
|
|
9
|
-
const {
|
|
10
|
-
Component,
|
|
11
|
-
onClick,
|
|
12
|
-
selected,
|
|
13
|
-
title
|
|
14
|
-
} = props;
|
|
15
|
-
const iconBefore = React.useMemo(() => jsx(InviteTeamIcon, {
|
|
16
|
-
label: title
|
|
17
|
-
}), [title]);
|
|
18
|
-
if (!Component && !onClick) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
const Wrapper = Component ? Component : ID;
|
|
22
|
-
return jsx("div", {
|
|
23
|
-
css: inviteTeamWrapper
|
|
24
|
-
}, jsx(Wrapper, null, jsx(ToolbarButton, {
|
|
25
|
-
className: "invite-to-edit",
|
|
26
|
-
onClick: onClick,
|
|
27
|
-
selected: selected,
|
|
28
|
-
title: title,
|
|
29
|
-
titlePosition: "bottom",
|
|
30
|
-
iconBefore: iconBefore
|
|
31
|
-
})));
|
|
32
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
import { N20 } from '@atlaskit/theme/colors';
|
|
3
|
-
import { akEditorSmallZIndex, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
4
|
-
export const inviteTeamWrapper = css`
|
|
5
|
-
background: ${`var(--ds-background-neutral, ${N20})`};
|
|
6
|
-
border-radius: 50%;
|
|
7
|
-
min-width: ${"var(--ds-space-400, 32px)"};
|
|
8
|
-
margin-left: ${"var(--ds-space-negative-050, -4px)"};
|
|
9
|
-
`;
|
|
10
|
-
export const avatarContainer = css`
|
|
11
|
-
margin-right: ${"var(--ds-space-100, 8px)"};
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
|
|
15
|
-
// ED-13102: This is to override list styles that come from the
|
|
16
|
-
// .wiki-content class in Confluence that should not apply within
|
|
17
|
-
// the toolbar. Has to be extra specific to override.
|
|
18
|
-
&& > ul {
|
|
19
|
-
list-style-type: none;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
div:last-child button.invite-to-edit {
|
|
23
|
-
border-radius: 50%;
|
|
24
|
-
height: 32px;
|
|
25
|
-
width: 32px;
|
|
26
|
-
padding: ${"var(--ds-space-025, 2px)"};
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
export const badge = color => css`
|
|
30
|
-
display: block;
|
|
31
|
-
position: absolute;
|
|
32
|
-
right: 1px;
|
|
33
|
-
bottom: 1px;
|
|
34
|
-
width: 13px;
|
|
35
|
-
height: 13px;
|
|
36
|
-
z-index: ${akEditorSmallZIndex};
|
|
37
|
-
border-radius: 3px;
|
|
38
|
-
background: ${color};
|
|
39
|
-
color: ${"var(--ds-text-inverse, #fff)"};
|
|
40
|
-
font-size: ${relativeFontSizeToBase16(9)};
|
|
41
|
-
line-height: 0;
|
|
42
|
-
padding-top: 7px;
|
|
43
|
-
text-align: center;
|
|
44
|
-
box-shadow: 0 0 1px ${"var(--ds-border-inverse, #fff)"};
|
|
45
|
-
box-sizing: border-box;
|
|
46
|
-
`;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import memoizeOne from 'memoize-one';
|
|
3
|
-
import { ColoredAvatarItem } from './colored-avatar-item';
|
|
4
|
-
const toAvatar = (participant, api) => ({
|
|
5
|
-
name: participant.name,
|
|
6
|
-
src: participant.avatar,
|
|
7
|
-
size: 'medium',
|
|
8
|
-
presence: /*#__PURE__*/React.createElement(ColoredAvatarItem, {
|
|
9
|
-
api: api,
|
|
10
|
-
name: participant.name,
|
|
11
|
-
sessionId: participant.sessionId
|
|
12
|
-
})
|
|
13
|
-
});
|
|
14
|
-
export default memoizeOne(toAvatar, function participantEquals([a], [b]) {
|
|
15
|
-
return a.name === b.name && a.avatar === b.avatar && a.sessionId === b.sessionId;
|
|
16
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import AvatarGroupPluginWrapper from './ui/AvatarGroupPluginWrapper';
|
|
3
|
-
var avatarGroup = function avatarGroup(_ref) {
|
|
4
|
-
var _api$featureFlags;
|
|
5
|
-
var props = _ref.config,
|
|
6
|
-
api = _ref.api;
|
|
7
|
-
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
8
|
-
return {
|
|
9
|
-
name: 'avatarGroup',
|
|
10
|
-
primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
|
|
11
|
-
var _api$analytics;
|
|
12
|
-
var editorView = _ref2.editorView,
|
|
13
|
-
popupsMountPoint = _ref2.popupsMountPoint,
|
|
14
|
-
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
15
|
-
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
16
|
-
disabled = _ref2.disabled,
|
|
17
|
-
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
18
|
-
eventDispatcher = _ref2.eventDispatcher,
|
|
19
|
-
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
20
|
-
return /*#__PURE__*/React.createElement(AvatarGroupPluginWrapper, {
|
|
21
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
22
|
-
editorView: editorView,
|
|
23
|
-
eventDispatcher: eventDispatcher,
|
|
24
|
-
collabEdit: props === null || props === void 0 ? void 0 : props.collabEdit,
|
|
25
|
-
takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
|
|
26
|
-
featureFlags: featureFlags,
|
|
27
|
-
editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
|
|
28
|
-
editorAPI: api
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export default avatarGroup;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2;
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
-
import { css, jsx } from '@emotion/react';
|
|
6
|
-
import AvatarsWithPluginState from './avatars-with-plugin-state';
|
|
7
|
-
import { useIntl } from 'react-intl-next';
|
|
8
|
-
import { avatarGroupMessages } from '../messages';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
var toolbarButtonWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n flex-grow: 0;\n align-items: center;\n & > div {\n margin-right: 0;\n }\n"])));
|
|
11
|
-
var toolbarButtonWrapperFullWidth = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n flex-grow: 1;\n"])), toolbarButtonWrapper);
|
|
12
|
-
var AvatarGroupPluginWrapper = function AvatarGroupPluginWrapper(props) {
|
|
13
|
-
var dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
|
|
14
|
-
featureFlags = props.featureFlags;
|
|
15
|
-
var intl = useIntl();
|
|
16
|
-
useEffect(function () {
|
|
17
|
-
if (!dispatchAnalyticsEvent) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
dispatchAnalyticsEvent({
|
|
21
|
-
action: ACTION.VIEWED,
|
|
22
|
-
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
23
|
-
actionSubjectId: ACTION_SUBJECT_ID.AVATAR_GROUP_PLUGIN,
|
|
24
|
-
eventType: EVENT_TYPE.UI
|
|
25
|
-
});
|
|
26
|
-
}, [dispatchAnalyticsEvent]);
|
|
27
|
-
return jsx("div", {
|
|
28
|
-
"aria-label": intl.formatMessage(avatarGroupMessages.editors),
|
|
29
|
-
"data-testid": 'avatar-group-in-plugin',
|
|
30
|
-
css: props.takeFullWidth ? toolbarButtonWrapperFullWidth : toolbarButtonWrapper
|
|
31
|
-
}, jsx(AvatarsWithPluginState, {
|
|
32
|
-
editorView: props.editorView,
|
|
33
|
-
eventDispatcher: props.eventDispatcher,
|
|
34
|
-
inviteToEditComponent: props.collabEdit && props.collabEdit.inviteToEditComponent,
|
|
35
|
-
inviteToEditHandler: props.collabEdit && props.collabEdit.inviteToEditHandler,
|
|
36
|
-
isInviteToEditButtonSelected: props.collabEdit && props.collabEdit.isInviteToEditButtonSelected,
|
|
37
|
-
featureFlags: featureFlags,
|
|
38
|
-
editorAnalyticsAPI: props.editorAnalyticsAPI,
|
|
39
|
-
editorAPI: props.editorAPI
|
|
40
|
-
}));
|
|
41
|
-
};
|
|
42
|
-
export default AvatarGroupPluginWrapper;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl-next';
|
|
3
|
-
import messages from '../../../messages';
|
|
4
|
-
import { Avatars } from './avatars';
|
|
5
|
-
import { InviteToEditButton } from './invite-to-edit';
|
|
6
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
-
var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
|
|
8
|
-
var title = props.intl.formatMessage(messages.inviteToEditButtonTitle);
|
|
9
|
-
var selected = props.isInviteToEditButtonSelected,
|
|
10
|
-
onClick = props.inviteToEditHandler,
|
|
11
|
-
Component = props.inviteToEditComponent,
|
|
12
|
-
editorView = props.editorView,
|
|
13
|
-
featureFlags = props.featureFlags,
|
|
14
|
-
editorAnalyticsAPI = props.editorAnalyticsAPI,
|
|
15
|
-
editorAPI = props.editorAPI;
|
|
16
|
-
var _useSharedPluginState = useSharedPluginState(editorAPI, ['collabEdit']),
|
|
17
|
-
collabEditState = _useSharedPluginState.collabEditState;
|
|
18
|
-
if (!collabEditState) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return /*#__PURE__*/React.createElement(Avatars, {
|
|
22
|
-
sessionId: collabEditState.sessionId,
|
|
23
|
-
participants: collabEditState.activeParticipants,
|
|
24
|
-
editorView: editorView,
|
|
25
|
-
featureFlags: featureFlags,
|
|
26
|
-
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
27
|
-
editorAPI: editorAPI
|
|
28
|
-
}, /*#__PURE__*/React.createElement(InviteToEditButton, {
|
|
29
|
-
title: title,
|
|
30
|
-
selected: selected,
|
|
31
|
-
onClick: onClick,
|
|
32
|
-
Component: Component
|
|
33
|
-
}));
|
|
34
|
-
};
|
|
35
|
-
export default injectIntl(AvatarsWithPluginState);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import AvatarGroup from '@atlaskit/avatar-group';
|
|
5
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { avatarContainer } from './styles';
|
|
7
|
-
import toAvatar from './to-avatar';
|
|
8
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
9
|
-
export var scrollToCollabCursor = function scrollToCollabCursor(editorView, participants, sessionId, index, editorAnalyticsAPI) {
|
|
10
|
-
var selectedUser = participants[index];
|
|
11
|
-
if (selectedUser && selectedUser.cursorPos !== undefined && selectedUser.sessionId !== sessionId) {
|
|
12
|
-
var state = editorView.state;
|
|
13
|
-
var tr = state.tr;
|
|
14
|
-
var analyticsPayload = {
|
|
15
|
-
action: ACTION.MATCHED,
|
|
16
|
-
actionSubject: ACTION_SUBJECT.SELECTION,
|
|
17
|
-
eventType: EVENT_TYPE.TRACK
|
|
18
|
-
};
|
|
19
|
-
tr.setSelection(Selection.near(tr.doc.resolve(selectedUser.cursorPos)));
|
|
20
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(analyticsPayload)(tr);
|
|
21
|
-
tr.scrollIntoView();
|
|
22
|
-
editorView.dispatch(tr);
|
|
23
|
-
if (!editorView.hasFocus()) {
|
|
24
|
-
editorView.focus();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
export var Avatars = /*#__PURE__*/React.memo(function (props) {
|
|
29
|
-
var _props$participants;
|
|
30
|
-
var sessionId = props.sessionId,
|
|
31
|
-
editorView = props.editorView,
|
|
32
|
-
featureFlags = props.featureFlags,
|
|
33
|
-
editorAPI = props.editorAPI;
|
|
34
|
-
var participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
|
|
35
|
-
var avatars = participants.sort(function (p) {
|
|
36
|
-
return p.sessionId === sessionId ? -1 : 1;
|
|
37
|
-
}).map(function (participant) {
|
|
38
|
-
return toAvatar(participant, editorAPI);
|
|
39
|
-
});
|
|
40
|
-
if (!avatars.length) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return jsx("div", {
|
|
44
|
-
css: avatarContainer
|
|
45
|
-
}, jsx(AvatarGroup, {
|
|
46
|
-
appearance: "stack",
|
|
47
|
-
size: "medium",
|
|
48
|
-
data: avatars,
|
|
49
|
-
maxCount: 3,
|
|
50
|
-
onAvatarClick: function onAvatarClick(_event, _analytics, index) {
|
|
51
|
-
if (!editorView) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var allowCollabAvatarScroll = featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.collabAvatarScroll;
|
|
55
|
-
|
|
56
|
-
// user does not need to scroll to their own position (index 0)
|
|
57
|
-
if (allowCollabAvatarScroll && index > 0) {
|
|
58
|
-
scrollToCollabCursor(editorView, participants, props.sessionId, index, props.editorAnalyticsAPI);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}), props.children);
|
|
62
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
|
-
import { badge } from './styles';
|
|
4
|
-
import { R100 } from '@atlaskit/theme/colors';
|
|
5
|
-
export var ColoredAvatarItem = function ColoredAvatarItem(props) {
|
|
6
|
-
var _props$api;
|
|
7
|
-
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;
|
|
8
|
-
var avatar = props.name.substr(0, 1).toUpperCase();
|
|
9
|
-
return jsx("div", {
|
|
10
|
-
css: badge(color || R100),
|
|
11
|
-
"data-testid": "editor-collab-badge"
|
|
12
|
-
}, avatar);
|
|
13
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { Fragment } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import InviteTeamIcon from '@atlaskit/icon/glyph/editor/add';
|
|
5
|
-
import ToolbarButton from '../../../ui/ToolbarButton';
|
|
6
|
-
import { inviteTeamWrapper } from './styles';
|
|
7
|
-
var ID = function ID(props) {
|
|
8
|
-
return jsx(Fragment, null, props.children);
|
|
9
|
-
};
|
|
10
|
-
export var InviteToEditButton = function InviteToEditButton(props) {
|
|
11
|
-
var Component = props.Component,
|
|
12
|
-
onClick = props.onClick,
|
|
13
|
-
selected = props.selected,
|
|
14
|
-
title = props.title;
|
|
15
|
-
var iconBefore = React.useMemo(function () {
|
|
16
|
-
return jsx(InviteTeamIcon, {
|
|
17
|
-
label: title
|
|
18
|
-
});
|
|
19
|
-
}, [title]);
|
|
20
|
-
if (!Component && !onClick) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
var Wrapper = Component ? Component : ID;
|
|
24
|
-
return jsx("div", {
|
|
25
|
-
css: inviteTeamWrapper
|
|
26
|
-
}, jsx(Wrapper, null, jsx(ToolbarButton, {
|
|
27
|
-
className: "invite-to-edit",
|
|
28
|
-
onClick: onClick,
|
|
29
|
-
selected: selected,
|
|
30
|
-
title: title,
|
|
31
|
-
titlePosition: "bottom",
|
|
32
|
-
iconBefore: iconBefore
|
|
33
|
-
})));
|
|
34
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { N20 } from '@atlaskit/theme/colors';
|
|
5
|
-
import { akEditorSmallZIndex, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
export var inviteTeamWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: 50%;\n min-width: ", ";\n margin-left: ", ";\n"])), "var(--ds-background-neutral, ".concat(N20, ")"), "var(--ds-space-400, 32px)", "var(--ds-space-negative-050, -4px)");
|
|
7
|
-
export var avatarContainer = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\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)");
|
|
8
|
-
export var badge = function badge(color) {
|
|
9
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\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"])), akEditorSmallZIndex, color, "var(--ds-text-inverse, #fff)", relativeFontSizeToBase16(9), "var(--ds-border-inverse, #fff)");
|
|
10
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import memoizeOne from 'memoize-one';
|
|
4
|
-
import { ColoredAvatarItem } from './colored-avatar-item';
|
|
5
|
-
var toAvatar = function toAvatar(participant, api) {
|
|
6
|
-
return {
|
|
7
|
-
name: participant.name,
|
|
8
|
-
src: participant.avatar,
|
|
9
|
-
size: 'medium',
|
|
10
|
-
presence: /*#__PURE__*/React.createElement(ColoredAvatarItem, {
|
|
11
|
-
api: api,
|
|
12
|
-
name: participant.name,
|
|
13
|
-
sessionId: participant.sessionId
|
|
14
|
-
})
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export default memoizeOne(toAvatar, function participantEquals(_ref, _ref2) {
|
|
18
|
-
var _ref3 = _slicedToArray(_ref, 1),
|
|
19
|
-
a = _ref3[0];
|
|
20
|
-
var _ref4 = _slicedToArray(_ref2, 1),
|
|
21
|
-
b = _ref4[0];
|
|
22
|
-
return a.name === b.name && a.avatar === b.avatar && a.sessionId === b.sessionId;
|
|
23
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
3
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
4
|
-
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
-
import type { CollabEditPlugin } from '@atlaskit/editor-plugin-collab-edit';
|
|
6
|
-
type Config = {
|
|
7
|
-
collabEdit?: CollabEditOptions;
|
|
8
|
-
takeFullWidth: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type AvatarGroupPlugin = NextEditorPlugin<'avatarGroup', {
|
|
11
|
-
pluginConfiguration: Config;
|
|
12
|
-
dependencies: [
|
|
13
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
14
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
15
|
-
OptionalPlugin<CollabEditPlugin>
|
|
16
|
-
];
|
|
17
|
-
}>;
|
|
18
|
-
declare const avatarGroup: AvatarGroupPlugin;
|
|
19
|
-
export default avatarGroup;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from '@emotion/react';
|
|
2
|
-
import type { EventDispatcher } from '../../../event-dispatcher';
|
|
3
|
-
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
5
|
-
import type { DispatchAnalyticsEvent, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import type { ExtractInjectionAPI, FeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
|
-
import type { AvatarGroupPlugin } from '..';
|
|
8
|
-
declare const AvatarGroupPluginWrapper: (props: {
|
|
9
|
-
collabEdit?: CollabEditOptions | undefined;
|
|
10
|
-
editorView: EditorView;
|
|
11
|
-
eventDispatcher: EventDispatcher<any>;
|
|
12
|
-
dispatchAnalyticsEvent?: DispatchAnalyticsEvent | undefined;
|
|
13
|
-
takeFullWidth: boolean;
|
|
14
|
-
featureFlags: FeatureFlags;
|
|
15
|
-
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
16
|
-
editorAPI: ExtractInjectionAPI<AvatarGroupPlugin> | undefined;
|
|
17
|
-
}) => jsx.JSX.Element;
|
|
18
|
-
export default AvatarGroupPluginWrapper;
|