@atlaskit/editor-plugin-mentions 4.3.2 → 4.3.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 +9 -0
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/PopperWrapper.js +24 -8
- package/dist/cjs/ui/useFocusTrap.js +44 -0
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/PopperWrapper.js +18 -5
- package/dist/es2019/ui/useFocusTrap.js +37 -0
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/PopperWrapper.js +24 -8
- package/dist/esm/ui/useFocusTrap.js +36 -0
- package/dist/types/ui/useFocusTrap.d.ts +4 -0
- package/dist/types-ts4.5/ui/useFocusTrap.d.ts +4 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 4.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#138789](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/138789)
|
|
8
|
+
[`eeb167efe5e64`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/eeb167efe5e64) -
|
|
9
|
+
Setup focus trap for profile card provider in vanilla mention version
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 4.3.2
|
|
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.3.
|
|
29
|
+
var PACKAGE_VERSION = "4.3.3";
|
|
30
30
|
var setProvider = function setProvider(provider) {
|
|
31
31
|
return function (state, dispatch) {
|
|
32
32
|
if (dispatch) {
|
|
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.Popup = Popup;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _popper = require("@atlaskit/popper");
|
|
10
11
|
var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
12
|
+
var _useFocusTrap = require("./useFocusTrap");
|
|
11
13
|
/**
|
|
12
14
|
* A popup wrapper to match the behaviour of `@atlaskit/popup`
|
|
13
15
|
*
|
|
@@ -22,21 +24,35 @@ var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
|
22
24
|
function Popup(_ref) {
|
|
23
25
|
var referenceElement = _ref.referenceElement,
|
|
24
26
|
children = _ref.children;
|
|
27
|
+
var _React$useState = _react.default.useState(null),
|
|
28
|
+
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
29
|
+
targetRef = _React$useState2[0],
|
|
30
|
+
setPopupRef = _React$useState2[1];
|
|
31
|
+
(0, _useFocusTrap.useFocusTrap)({
|
|
32
|
+
targetRef: targetRef
|
|
33
|
+
});
|
|
25
34
|
return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
|
|
26
35
|
referenceElement: referenceElement,
|
|
27
36
|
offset: [0, 8],
|
|
28
37
|
placement: "bottom-end",
|
|
29
38
|
strategy: "fixed"
|
|
30
39
|
}, function (_ref2) {
|
|
31
|
-
var
|
|
40
|
+
var _ref3 = _ref2.ref,
|
|
32
41
|
style = _ref2.style;
|
|
33
|
-
return (
|
|
34
|
-
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
ref: function ref(node) {
|
|
44
|
+
if (node) {
|
|
45
|
+
if (typeof _ref3 === 'function') {
|
|
46
|
+
_ref3(node);
|
|
47
|
+
} else {
|
|
48
|
+
_ref3.current = node;
|
|
49
|
+
}
|
|
50
|
+
setPopupRef(node);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, children)
|
|
40
|
-
);
|
|
54
|
+
,
|
|
55
|
+
style: style
|
|
56
|
+
}, children);
|
|
41
57
|
}));
|
|
42
58
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useFocusTrap = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _focusTrap = _interopRequireDefault(require("focus-trap"));
|
|
10
|
+
/**
|
|
11
|
+
* Custom hook to add focus trap
|
|
12
|
+
* used for focus trap in ReactionPicker
|
|
13
|
+
* copied from useFocusManager in @atlaskit/popup
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var useFocusTrap = exports.useFocusTrap = function useFocusTrap(_ref) {
|
|
17
|
+
var targetRef = _ref.targetRef;
|
|
18
|
+
(0, _react.useEffect)(function () {
|
|
19
|
+
if (!targetRef) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var trapConfig = {
|
|
23
|
+
clickOutsideDeactivates: true,
|
|
24
|
+
escapeDeactivates: true,
|
|
25
|
+
initialFocus: targetRef,
|
|
26
|
+
fallbackFocus: targetRef,
|
|
27
|
+
returnFocusOnDeactivate: true
|
|
28
|
+
};
|
|
29
|
+
var focusTrap = (0, _focusTrap.default)(targetRef, trapConfig);
|
|
30
|
+
|
|
31
|
+
// wait for the popup to reposition itself before we focus
|
|
32
|
+
var frameId = requestAnimationFrame(function () {
|
|
33
|
+
frameId = null;
|
|
34
|
+
focusTrap.activate();
|
|
35
|
+
});
|
|
36
|
+
return function () {
|
|
37
|
+
if (frameId !== null) {
|
|
38
|
+
cancelAnimationFrame(frameId);
|
|
39
|
+
frameId = null;
|
|
40
|
+
}
|
|
41
|
+
focusTrap.deactivate();
|
|
42
|
+
};
|
|
43
|
+
}, [targetRef]);
|
|
44
|
+
};
|
|
@@ -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.3.
|
|
18
|
+
const PACKAGE_VERSION = "4.3.3";
|
|
19
19
|
const setProvider = provider => (state, dispatch) => {
|
|
20
20
|
if (dispatch) {
|
|
21
21
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Popper as ReactPopper } from '@atlaskit/popper';
|
|
3
3
|
import Portal from '@atlaskit/portal';
|
|
4
|
+
import { useFocusTrap } from './useFocusTrap';
|
|
4
5
|
/**
|
|
5
6
|
* A popup wrapper to match the behaviour of `@atlaskit/popup`
|
|
6
7
|
*
|
|
@@ -16,6 +17,10 @@ export function Popup({
|
|
|
16
17
|
referenceElement,
|
|
17
18
|
children
|
|
18
19
|
}) {
|
|
20
|
+
const [targetRef, setPopupRef] = React.useState(null);
|
|
21
|
+
useFocusTrap({
|
|
22
|
+
targetRef: targetRef
|
|
23
|
+
});
|
|
19
24
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ReactPopper, {
|
|
20
25
|
referenceElement: referenceElement,
|
|
21
26
|
offset: [0, 8],
|
|
@@ -24,11 +29,19 @@ export function Popup({
|
|
|
24
29
|
}, ({
|
|
25
30
|
ref,
|
|
26
31
|
style
|
|
27
|
-
}) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
}) => /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
ref: node => {
|
|
34
|
+
if (node) {
|
|
35
|
+
if (typeof ref === 'function') {
|
|
36
|
+
ref(node);
|
|
37
|
+
} else {
|
|
38
|
+
ref.current = node;
|
|
39
|
+
}
|
|
40
|
+
setPopupRef(node);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
44
|
+
,
|
|
32
45
|
style: style
|
|
33
46
|
}, children)));
|
|
34
47
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to add focus trap
|
|
3
|
+
* used for focus trap in ReactionPicker
|
|
4
|
+
* copied from useFocusManager in @atlaskit/popup
|
|
5
|
+
*/
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
import createFocusTrap from 'focus-trap';
|
|
8
|
+
export const useFocusTrap = ({
|
|
9
|
+
targetRef
|
|
10
|
+
}) => {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!targetRef) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const trapConfig = {
|
|
16
|
+
clickOutsideDeactivates: true,
|
|
17
|
+
escapeDeactivates: true,
|
|
18
|
+
initialFocus: targetRef,
|
|
19
|
+
fallbackFocus: targetRef,
|
|
20
|
+
returnFocusOnDeactivate: true
|
|
21
|
+
};
|
|
22
|
+
const focusTrap = createFocusTrap(targetRef, trapConfig);
|
|
23
|
+
|
|
24
|
+
// wait for the popup to reposition itself before we focus
|
|
25
|
+
let frameId = requestAnimationFrame(() => {
|
|
26
|
+
frameId = null;
|
|
27
|
+
focusTrap.activate();
|
|
28
|
+
});
|
|
29
|
+
return () => {
|
|
30
|
+
if (frameId !== null) {
|
|
31
|
+
cancelAnimationFrame(frameId);
|
|
32
|
+
frameId = null;
|
|
33
|
+
}
|
|
34
|
+
focusTrap.deactivate();
|
|
35
|
+
};
|
|
36
|
+
}, [targetRef]);
|
|
37
|
+
};
|
|
@@ -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.3.
|
|
21
|
+
var PACKAGE_VERSION = "4.3.3";
|
|
22
22
|
var setProvider = function setProvider(provider) {
|
|
23
23
|
return function (state, dispatch) {
|
|
24
24
|
if (dispatch) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { Popper as ReactPopper } from '@atlaskit/popper';
|
|
3
4
|
import Portal from '@atlaskit/portal';
|
|
5
|
+
import { useFocusTrap } from './useFocusTrap';
|
|
4
6
|
/**
|
|
5
7
|
* A popup wrapper to match the behaviour of `@atlaskit/popup`
|
|
6
8
|
*
|
|
@@ -15,21 +17,35 @@ import Portal from '@atlaskit/portal';
|
|
|
15
17
|
export function Popup(_ref) {
|
|
16
18
|
var referenceElement = _ref.referenceElement,
|
|
17
19
|
children = _ref.children;
|
|
20
|
+
var _React$useState = React.useState(null),
|
|
21
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
22
|
+
targetRef = _React$useState2[0],
|
|
23
|
+
setPopupRef = _React$useState2[1];
|
|
24
|
+
useFocusTrap({
|
|
25
|
+
targetRef: targetRef
|
|
26
|
+
});
|
|
18
27
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(ReactPopper, {
|
|
19
28
|
referenceElement: referenceElement,
|
|
20
29
|
offset: [0, 8],
|
|
21
30
|
placement: "bottom-end",
|
|
22
31
|
strategy: "fixed"
|
|
23
32
|
}, function (_ref2) {
|
|
24
|
-
var
|
|
33
|
+
var _ref3 = _ref2.ref,
|
|
25
34
|
style = _ref2.style;
|
|
26
|
-
return (
|
|
27
|
-
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
ref: function ref(node) {
|
|
37
|
+
if (node) {
|
|
38
|
+
if (typeof _ref3 === 'function') {
|
|
39
|
+
_ref3(node);
|
|
40
|
+
} else {
|
|
41
|
+
_ref3.current = node;
|
|
42
|
+
}
|
|
43
|
+
setPopupRef(node);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
28
46
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, children)
|
|
33
|
-
);
|
|
47
|
+
,
|
|
48
|
+
style: style
|
|
49
|
+
}, children);
|
|
34
50
|
}));
|
|
35
51
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to add focus trap
|
|
3
|
+
* used for focus trap in ReactionPicker
|
|
4
|
+
* copied from useFocusManager in @atlaskit/popup
|
|
5
|
+
*/
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
import createFocusTrap from 'focus-trap';
|
|
8
|
+
export var useFocusTrap = function useFocusTrap(_ref) {
|
|
9
|
+
var targetRef = _ref.targetRef;
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
if (!targetRef) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var trapConfig = {
|
|
15
|
+
clickOutsideDeactivates: true,
|
|
16
|
+
escapeDeactivates: true,
|
|
17
|
+
initialFocus: targetRef,
|
|
18
|
+
fallbackFocus: targetRef,
|
|
19
|
+
returnFocusOnDeactivate: true
|
|
20
|
+
};
|
|
21
|
+
var focusTrap = createFocusTrap(targetRef, trapConfig);
|
|
22
|
+
|
|
23
|
+
// wait for the popup to reposition itself before we focus
|
|
24
|
+
var frameId = requestAnimationFrame(function () {
|
|
25
|
+
frameId = null;
|
|
26
|
+
focusTrap.activate();
|
|
27
|
+
});
|
|
28
|
+
return function () {
|
|
29
|
+
if (frameId !== null) {
|
|
30
|
+
cancelAnimationFrame(frameId);
|
|
31
|
+
frameId = null;
|
|
32
|
+
}
|
|
33
|
+
focusTrap.deactivate();
|
|
34
|
+
};
|
|
35
|
+
}, [targetRef]);
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
37
37
|
"@atlaskit/css": "^0.10.0",
|
|
38
|
-
"@atlaskit/editor-common": "^103.
|
|
38
|
+
"@atlaskit/editor-common": "^103.1.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.0.0",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@babel/runtime": "^7.0.0",
|
|
55
55
|
"@compiled/react": "^0.18.3",
|
|
56
56
|
"bind-event-listener": "^3.0.0",
|
|
57
|
+
"focus-trap": "^2.4.5",
|
|
57
58
|
"uuid": "^3.1.0"
|
|
58
59
|
},
|
|
59
60
|
"peerDependencies": {
|