@atlaskit/editor-plugin-mentions 4.4.1 → 4.4.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,14 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 4.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#143385](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/143385)
8
+ [`8c63cbda9b29f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c63cbda9b29f) -
9
+ Fix initial position of mention profile card popup.
10
+ - Updated dependencies
11
+
3
12
  ## 4.4.1
4
13
 
5
14
  ### Patch Changes
@@ -26,7 +26,7 @@ var ACTIONS = exports.ACTIONS = {
26
26
  SET_PROVIDER: 'SET_PROVIDER'
27
27
  };
28
28
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
29
- var PACKAGE_VERSION = "4.4.1";
29
+ var PACKAGE_VERSION = "4.4.2";
30
30
  var setProvider = function setProvider(provider) {
31
31
  return function (state, dispatch) {
32
32
  if (dispatch) {
@@ -1,15 +1,37 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.Popup = Popup;
9
+ exports.RepositionOnUpdate = void 0;
8
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
10
12
  var _popper = require("@atlaskit/popper");
11
13
  var _portal = _interopRequireDefault(require("@atlaskit/portal"));
14
+ var _constants = require("@atlaskit/theme/constants");
12
15
  var _useFocusTrap = require("./useFocusTrap");
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
+ // From `packages/design-system/popup/src/reposition-on-update.tsx`
19
+ var RepositionOnUpdate = exports.RepositionOnUpdate = function RepositionOnUpdate(_ref) {
20
+ var children = _ref.children,
21
+ update = _ref.update;
22
+ // Ref used here to skip update on first render (when refs haven't been set)
23
+ var isFirstRenderRef = (0, _react.useRef)(true);
24
+ (0, _react.useEffect)(function () {
25
+ if (isFirstRenderRef.current) {
26
+ isFirstRenderRef.current = false;
27
+ return;
28
+ }
29
+ // callback function from popper that repositions pop-up on content Update
30
+ update();
31
+ }, [update, children]);
32
+ return children;
33
+ };
34
+
13
35
  /**
14
36
  * A popup wrapper to match the behaviour of `@atlaskit/popup`
15
37
  *
@@ -21,9 +43,9 @@ var _useFocusTrap = require("./useFocusTrap");
21
43
  * @param children React.ReactNode - Returns the element to be positioned.
22
44
  * @returns React popper component
23
45
  */
24
- function Popup(_ref) {
25
- var referenceElement = _ref.referenceElement,
26
- children = _ref.children;
46
+ function Popup(_ref2) {
47
+ var referenceElement = _ref2.referenceElement,
48
+ children = _ref2.children;
27
49
  var _React$useState = _react.default.useState(null),
28
50
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
29
51
  targetRef = _React$useState2[0],
@@ -31,21 +53,24 @@ function Popup(_ref) {
31
53
  (0, _useFocusTrap.useFocusTrap)({
32
54
  targetRef: targetRef
33
55
  });
34
- return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
56
+ return /*#__PURE__*/_react.default.createElement(_portal.default, {
57
+ zIndex: _constants.layers.modal()
58
+ }, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
35
59
  referenceElement: referenceElement,
36
60
  offset: [0, 8],
37
61
  placement: "bottom-end",
38
62
  strategy: "fixed"
39
- }, function (_ref2) {
40
- var _ref3 = _ref2.ref,
41
- style = _ref2.style;
63
+ }, function (_ref3) {
64
+ var _ref4 = _ref3.ref,
65
+ style = _ref3.style,
66
+ update = _ref3.update;
42
67
  return /*#__PURE__*/_react.default.createElement("div", {
43
68
  ref: function ref(node) {
44
69
  if (node) {
45
- if (typeof _ref3 === 'function') {
46
- _ref3(node);
70
+ if (typeof _ref4 === 'function') {
71
+ _ref4(node);
47
72
  } else {
48
- _ref3.current = node;
73
+ _ref4.current = node;
49
74
  }
50
75
  setPopupRef(node);
51
76
  }
@@ -53,6 +78,8 @@ function Popup(_ref) {
53
78
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
54
79
  ,
55
80
  style: style
56
- }, children);
81
+ }, /*#__PURE__*/_react.default.createElement(RepositionOnUpdate, {
82
+ update: update
83
+ }, children));
57
84
  }));
58
85
  }
@@ -164,10 +164,6 @@ function ProfileCardComponent(_ref4) {
164
164
  }
165
165
  });
166
166
  });
167
- if (!provider || !activeMention) {
168
- return null;
169
- }
170
- var cloudId = provider.cloudId;
171
167
  return /*#__PURE__*/React.createElement(_PopperWrapper.Popup, {
172
168
  referenceElement: dom
173
169
  }, /*#__PURE__*/React.createElement(LoadingWrapper, {
@@ -182,7 +178,7 @@ function ProfileCardComponent(_ref4) {
182
178
  isBot: data === null || data === void 0 ? void 0 : data.isBot,
183
179
  fullName: data === null || data === void 0 ? void 0 : data.fullName,
184
180
  userId: id,
185
- cloudId: cloudId,
181
+ cloudId: provider === null || provider === void 0 ? void 0 : provider.cloudId,
186
182
  actions: actions,
187
183
  isLoading: isLoading,
188
184
  location: data === null || data === void 0 ? void 0 : data.location,
@@ -15,7 +15,7 @@ export const ACTIONS = {
15
15
  SET_PROVIDER: 'SET_PROVIDER'
16
16
  };
17
17
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
18
- const PACKAGE_VERSION = "4.4.1";
18
+ const PACKAGE_VERSION = "4.4.2";
19
19
  const setProvider = provider => (state, dispatch) => {
20
20
  if (dispatch) {
21
21
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -1,7 +1,26 @@
1
- import React from 'react';
1
+ import React, { useRef, useEffect } from 'react';
2
2
  import { Popper as ReactPopper } from '@atlaskit/popper';
3
3
  import Portal from '@atlaskit/portal';
4
+ import { layers } from '@atlaskit/theme/constants';
4
5
  import { useFocusTrap } from './useFocusTrap';
6
+ // From `packages/design-system/popup/src/reposition-on-update.tsx`
7
+ export const RepositionOnUpdate = ({
8
+ children,
9
+ update
10
+ }) => {
11
+ // Ref used here to skip update on first render (when refs haven't been set)
12
+ const isFirstRenderRef = useRef(true);
13
+ useEffect(() => {
14
+ if (isFirstRenderRef.current) {
15
+ isFirstRenderRef.current = false;
16
+ return;
17
+ }
18
+ // callback function from popper that repositions pop-up on content Update
19
+ update();
20
+ }, [update, children]);
21
+ return children;
22
+ };
23
+
5
24
  /**
6
25
  * A popup wrapper to match the behaviour of `@atlaskit/popup`
7
26
  *
@@ -21,14 +40,17 @@ export function Popup({
21
40
  useFocusTrap({
22
41
  targetRef: targetRef
23
42
  });
24
- return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ReactPopper, {
43
+ return /*#__PURE__*/React.createElement(Portal, {
44
+ zIndex: layers.modal()
45
+ }, /*#__PURE__*/React.createElement(ReactPopper, {
25
46
  referenceElement: referenceElement,
26
47
  offset: [0, 8],
27
48
  placement: "bottom-end",
28
49
  strategy: "fixed"
29
50
  }, ({
30
51
  ref,
31
- style
52
+ style,
53
+ update
32
54
  }) => /*#__PURE__*/React.createElement("div", {
33
55
  ref: node => {
34
56
  if (node) {
@@ -43,5 +65,7 @@ export function Popup({
43
65
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
44
66
  ,
45
67
  style: style
46
- }, children)));
68
+ }, /*#__PURE__*/React.createElement(RepositionOnUpdate, {
69
+ update: update
70
+ }, children))));
47
71
  }
@@ -100,12 +100,6 @@ export function ProfileCardComponent({
100
100
  }
101
101
  });
102
102
  });
103
- if (!provider || !activeMention) {
104
- return null;
105
- }
106
- const {
107
- cloudId
108
- } = provider;
109
103
  return /*#__PURE__*/React.createElement(Popup, {
110
104
  referenceElement: dom
111
105
  }, /*#__PURE__*/React.createElement(LoadingWrapper, {
@@ -120,7 +114,7 @@ export function ProfileCardComponent({
120
114
  isBot: data === null || data === void 0 ? void 0 : data.isBot,
121
115
  fullName: data === null || data === void 0 ? void 0 : data.fullName,
122
116
  userId: id,
123
- cloudId: cloudId,
117
+ cloudId: provider === null || provider === void 0 ? void 0 : provider.cloudId,
124
118
  actions: actions,
125
119
  isLoading: isLoading,
126
120
  location: data === null || data === void 0 ? void 0 : data.location,
@@ -18,7 +18,7 @@ export var ACTIONS = {
18
18
  SET_PROVIDER: 'SET_PROVIDER'
19
19
  };
20
20
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
21
- var PACKAGE_VERSION = "4.4.1";
21
+ var PACKAGE_VERSION = "4.4.2";
22
22
  var setProvider = function setProvider(provider) {
23
23
  return function (state, dispatch) {
24
24
  if (dispatch) {
@@ -1,8 +1,26 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React from 'react';
2
+ import React, { useRef, useEffect } from 'react';
3
3
  import { Popper as ReactPopper } from '@atlaskit/popper';
4
4
  import Portal from '@atlaskit/portal';
5
+ import { layers } from '@atlaskit/theme/constants';
5
6
  import { useFocusTrap } from './useFocusTrap';
7
+ // From `packages/design-system/popup/src/reposition-on-update.tsx`
8
+ export var RepositionOnUpdate = function RepositionOnUpdate(_ref) {
9
+ var children = _ref.children,
10
+ update = _ref.update;
11
+ // Ref used here to skip update on first render (when refs haven't been set)
12
+ var isFirstRenderRef = useRef(true);
13
+ useEffect(function () {
14
+ if (isFirstRenderRef.current) {
15
+ isFirstRenderRef.current = false;
16
+ return;
17
+ }
18
+ // callback function from popper that repositions pop-up on content Update
19
+ update();
20
+ }, [update, children]);
21
+ return children;
22
+ };
23
+
6
24
  /**
7
25
  * A popup wrapper to match the behaviour of `@atlaskit/popup`
8
26
  *
@@ -14,9 +32,9 @@ import { useFocusTrap } from './useFocusTrap';
14
32
  * @param children React.ReactNode - Returns the element to be positioned.
15
33
  * @returns React popper component
16
34
  */
17
- export function Popup(_ref) {
18
- var referenceElement = _ref.referenceElement,
19
- children = _ref.children;
35
+ export function Popup(_ref2) {
36
+ var referenceElement = _ref2.referenceElement,
37
+ children = _ref2.children;
20
38
  var _React$useState = React.useState(null),
21
39
  _React$useState2 = _slicedToArray(_React$useState, 2),
22
40
  targetRef = _React$useState2[0],
@@ -24,21 +42,24 @@ export function Popup(_ref) {
24
42
  useFocusTrap({
25
43
  targetRef: targetRef
26
44
  });
27
- return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ReactPopper, {
45
+ return /*#__PURE__*/React.createElement(Portal, {
46
+ zIndex: layers.modal()
47
+ }, /*#__PURE__*/React.createElement(ReactPopper, {
28
48
  referenceElement: referenceElement,
29
49
  offset: [0, 8],
30
50
  placement: "bottom-end",
31
51
  strategy: "fixed"
32
- }, function (_ref2) {
33
- var _ref3 = _ref2.ref,
34
- style = _ref2.style;
52
+ }, function (_ref3) {
53
+ var _ref4 = _ref3.ref,
54
+ style = _ref3.style,
55
+ update = _ref3.update;
35
56
  return /*#__PURE__*/React.createElement("div", {
36
57
  ref: function ref(node) {
37
58
  if (node) {
38
- if (typeof _ref3 === 'function') {
39
- _ref3(node);
59
+ if (typeof _ref4 === 'function') {
60
+ _ref4(node);
40
61
  } else {
41
- _ref3.current = node;
62
+ _ref4.current = node;
42
63
  }
43
64
  setPopupRef(node);
44
65
  }
@@ -46,6 +67,8 @@ export function Popup(_ref) {
46
67
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
47
68
  ,
48
69
  style: style
49
- }, children);
70
+ }, /*#__PURE__*/React.createElement(RepositionOnUpdate, {
71
+ update: update
72
+ }, children));
50
73
  }));
51
74
  }
@@ -153,10 +153,6 @@ export function ProfileCardComponent(_ref4) {
153
153
  }
154
154
  });
155
155
  });
156
- if (!provider || !activeMention) {
157
- return null;
158
- }
159
- var cloudId = provider.cloudId;
160
156
  return /*#__PURE__*/React.createElement(Popup, {
161
157
  referenceElement: dom
162
158
  }, /*#__PURE__*/React.createElement(LoadingWrapper, {
@@ -171,7 +167,7 @@ export function ProfileCardComponent(_ref4) {
171
167
  isBot: data === null || data === void 0 ? void 0 : data.isBot,
172
168
  fullName: data === null || data === void 0 ? void 0 : data.fullName,
173
169
  userId: id,
174
- cloudId: cloudId,
170
+ cloudId: provider === null || provider === void 0 ? void 0 : provider.cloudId,
175
171
  actions: actions,
176
172
  isLoading: isLoading,
177
173
  location: data === null || data === void 0 ? void 0 : data.location,
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import { type PopperChildrenProps } from '@atlaskit/popper';
2
3
  interface Props {
3
4
  /**
4
5
  * Replacement reference element to position popper relative to.
@@ -9,6 +10,9 @@ interface Props {
9
10
  */
10
11
  children: React.ReactNode;
11
12
  }
13
+ export declare const RepositionOnUpdate: ({ children, update, }: React.PropsWithChildren<{
14
+ update: PopperChildrenProps['update'];
15
+ }>) => React.ReactNode;
12
16
  /**
13
17
  * A popup wrapper to match the behaviour of `@atlaskit/popup`
14
18
  *
@@ -19,5 +19,5 @@ export declare function ProfileCardComponent({ profilecardProvider, activeMentio
19
19
  activeMention: PMNode;
20
20
  dom: HTMLElement;
21
21
  closeComponent: () => void;
22
- }): JSX.Element | null;
22
+ }): JSX.Element;
23
23
  export {};
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import React, { type PropsWithChildren } from 'react';
2
+ import { type PopperChildrenProps } from '@atlaskit/popper';
2
3
  interface Props {
3
4
  /**
4
5
  * Replacement reference element to position popper relative to.
@@ -9,6 +10,9 @@ interface Props {
9
10
  */
10
11
  children: React.ReactNode;
11
12
  }
13
+ export declare const RepositionOnUpdate: ({ children, update, }: React.PropsWithChildren<{
14
+ update: PopperChildrenProps['update'];
15
+ }>) => React.ReactNode;
12
16
  /**
13
17
  * A popup wrapper to match the behaviour of `@atlaskit/popup`
14
18
  *
@@ -19,5 +19,5 @@ export declare function ProfileCardComponent({ profilecardProvider, activeMentio
19
19
  activeMention: PMNode;
20
20
  dom: HTMLElement;
21
21
  closeComponent: () => void;
22
- }): JSX.Element | null;
22
+ }): JSX.Element;
23
23
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,22 +35,22 @@
35
35
  "dependencies": {
36
36
  "@atlaskit/adf-schema": "^47.6.0",
37
37
  "@atlaskit/css": "^0.10.0",
38
- "@atlaskit/editor-common": "^103.6.0",
38
+ "@atlaskit/editor-common": "^103.10.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-base": "^2.3.0",
41
41
  "@atlaskit/editor-plugin-context-identifier": "^2.1.0",
42
42
  "@atlaskit/editor-plugin-selection": "^2.1.0",
43
- "@atlaskit/editor-plugin-type-ahead": "^2.4.0",
43
+ "@atlaskit/editor-plugin-type-ahead": "^2.5.0",
44
44
  "@atlaskit/editor-prosemirror": "7.0.0",
45
45
  "@atlaskit/icon": "^25.6.0",
46
46
  "@atlaskit/mention": "^24.1.0",
47
47
  "@atlaskit/platform-feature-flags": "^1.1.0",
48
48
  "@atlaskit/popper": "^7.0.0",
49
49
  "@atlaskit/portal": "^5.1.0",
50
- "@atlaskit/profilecard": "^23.7.0",
50
+ "@atlaskit/profilecard": "^23.8.0",
51
51
  "@atlaskit/theme": "^18.0.0",
52
- "@atlaskit/tmp-editor-statsig": "^4.8.0",
53
- "@atlaskit/tokens": "^4.7.0",
52
+ "@atlaskit/tmp-editor-statsig": "^4.12.0",
53
+ "@atlaskit/tokens": "^4.8.0",
54
54
  "@babel/runtime": "^7.0.0",
55
55
  "@compiled/react": "^0.18.3",
56
56
  "bind-event-listener": "^3.0.0",