@atlaskit/editor-plugin-avatar-group 3.1.0 → 3.1.2

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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-avatar-group
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#145138](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145138)
8
+ [`0ba0ff24c0e33`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0ba0ff24c0e33) -
9
+ Enable useSharedPluginStateSelector in accessibility, alignment, annotation and avatar-group
10
+ plugins
11
+ - Updated dependencies
12
+
13
+ ## 3.1.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#145269](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145269)
18
+ [`737139c963111`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/737139c963111) -
19
+ [ux] Introduces an early-return guard inside `Avatars` that exits when `participants` is
20
+ null/undefined. Behind fg platform_editor_avatars_sort_error_fix. Prevents the runtime crash
21
+ `cannot read properties of undefined (reading sort)` observed while presence data is still
22
+ loading. For HOT-116939.
23
+ - Updated dependencies
24
+
3
25
  ## 3.1.0
4
26
 
5
27
  ### Minor Changes
@@ -9,6 +9,8 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
11
  var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
12
+ var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
13
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
14
  var _avatars = require("./avatars");
13
15
  var _inviteToEdit = require("./invite-to-edit");
14
16
  var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
@@ -20,14 +22,34 @@ var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
20
22
  featureFlags = props.featureFlags,
21
23
  editorAnalyticsAPI = props.editorAnalyticsAPI,
22
24
  editorAPI = props.editorAPI;
23
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(editorAPI, ['collabEdit']),
25
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(editorAPI, ['collabEdit'], {
26
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)
27
+ }),
24
28
  collabEditState = _useSharedPluginState.collabEditState;
25
- if (!collabEditState) {
29
+
30
+ // sessionId
31
+ var sessionIdSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'collabEdit.sessionId', {
32
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
33
+ });
34
+ var sessionId = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? sessionIdSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.sessionId;
35
+
36
+ // activeParticipants
37
+ var activeParticipantsSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'collabEdit.activeParticipants', {
38
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
39
+ });
40
+ var activeParticipants = (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true) ? activeParticipantsSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.activeParticipants;
41
+ var initialised = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(editorAPI, 'collabEdit.initialised', {
42
+ disabled: (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)
43
+ });
44
+ if (!collabEditState && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
45
+ return null;
46
+ }
47
+ if (!initialised && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', true)) {
26
48
  return null;
27
49
  }
28
50
  return /*#__PURE__*/_react.default.createElement(_avatars.Avatars, {
29
- sessionId: collabEditState.sessionId,
30
- participants: collabEditState.activeParticipants,
51
+ sessionId: sessionId,
52
+ participants: activeParticipants,
31
53
  editorView: editorView,
32
54
  featureFlags: featureFlags,
33
55
  editorAnalyticsAPI: editorAnalyticsAPI,
@@ -10,6 +10,7 @@ var _react2 = require("@emotion/react");
10
10
  var _avatarGroup = _interopRequireDefault(require("@atlaskit/avatar-group"));
11
11
  var _analytics2 = require("@atlaskit/editor-common/analytics");
12
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _styles = require("./styles");
14
15
  var _toAvatar = _interopRequireDefault(require("./to-avatar"));
15
16
  /**
@@ -45,6 +46,11 @@ var Avatars = exports.Avatars = /*#__PURE__*/_react.default.memo(function (props
45
46
  featureFlags = props.featureFlags,
46
47
  editorAPI = props.editorAPI;
47
48
  var participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
49
+ if ((0, _platformFeatureFlags.fg)('platform_editor_avatars_sort_error_fix')) {
50
+ if (!participants) {
51
+ return null;
52
+ }
53
+ }
48
54
  var avatars = participants.sort(function (p) {
49
55
  return p.sessionId === sessionId ? -1 : 1;
50
56
  }).map(function (participant) {
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { injectIntl } from 'react-intl-next';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import messages from '@atlaskit/editor-common/messages';
5
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
7
  import { Avatars } from './avatars';
6
8
  import { InviteToEditButton } from './invite-to-edit';
7
9
  const AvatarsWithPluginState = props => {
@@ -17,13 +19,33 @@ const AvatarsWithPluginState = props => {
17
19
  } = props;
18
20
  const {
19
21
  collabEditState
20
- } = useSharedPluginState(editorAPI, ['collabEdit']);
21
- if (!collabEditState) {
22
+ } = useSharedPluginState(editorAPI, ['collabEdit'], {
23
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
24
+ });
25
+
26
+ // sessionId
27
+ const sessionIdSelector = useSharedPluginStateSelector(editorAPI, 'collabEdit.sessionId', {
28
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
29
+ });
30
+ const sessionId = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? sessionIdSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.sessionId;
31
+
32
+ // activeParticipants
33
+ const activeParticipantsSelector = useSharedPluginStateSelector(editorAPI, 'collabEdit.activeParticipants', {
34
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
35
+ });
36
+ const activeParticipants = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? activeParticipantsSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.activeParticipants;
37
+ const initialised = useSharedPluginStateSelector(editorAPI, 'collabEdit.initialised', {
38
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
39
+ });
40
+ if (!collabEditState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
41
+ return null;
42
+ }
43
+ if (!initialised && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
22
44
  return null;
23
45
  }
24
46
  return /*#__PURE__*/React.createElement(Avatars, {
25
- sessionId: collabEditState.sessionId,
26
- participants: collabEditState.activeParticipants,
47
+ sessionId: sessionId,
48
+ participants: activeParticipants,
27
49
  editorView: editorView,
28
50
  featureFlags: featureFlags,
29
51
  editorAnalyticsAPI: editorAnalyticsAPI,
@@ -10,6 +10,7 @@ import { jsx } from '@emotion/react';
10
10
  import AvatarGroup from '@atlaskit/avatar-group';
11
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
12
12
  import { Selection } from '@atlaskit/editor-prosemirror/state';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { avatarContainerStyles } from './styles';
14
15
  import toAvatar from './to-avatar';
15
16
  export const scrollToCollabCursor = (editorAPI, participants, sessionId, index, editorAnalyticsAPI) => {
@@ -41,6 +42,11 @@ export const Avatars = /*#__PURE__*/React.memo(props => {
41
42
  editorAPI
42
43
  } = props;
43
44
  const participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
45
+ if (fg('platform_editor_avatars_sort_error_fix')) {
46
+ if (!participants) {
47
+ return null;
48
+ }
49
+ }
44
50
  const avatars = participants.sort(p => p.sessionId === sessionId ? -1 : 1).map(participant => toAvatar(participant, editorAPI));
45
51
  if (!avatars.length) {
46
52
  return null;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { injectIntl } from 'react-intl-next';
3
3
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
4
4
  import messages from '@atlaskit/editor-common/messages';
5
+ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
7
  import { Avatars } from './avatars';
6
8
  import { InviteToEditButton } from './invite-to-edit';
7
9
  var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
@@ -13,14 +15,34 @@ var AvatarsWithPluginState = function AvatarsWithPluginState(props) {
13
15
  featureFlags = props.featureFlags,
14
16
  editorAnalyticsAPI = props.editorAnalyticsAPI,
15
17
  editorAPI = props.editorAPI;
16
- var _useSharedPluginState = useSharedPluginState(editorAPI, ['collabEdit']),
18
+ var _useSharedPluginState = useSharedPluginState(editorAPI, ['collabEdit'], {
19
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', true)
20
+ }),
17
21
  collabEditState = _useSharedPluginState.collabEditState;
18
- if (!collabEditState) {
22
+
23
+ // sessionId
24
+ var sessionIdSelector = useSharedPluginStateSelector(editorAPI, 'collabEdit.sessionId', {
25
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
26
+ });
27
+ var sessionId = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? sessionIdSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.sessionId;
28
+
29
+ // activeParticipants
30
+ var activeParticipantsSelector = useSharedPluginStateSelector(editorAPI, 'collabEdit.activeParticipants', {
31
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
32
+ });
33
+ var activeParticipants = editorExperiment('platform_editor_usesharedpluginstateselector', true) ? activeParticipantsSelector : collabEditState === null || collabEditState === void 0 ? void 0 : collabEditState.activeParticipants;
34
+ var initialised = useSharedPluginStateSelector(editorAPI, 'collabEdit.initialised', {
35
+ disabled: editorExperiment('platform_editor_usesharedpluginstateselector', false)
36
+ });
37
+ if (!collabEditState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
38
+ return null;
39
+ }
40
+ if (!initialised && editorExperiment('platform_editor_usesharedpluginstateselector', true)) {
19
41
  return null;
20
42
  }
21
43
  return /*#__PURE__*/React.createElement(Avatars, {
22
- sessionId: collabEditState.sessionId,
23
- participants: collabEditState.activeParticipants,
44
+ sessionId: sessionId,
45
+ participants: activeParticipants,
24
46
  editorView: editorView,
25
47
  featureFlags: featureFlags,
26
48
  editorAnalyticsAPI: editorAnalyticsAPI,
@@ -10,6 +10,7 @@ import { jsx } from '@emotion/react';
10
10
  import AvatarGroup from '@atlaskit/avatar-group';
11
11
  import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
12
12
  import { Selection } from '@atlaskit/editor-prosemirror/state';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { avatarContainerStyles } from './styles';
14
15
  import toAvatar from './to-avatar';
15
16
  export var scrollToCollabCursor = function scrollToCollabCursor(editorAPI, participants, sessionId, index, editorAnalyticsAPI) {
@@ -38,6 +39,11 @@ export var Avatars = /*#__PURE__*/React.memo(function (props) {
38
39
  featureFlags = props.featureFlags,
39
40
  editorAPI = props.editorAPI;
40
41
  var participants = (_props$participants = props.participants) === null || _props$participants === void 0 ? void 0 : _props$participants.toArray();
42
+ if (fg('platform_editor_avatars_sort_error_fix')) {
43
+ if (!participants) {
44
+ return null;
45
+ }
46
+ }
41
47
  var avatars = participants.sort(function (p) {
42
48
  return p.sessionId === sessionId ? -1 : 1;
43
49
  }).map(function (participant) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-avatar-group",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Avatar Group plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,16 +37,18 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@atlaskit/avatar-group": "^12.0.0",
40
- "@atlaskit/editor-common": "^103.4.0",
40
+ "@atlaskit/editor-common": "^103.18.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
42
42
  "@atlaskit/editor-plugin-collab-edit": "^3.4.0",
43
43
  "@atlaskit/editor-plugin-feature-flags": "^1.4.0",
44
44
  "@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
45
45
  "@atlaskit/editor-prosemirror": "7.0.0",
46
46
  "@atlaskit/editor-shared-styles": "^3.4.0",
47
- "@atlaskit/icon": "^25.5.0",
47
+ "@atlaskit/icon": "^25.6.0",
48
+ "@atlaskit/platform-feature-flags": "^1.1.0",
48
49
  "@atlaskit/theme": "^18.0.0",
49
- "@atlaskit/tokens": "^4.7.0",
50
+ "@atlaskit/tmp-editor-statsig": "^4.14.0",
51
+ "@atlaskit/tokens": "^4.8.0",
50
52
  "@babel/runtime": "^7.0.0",
51
53
  "@emotion/react": "^11.7.1",
52
54
  "memoize-one": "^6.0.0",
@@ -98,5 +100,10 @@
98
100
  "no-unused-dependencies": {
99
101
  "checkDevDependencies": true
100
102
  }
103
+ },
104
+ "platform-feature-flags": {
105
+ "platform_editor_avatars_sort_error_fix": {
106
+ "type": "boolean"
107
+ }
101
108
  }
102
109
  }