@atlaskit/editor-core 191.0.9 → 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.
Files changed (85) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/afm-cc/tsconfig.json +3 -6
  3. package/dist/cjs/plugins/index.js +1 -8
  4. package/dist/cjs/presets/universal.js +10 -13
  5. package/dist/cjs/ui/Addon/click-area-helper.js +2 -0
  6. package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -3
  7. package/dist/cjs/ui/Appearance/Comment/Toolbar.js +19 -6
  8. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +6 -12
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/plugins/index.js +1 -2
  11. package/dist/es2019/presets/universal.js +11 -14
  12. package/dist/es2019/ui/Addon/click-area-helper.js +2 -0
  13. package/dist/es2019/ui/Appearance/Comment/Comment.js +6 -3
  14. package/dist/es2019/ui/Appearance/Comment/Toolbar.js +38 -6
  15. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/esm/plugins/index.js +1 -2
  18. package/dist/esm/presets/universal.js +11 -14
  19. package/dist/esm/ui/Addon/click-area-helper.js +2 -0
  20. package/dist/esm/ui/Appearance/Comment/Comment.js +6 -3
  21. package/dist/esm/ui/Appearance/Comment/Toolbar.js +19 -6
  22. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +4 -10
  23. package/dist/esm/version-wrapper.js +1 -1
  24. package/dist/types/plugins/index.d.ts +0 -1
  25. package/dist/types/presets/default.d.ts +6 -36
  26. package/dist/types/ui/Appearance/Comment/Toolbar.d.ts +2 -1
  27. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  28. package/dist/types-ts4.5/presets/default.d.ts +6 -36
  29. package/dist/types-ts4.5/ui/Appearance/Comment/Toolbar.d.ts +2 -1
  30. package/docs/0-intro.tsx +252 -174
  31. package/docs/1-legacy-editor.tsx +268 -0
  32. package/package.json +7 -7
  33. package/dist/cjs/plugins/avatar-group/index.js +0 -40
  34. package/dist/cjs/plugins/avatar-group/messages.js +0 -14
  35. package/dist/cjs/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -49
  36. package/dist/cjs/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -42
  37. package/dist/cjs/plugins/avatar-group/ui/avatars.js +0 -70
  38. package/dist/cjs/plugins/avatar-group/ui/colored-avatar-item.js +0 -20
  39. package/dist/cjs/plugins/avatar-group/ui/index.js +0 -9
  40. package/dist/cjs/plugins/avatar-group/ui/invite-to-edit.js +0 -45
  41. package/dist/cjs/plugins/avatar-group/ui/styles.js +0 -17
  42. package/dist/cjs/plugins/avatar-group/ui/to-avatar.js +0 -30
  43. package/dist/es2019/plugins/avatar-group/index.js +0 -35
  44. package/dist/es2019/plugins/avatar-group/messages.js +0 -8
  45. package/dist/es2019/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -53
  46. package/dist/es2019/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -38
  47. package/dist/es2019/plugins/avatar-group/ui/avatars.js +0 -62
  48. package/dist/es2019/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
  49. package/dist/es2019/plugins/avatar-group/ui/index.js +0 -2
  50. package/dist/es2019/plugins/avatar-group/ui/invite-to-edit.js +0 -32
  51. package/dist/es2019/plugins/avatar-group/ui/styles.js +0 -46
  52. package/dist/es2019/plugins/avatar-group/ui/to-avatar.js +0 -16
  53. package/dist/esm/plugins/avatar-group/index.js +0 -33
  54. package/dist/esm/plugins/avatar-group/messages.js +0 -8
  55. package/dist/esm/plugins/avatar-group/ui/AvatarGroupPluginWrapper.js +0 -42
  56. package/dist/esm/plugins/avatar-group/ui/avatars-with-plugin-state.js +0 -35
  57. package/dist/esm/plugins/avatar-group/ui/avatars.js +0 -62
  58. package/dist/esm/plugins/avatar-group/ui/colored-avatar-item.js +0 -13
  59. package/dist/esm/plugins/avatar-group/ui/index.js +0 -2
  60. package/dist/esm/plugins/avatar-group/ui/invite-to-edit.js +0 -34
  61. package/dist/esm/plugins/avatar-group/ui/styles.js +0 -10
  62. package/dist/esm/plugins/avatar-group/ui/to-avatar.js +0 -23
  63. package/dist/types/plugins/avatar-group/index.d.ts +0 -19
  64. package/dist/types/plugins/avatar-group/messages.d.ts +0 -7
  65. package/dist/types/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
  66. package/dist/types/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -81
  67. package/dist/types/plugins/avatar-group/ui/avatars.d.ts +0 -17
  68. package/dist/types/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -10
  69. package/dist/types/plugins/avatar-group/ui/index.d.ts +0 -2
  70. package/dist/types/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
  71. package/dist/types/plugins/avatar-group/ui/styles.d.ts +0 -3
  72. package/dist/types/plugins/avatar-group/ui/to-avatar.d.ts +0 -30
  73. package/dist/types-ts4.5/plugins/avatar-group/index.d.ts +0 -19
  74. package/dist/types-ts4.5/plugins/avatar-group/messages.d.ts +0 -7
  75. package/dist/types-ts4.5/plugins/avatar-group/ui/AvatarGroupPluginWrapper.d.ts +0 -18
  76. package/dist/types-ts4.5/plugins/avatar-group/ui/avatars-with-plugin-state.d.ts +0 -97
  77. package/dist/types-ts4.5/plugins/avatar-group/ui/avatars.d.ts +0 -19
  78. package/dist/types-ts4.5/plugins/avatar-group/ui/colored-avatar-item.d.ts +0 -12
  79. package/dist/types-ts4.5/plugins/avatar-group/ui/index.d.ts +0 -2
  80. package/dist/types-ts4.5/plugins/avatar-group/ui/invite-to-edit.d.ts +0 -10
  81. package/dist/types-ts4.5/plugins/avatar-group/ui/styles.d.ts +0 -3
  82. package/dist/types-ts4.5/plugins/avatar-group/ui/to-avatar.d.ts +0 -37
  83. /package/docs/{1-labs.tsx → 2-labs.tsx} +0 -0
  84. /package/docs/{2-autoformatting.tsx → 3-autoformatting.tsx} +0 -0
  85. /package/docs/{3-annotations.tsx → 4-annotations.tsx} +0 -0
@@ -0,0 +1,268 @@
1
+ import React from 'react';
2
+ import {
3
+ md,
4
+ code,
5
+ Example,
6
+ Props,
7
+ AtlassianInternalWarning,
8
+ } from '@atlaskit/docs';
9
+
10
+ export default md`
11
+ ${(<AtlassianInternalWarning />)}
12
+
13
+ ### Note:
14
+
15
+ Don't forget to add these polyfills to your product build if you're using emoji or mentions in the editor and you want to target older browsers:
16
+
17
+ * Promise ([polyfill](https://www.npmjs.com/package/es6-promise), [browser support](http://caniuse.com/#feat=promises))
18
+ * Fetch API ([polyfill](https://www.npmjs.com/package/whatwg-fetch), [browser support](http://caniuse.com/#feat=fetch))
19
+ * Element.closest ([polyfill](https://www.npmjs.com/package/element-closest), [browser support](http://caniuse.com/#feat=element-closest))
20
+
21
+ # Installing the editor package
22
+
23
+ The dependencies of editor is a complex beast and can confuse some package managers (\`npm\` does not seem to result in duplicates, but \`yarn\` does).
24
+
25
+ We have encountered many strange bugs that were caused by duplicated packages in a product codebase. It is highly recommend to deduplicate packages to work around the yarn bug.
26
+
27
+ Be sure to dedupe your packages after adding or upgrading \`@atlaskit/editor-core\` in your package.json file. Our recommendation is to use [yarn-deduplicate](https://www.npmjs.com/package/yarn-deduplicate).
28
+
29
+ # Starting to use the editor
30
+
31
+ ## Simplest Editor
32
+
33
+ The simplest editor in the world is just:
34
+
35
+ ${code`
36
+ import { Editor } from '@atlaskit/editor-core';
37
+
38
+ <Editor appearance="comment" />;
39
+ `}
40
+
41
+ This will render the comment editor with only text formatting (bold / italics / underline / superscript/subscript) enabled.
42
+
43
+ You can enable more functionality in the editor via passing extra props.
44
+
45
+ ## Editor with mentions
46
+
47
+ To add mention capabilities to the editor, you will need to pass in a "Mention Provider". At a high level, this is simply an object that will allow us to interface whatever mention source you want to use with the editor. This looks like:
48
+
49
+ ${code`
50
+ import { Editor } from '@atlaskit/editor-core';
51
+ import mentionProvider from './mentionProvider';
52
+
53
+ <Editor
54
+ appearance="comment"
55
+ mentionProvider={mentionProvider.get()}
56
+ />;
57
+ `}
58
+
59
+ ## Collapsed Editor
60
+
61
+ Sometimes we don't want to show the whole editor at the start and instead show a collapsed state for a user to click on to start typing. This looks like:
62
+
63
+ ${code`
64
+ import { Editor, CollapsedEditor } from '@atlaskit/editor-core';
65
+
66
+ class CollapsibleEditor extends React.Component {
67
+ state = { isExpanded: false };
68
+
69
+ expandEditor = () => this.setState({ isExpanded: true });
70
+ collapseEditor = () => this.setState({ isExpanded: false });
71
+
72
+ onSave = () => {
73
+ /* do something */
74
+ };
75
+
76
+ render() {
77
+ return (
78
+ <CollapsedEditor
79
+ placeholder="What would you like to say?"
80
+ isExpanded={this.state.isExpanded}
81
+ onFocus={this.expandEditor}
82
+ >
83
+ <Editor
84
+ appearance="comment"
85
+ onSave={this.onSave}
86
+ onCancel={this.collapseEditor}
87
+ />
88
+ </CollapsedEditor>
89
+ );
90
+ }
91
+ }
92
+ `}
93
+
94
+ ## What is EditorContext?!?!
95
+
96
+ EditorContext allows you, in conjunction with WithEditorActions, to manipulate the editor from anywhere inside the EditorContext. In the example below, notice that no reference is kept to the editor instance.
97
+
98
+ ${code`
99
+ import { EditorContext, WithEditorActions } from '@atlaskit/editor-core';
100
+ import { CollapsibleEditor } from 'previous-example';
101
+
102
+ <EditorContext>
103
+ <div>
104
+ <CollapsibleEditor />
105
+ <WithEditorActions
106
+ render={actions => (
107
+ <ButtonGroup>
108
+ <Button onClick={() => actions.clear()}>Clear Editor</Button>
109
+ <Button onClick={() => actions.focus()}>Focus Editor</Button>
110
+ </ButtonGroup>
111
+ )}
112
+ />
113
+ </div>
114
+ </EditorContext>;
115
+ `}
116
+
117
+ ## How can I set the content of the editor?
118
+
119
+ There's two ways at the moment. It depends on whether the editor is mounted yet or not.
120
+
121
+ ### If the editor is not mounted
122
+
123
+ You can just pass through the value you want to set the editor to, as the \`defaultValue\` prop
124
+
125
+ ### If the Editor is Mounted
126
+
127
+ You can use \`WithEditorActions\` and \`actions.replaceDocument(documentValueHere)\` together
128
+
129
+ ## Using a non-'Atlassian Document Format' storage format
130
+
131
+ Using a custom storage format is fairly straightforward - you simply have to import the relevant transformer and pass it through to the editor. That's all!
132
+
133
+ ${code`
134
+ import { Editor, BitbucketTransformer } from '@atlaskit/editor-core';
135
+
136
+ <Editor
137
+ appearance="comment"
138
+ contentTransformerProvider={schema => new BitbucketTransformer(schema)}
139
+ />;
140
+ `}
141
+
142
+ ## Example saving content
143
+
144
+ If you want an example of actually using \`WithEditorActions\` to save content, you've got it!
145
+
146
+ ${code`
147
+ class SaveExample extends React.Component {
148
+ onSubmit = actions => editorView => {
149
+ actions.getValue().then(value => {
150
+ if (value != null) {
151
+ dispatch({ type: 'SAVE_COMMENT', payload: value });
152
+ }
153
+ })
154
+ }
155
+
156
+ render() {
157
+ return (
158
+ <EditorContext>
159
+ <WithEditorActions
160
+ render={actions => (
161
+ <Editor
162
+ appearance="comment"
163
+ onSave={this.onSubmit(actions)}
164
+ />
165
+ )}
166
+ />
167
+ </EditorContext>
168
+ )
169
+ }
170
+ `}
171
+
172
+ alternatively
173
+
174
+ ${code`
175
+ class EditorWrapper extends React.Component {
176
+ propTypes = { actions: PropTypes.object };
177
+
178
+ onSubmit = () => {
179
+ this.props.actions.getValue().then(value => {
180
+ if (value != null) {
181
+ dispatch({ type: 'SAVE_COMMENT', payload: value });
182
+ }
183
+ });
184
+ };
185
+
186
+ render() {
187
+ return (
188
+ <Editor
189
+ appearance="comment"
190
+ onSave={this.onSubmit}
191
+ />
192
+ );
193
+ }
194
+ }
195
+
196
+ class SaveExample extends React.Component {
197
+ render() {
198
+ return (
199
+ <EditorContext>
200
+ <WithEditorActions
201
+ render={actions => <EditorWrapper actions={actions} />}
202
+ />
203
+ </EditorContext>
204
+ );
205
+ }
206
+ }
207
+ `}
208
+
209
+ We’d love to hear your feedback.
210
+
211
+ ## Theming and dark mode support
212
+ To render certain ADF content correctly in different color themes, such as light and dark mode, this package utilise
213
+ the \`@atlaskit/editor-palette\` package, which converts colors stored in ADF to Atlassian Design Tokens.
214
+ Learn more about this utility in the [Editor Palette docs](/packages/editor/editor-palette).
215
+
216
+ Full light and dark mode support for the Editor is a work in progress. Currently, the following experiences do not yet support theming:
217
+ - Custom table backgrounds
218
+
219
+ ## Tab indexing / focus
220
+ If you are displaying a title you may need to listen for a tab event to
221
+ explicitly enable and focus the editor.
222
+
223
+ Shift + Tab will move from the title bar to the toolbar preserving tab order.
224
+
225
+ See the Full Page Example code for a complete implementation.
226
+
227
+ For example:
228
+
229
+ ${code`
230
+ <WithEditorActions
231
+
232
+ render={actions => (
233
+ <TitleInput
234
+ placeholder="Give this page a title..."
235
+ onKeyDown={(e: KeyboardEvent) =>
236
+ this.onKeyPressed(e, actions)
237
+ }
238
+ />
239
+ )}
240
+ />
241
+ `}
242
+
243
+ ${code`
244
+ private onKeyPressed = (e: KeyboardEvent, actions: EditorActions) => {
245
+ if (e.key === 'Tab' && !e.shiftKey) {
246
+ actions.focus();
247
+ return false;
248
+ }
249
+ };
250
+ `}
251
+
252
+ ${(
253
+ <Example
254
+ packageName="@atlaskit/editor-core"
255
+ Component={require('../examples/1-basic').default}
256
+ title="Basic"
257
+ source={require('!!raw-loader!../examples/1-basic')}
258
+ />
259
+ )}
260
+
261
+ ${(
262
+ <Props
263
+ shouldCollapseProps
264
+ heading="Props"
265
+ props={require('!!extract-react-types-loader!../src/editor')}
266
+ />
267
+ )}
268
+ `;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "191.0.9",
3
+ "version": "191.1.3",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },
8
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
8
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
9
9
  "author": "Atlassian Pty Ltd",
10
10
  "license": "Apache-2.0",
11
11
  "main": "dist/cjs/index.js",
@@ -45,14 +45,13 @@
45
45
  "@atlaskit/analytics-namespaced-context": "^6.9.0",
46
46
  "@atlaskit/analytics-next": "^9.1.0",
47
47
  "@atlaskit/analytics-next-stable-react-context": "1.0.1",
48
- "@atlaskit/avatar": "^21.4.0",
49
- "@atlaskit/avatar-group": "^9.5.0",
50
48
  "@atlaskit/button": "^17.2.0",
51
49
  "@atlaskit/editor-common": "^76.39.0",
52
50
  "@atlaskit/editor-json-transformer": "^8.10.0",
53
51
  "@atlaskit/editor-plugin-alignment": "^0.1.0",
54
52
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
55
53
  "@atlaskit/editor-plugin-annotation": "^0.1.0",
54
+ "@atlaskit/editor-plugin-avatar-group": "^0.1.0",
56
55
  "@atlaskit/editor-plugin-base": "^0.3.0",
57
56
  "@atlaskit/editor-plugin-before-primary-toolbar": "^0.1.0",
58
57
  "@atlaskit/editor-plugin-better-type-history": "^0.1.0",
@@ -125,7 +124,7 @@
125
124
  "@atlaskit/emoji": "^67.6.0",
126
125
  "@atlaskit/icon": "^22.0.0",
127
126
  "@atlaskit/logo": "^13.15.0",
128
- "@atlaskit/media-card": "^77.6.0",
127
+ "@atlaskit/media-card": "^77.7.0",
129
128
  "@atlaskit/mention": "^22.1.0",
130
129
  "@atlaskit/platform-feature-flags": "^0.2.0",
131
130
  "@atlaskit/spinner": "^16.0.0",
@@ -160,9 +159,10 @@
160
159
  "@af/visual-regression": "*",
161
160
  "@atlaskit/adf-utils": "^19.0.0",
162
161
  "@atlaskit/analytics-listeners": "^8.9.0",
162
+ "@atlaskit/avatar": "^21.4.0",
163
163
  "@atlaskit/checkbox": "^13.0.0",
164
164
  "@atlaskit/code": "^15.1.0",
165
- "@atlaskit/collab-provider": "9.21.2",
165
+ "@atlaskit/collab-provider": "9.21.3",
166
166
  "@atlaskit/dropdown-menu": "^12.1.0",
167
167
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
168
168
  "@atlaskit/editor-palette": "1.5.2",
@@ -184,7 +184,7 @@
184
184
  "@atlaskit/visual-regression": "*",
185
185
  "@atlassian/adf-schema-json": "^1.0.7",
186
186
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
187
- "@atlassian/editor-extension-link-create": "^1.1.0",
187
+ "@atlassian/editor-extension-link-create": "^1.2.0",
188
188
  "@atlassian/feature-flags-test-utils": "^0.1.1",
189
189
  "@atlassian/link-picker-plugins": "^24.0.0",
190
190
  "@atlassian/search-provider": "2.4.11",
@@ -1,40 +0,0 @@
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 _AvatarGroupPluginWrapper = _interopRequireDefault(require("./ui/AvatarGroupPluginWrapper"));
10
- var avatarGroup = function avatarGroup(_ref) {
11
- var _api$featureFlags;
12
- var props = _ref.config,
13
- api = _ref.api;
14
- var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
15
- return {
16
- name: 'avatarGroup',
17
- primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
18
- var _api$analytics;
19
- var editorView = _ref2.editorView,
20
- popupsMountPoint = _ref2.popupsMountPoint,
21
- popupsBoundariesElement = _ref2.popupsBoundariesElement,
22
- popupsScrollableElement = _ref2.popupsScrollableElement,
23
- disabled = _ref2.disabled,
24
- isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
25
- eventDispatcher = _ref2.eventDispatcher,
26
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
27
- return /*#__PURE__*/_react.default.createElement(_AvatarGroupPluginWrapper.default, {
28
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
29
- editorView: editorView,
30
- eventDispatcher: eventDispatcher,
31
- collabEdit: props === null || props === void 0 ? void 0 : props.collabEdit,
32
- takeFullWidth: props === null || props === void 0 ? void 0 : props.takeFullWidth,
33
- featureFlags: featureFlags,
34
- editorAnalyticsAPI: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions,
35
- editorAPI: api
36
- });
37
- }
38
- };
39
- };
40
- var _default = exports.default = avatarGroup;
@@ -1,14 +0,0 @@
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
- });
@@ -1,49 +0,0 @@
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 _avatarsWithPluginState = _interopRequireDefault(require("./avatars-with-plugin-state"));
12
- var _reactIntlNext = require("react-intl-next");
13
- var _messages = require("../messages");
14
- var _analytics = require("@atlaskit/editor-common/analytics");
15
- var _templateObject, _templateObject2;
16
- /** @jsx jsx */
17
- 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"])));
18
- var toolbarButtonWrapperFullWidth = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n flex-grow: 1;\n"])), toolbarButtonWrapper);
19
- var AvatarGroupPluginWrapper = function AvatarGroupPluginWrapper(props) {
20
- var dispatchAnalyticsEvent = props.dispatchAnalyticsEvent,
21
- featureFlags = props.featureFlags;
22
- var intl = (0, _reactIntlNext.useIntl)();
23
- (0, _react.useEffect)(function () {
24
- if (!dispatchAnalyticsEvent) {
25
- return;
26
- }
27
- dispatchAnalyticsEvent({
28
- action: _analytics.ACTION.VIEWED,
29
- actionSubject: _analytics.ACTION_SUBJECT.BUTTON,
30
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.AVATAR_GROUP_PLUGIN,
31
- eventType: _analytics.EVENT_TYPE.UI
32
- });
33
- }, [dispatchAnalyticsEvent]);
34
- return (0, _react2.jsx)("div", {
35
- "aria-label": intl.formatMessage(_messages.avatarGroupMessages.editors),
36
- "data-testid": 'avatar-group-in-plugin',
37
- css: props.takeFullWidth ? toolbarButtonWrapperFullWidth : toolbarButtonWrapper
38
- }, (0, _react2.jsx)(_avatarsWithPluginState.default, {
39
- editorView: props.editorView,
40
- eventDispatcher: props.eventDispatcher,
41
- inviteToEditComponent: props.collabEdit && props.collabEdit.inviteToEditComponent,
42
- inviteToEditHandler: props.collabEdit && props.collabEdit.inviteToEditHandler,
43
- isInviteToEditButtonSelected: props.collabEdit && props.collabEdit.isInviteToEditButtonSelected,
44
- featureFlags: featureFlags,
45
- editorAnalyticsAPI: props.editorAnalyticsAPI,
46
- editorAPI: props.editorAPI
47
- }));
48
- };
49
- var _default = exports.default = AvatarGroupPluginWrapper;
@@ -1,42 +0,0 @@
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 _messages = _interopRequireDefault(require("../../../messages"));
11
- var _avatars = require("./avatars");
12
- var _inviteToEdit = require("./invite-to-edit");
13
- var _hooks = require("@atlaskit/editor-common/hooks");
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);
@@ -1,70 +0,0 @@
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 _state = require("@atlaskit/editor-prosemirror/state");
12
- var _styles = require("./styles");
13
- var _toAvatar = _interopRequireDefault(require("./to-avatar"));
14
- var _analytics2 = require("@atlaskit/editor-common/analytics");
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 (0, _react2.jsx)("div", {
52
- css: _styles.avatarContainer
53
- }, (0, _react2.jsx)(_avatarGroup.default, {
54
- appearance: "stack",
55
- size: "medium",
56
- data: avatars,
57
- maxCount: 3,
58
- onAvatarClick: function onAvatarClick(_event, _analytics, index) {
59
- if (!editorView) {
60
- return;
61
- }
62
- var allowCollabAvatarScroll = featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.collabAvatarScroll;
63
-
64
- // user does not need to scroll to their own position (index 0)
65
- if (allowCollabAvatarScroll && index > 0) {
66
- scrollToCollabCursor(editorView, participants, props.sessionId, index, props.editorAnalyticsAPI);
67
- }
68
- }
69
- }), props.children);
70
- });
@@ -1,20 +0,0 @@
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 _styles = require("./styles");
9
- var _colors = require("@atlaskit/theme/colors");
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 (0, _react.jsx)("div", {
17
- css: (0, _styles.badge)(color || _colors.R100),
18
- "data-testid": "editor-collab-badge"
19
- }, avatar);
20
- };
@@ -1,9 +0,0 @@
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 _avatarsWithPluginState = _interopRequireDefault(require("./avatars-with-plugin-state"));
9
- var _default = exports.default = _avatarsWithPluginState.default;
@@ -1,45 +0,0 @@
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 _add = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/add"));
12
- var _ToolbarButton = _interopRequireDefault(require("../../../ui/ToolbarButton"));
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 (0, _react2.jsx)("div", {
36
- css: _styles.inviteTeamWrapper
37
- }, (0, _react2.jsx)(Wrapper, null, (0, _react2.jsx)(_ToolbarButton.default, {
38
- className: "invite-to-edit",
39
- onClick: onClick,
40
- selected: selected,
41
- title: title,
42
- titlePosition: "bottom",
43
- iconBefore: iconBefore
44
- })));
45
- };
@@ -1,17 +0,0 @@
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 _colors = require("@atlaskit/theme/colors");
11
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
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
- };
@@ -1,30 +0,0 @@
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
- });