@atlaskit/editor-plugin-mentions 1.4.0 → 1.5.0
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 +21 -0
- package/dist/cjs/nodeviews/mention.js +29 -8
- package/dist/cjs/ui/Mention/index.js +4 -0
- package/dist/cjs/ui/Mention/mention.js +182 -0
- package/dist/es2019/nodeviews/mention.js +29 -8
- package/dist/es2019/ui/Mention/index.js +5 -2
- package/dist/es2019/ui/Mention/mention.js +120 -0
- package/dist/esm/nodeviews/mention.js +29 -8
- package/dist/esm/ui/Mention/index.js +5 -2
- package/dist/esm/ui/Mention/mention.js +173 -0
- package/dist/types/types.d.ts +2 -0
- package/dist/types/ui/Mention/index.d.ts +4 -0
- package/dist/types/ui/Mention/mention.d.ts +18 -0
- package/dist/types-ts4.5/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/Mention/index.d.ts +4 -0
- package/dist/types-ts4.5/ui/Mention/mention.d.ts +18 -0
- package/package.json +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#103169](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103169)
|
|
8
|
+
[`e9d45fc94064`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e9d45fc94064) -
|
|
9
|
+
[ux] [ED-23248] -
|
|
10
|
+
|
|
11
|
+
**@atlaskit/editor-core**: Added optional profilecardProvider to Mention plugin in universal
|
|
12
|
+
composable editor **@atlaskit/editor-plugin-mentions**: Made mentions render with profile cards
|
|
13
|
+
on click if the feature flag: `platform.editor.mentions-in-editor-popup-on-click` is turned on
|
|
14
|
+
|
|
15
|
+
## 1.4.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
|
|
20
|
+
[`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
|
|
21
|
+
[ED-23332] Update adf-schema package to 36.10.1
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 1.4.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -13,7 +13,9 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
14
14
|
var _mention = require("@atlaskit/mention");
|
|
15
15
|
var _types = require("@atlaskit/mention/types");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _Mention = _interopRequireDefault(require("../ui/Mention"));
|
|
18
|
+
var _mention2 = require("../ui/Mention/mention");
|
|
17
19
|
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); }
|
|
18
20
|
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 && Object.prototype.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; }
|
|
19
21
|
var UNKNOWN_USER_ID = '_|unknown|_';
|
|
@@ -95,16 +97,35 @@ var MentionNodeView = exports.MentionNodeView = function MentionNodeView(props)
|
|
|
95
97
|
accessLevel = _props$node$attrs.accessLevel,
|
|
96
98
|
localId = _props$node$attrs.localId;
|
|
97
99
|
var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
|
|
100
|
+
var _props$options;
|
|
98
101
|
var _ref3 = providers,
|
|
99
102
|
mentionProvider = _ref3.mentionProvider;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
var profilecardProvider = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.mentions-in-editor-popup-on-click') ? (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider : undefined;
|
|
104
|
+
if (profilecardProvider) {
|
|
105
|
+
return (
|
|
106
|
+
/*#__PURE__*/
|
|
107
|
+
/**
|
|
108
|
+
* Rename this to `Mention` when `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
109
|
+
*/
|
|
110
|
+
_react.default.createElement(_mention2.Mention, {
|
|
111
|
+
id: id,
|
|
112
|
+
text: text,
|
|
113
|
+
accessLevel: accessLevel,
|
|
114
|
+
mentionProvider: mentionProvider,
|
|
115
|
+
profilecardProvider: profilecardProvider,
|
|
116
|
+
localId: localId
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
} else {
|
|
120
|
+
return /*#__PURE__*/_react.default.createElement(MentionAssistiveTextComponent, {
|
|
121
|
+
mentionProvider: mentionProvider,
|
|
122
|
+
id: id,
|
|
123
|
+
text: text,
|
|
124
|
+
providers: providerFactory,
|
|
125
|
+
accessLevel: accessLevel,
|
|
126
|
+
localId: localId
|
|
127
|
+
});
|
|
128
|
+
}
|
|
108
129
|
};
|
|
109
130
|
return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
|
|
110
131
|
providers: ['mentionProvider', 'profilecardProvider'],
|
|
@@ -34,6 +34,10 @@ var refreshBrowserSelection = function refreshBrowserSelection() {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated should be replaced with `editor-plugin-mentions/src/ui/Mention/mention.tsx`
|
|
39
|
+
* when the feature flag `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
40
|
+
*/
|
|
37
41
|
var Mention = exports.default = /*#__PURE__*/function (_PureComponent) {
|
|
38
42
|
(0, _inherits2.default)(Mention, _PureComponent);
|
|
39
43
|
var _super = _createSuper(Mention);
|
|
@@ -0,0 +1,182 @@
|
|
|
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.Mention = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _mention = require("@atlaskit/editor-common/mention");
|
|
15
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
|
+
var _element = require("@atlaskit/mention/element");
|
|
17
|
+
var _resource = require("@atlaskit/mention/resource");
|
|
18
|
+
var _types = require("@atlaskit/mention/types");
|
|
19
|
+
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); }
|
|
20
|
+
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 && Object.prototype.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; }
|
|
21
|
+
// Workaround for a firefox issue where dom selection is off sync
|
|
22
|
+
// https://product-fabric.atlassian.net/browse/ED-12442
|
|
23
|
+
var refreshBrowserSelection = function refreshBrowserSelection() {
|
|
24
|
+
var domSelection = window.getSelection();
|
|
25
|
+
if (domSelection) {
|
|
26
|
+
var domRange = domSelection && domSelection.rangeCount === 1 && domSelection.getRangeAt(0).cloneRange();
|
|
27
|
+
if (domRange) {
|
|
28
|
+
domSelection.removeAllRanges();
|
|
29
|
+
domSelection.addRange(domRange);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* This is the new preferred way to render mentions in the editor.
|
|
35
|
+
* Introduced behind the `platform.editor.mentions-in-editor-popup-on-click` feature flag.
|
|
36
|
+
*/
|
|
37
|
+
var Mention = exports.Mention = function Mention(props) {
|
|
38
|
+
var accessLevel = props.accessLevel,
|
|
39
|
+
eventHandlers = props.eventHandlers,
|
|
40
|
+
id = props.id,
|
|
41
|
+
text = props.text,
|
|
42
|
+
localId = props.localId,
|
|
43
|
+
mentionProvider = props.mentionProvider,
|
|
44
|
+
profilecardProviderPromise = props.profilecardProvider;
|
|
45
|
+
var _useState = (0, _react.useState)(undefined),
|
|
46
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
47
|
+
profilecardProvider = _useState2[0],
|
|
48
|
+
setProfilecardProvider = _useState2[1];
|
|
49
|
+
var resolvedName = useResolvedName(id, text, mentionProvider);
|
|
50
|
+
|
|
51
|
+
// Resolve the profilecard provider
|
|
52
|
+
(0, _react.useEffect)(function () {
|
|
53
|
+
var isCancelled = false;
|
|
54
|
+
var resolveProfilecardProvider = /*#__PURE__*/function () {
|
|
55
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
56
|
+
var _profilecardProvider;
|
|
57
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
_context.prev = 0;
|
|
61
|
+
_context.next = 3;
|
|
62
|
+
return profilecardProviderPromise;
|
|
63
|
+
case 3:
|
|
64
|
+
_profilecardProvider = _context.sent;
|
|
65
|
+
if (!isCancelled) {
|
|
66
|
+
setProfilecardProvider(_profilecardProvider);
|
|
67
|
+
}
|
|
68
|
+
_context.next = 10;
|
|
69
|
+
break;
|
|
70
|
+
case 7:
|
|
71
|
+
_context.prev = 7;
|
|
72
|
+
_context.t0 = _context["catch"](0);
|
|
73
|
+
if (!isCancelled) {
|
|
74
|
+
setProfilecardProvider(undefined);
|
|
75
|
+
}
|
|
76
|
+
case 10:
|
|
77
|
+
case "end":
|
|
78
|
+
return _context.stop();
|
|
79
|
+
}
|
|
80
|
+
}, _callee, null, [[0, 7]]);
|
|
81
|
+
}));
|
|
82
|
+
return function resolveProfilecardProvider() {
|
|
83
|
+
return _ref.apply(this, arguments);
|
|
84
|
+
};
|
|
85
|
+
}();
|
|
86
|
+
if (profilecardProviderPromise) {
|
|
87
|
+
resolveProfilecardProvider();
|
|
88
|
+
}
|
|
89
|
+
return function () {
|
|
90
|
+
isCancelled = true;
|
|
91
|
+
};
|
|
92
|
+
}, [profilecardProviderPromise]);
|
|
93
|
+
(0, _react.useEffect)(function () {
|
|
94
|
+
// Workaround an issue where the selection is not updated immediately after adding
|
|
95
|
+
// a mention when "sanitizePrivateContent" is enabled in the editor on safari.
|
|
96
|
+
// This affects both insertion and paste behaviour it is applied to the component.
|
|
97
|
+
// https://product-fabric.atlassian.net/browse/ED-14859
|
|
98
|
+
if (_utils.browser.safari) {
|
|
99
|
+
setTimeout(refreshBrowserSelection, 0);
|
|
100
|
+
}
|
|
101
|
+
}, []);
|
|
102
|
+
var actionHandlers = {};
|
|
103
|
+
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (handler) {
|
|
104
|
+
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || function () {};
|
|
105
|
+
});
|
|
106
|
+
if (profilecardProvider) {
|
|
107
|
+
return /*#__PURE__*/_react.default.createElement(_mention.MentionWithProfileCard, (0, _extends2.default)({
|
|
108
|
+
id: id,
|
|
109
|
+
text: resolvedName,
|
|
110
|
+
accessLevel: accessLevel,
|
|
111
|
+
mentionProvider: mentionProvider,
|
|
112
|
+
profilecardProvider: profilecardProvider,
|
|
113
|
+
localId: localId
|
|
114
|
+
}, actionHandlers));
|
|
115
|
+
} else {
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_element.ResourcedMention, (0, _extends2.default)({
|
|
117
|
+
id: id,
|
|
118
|
+
text: resolvedName,
|
|
119
|
+
accessLevel: accessLevel,
|
|
120
|
+
mentionProvider: mentionProvider,
|
|
121
|
+
localId: localId
|
|
122
|
+
}, actionHandlers));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var useResolvedName = function useResolvedName(id, text, mentionProvider) {
|
|
126
|
+
var _useState3 = (0, _react.useState)(text),
|
|
127
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
128
|
+
resolvedName = _useState4[0],
|
|
129
|
+
setResolvedName = _useState4[1];
|
|
130
|
+
var processName = function processName(name) {
|
|
131
|
+
if (name.status === _resource.MentionNameStatus.OK) {
|
|
132
|
+
return "@".concat(name.name || '');
|
|
133
|
+
} else {
|
|
134
|
+
return "@_|unknown|_";
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
(0, _react.useEffect)(function () {
|
|
138
|
+
if (mentionProvider) {
|
|
139
|
+
mentionProvider.then( /*#__PURE__*/function () {
|
|
140
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(provider) {
|
|
141
|
+
var nameDetail;
|
|
142
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
143
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
if (!(!text && (0, _resource.isResolvingMentionProvider)(provider))) {
|
|
146
|
+
_context2.next = 13;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
nameDetail = provider.resolveMentionName(id);
|
|
150
|
+
if (!(0, _types.isPromise)(nameDetail)) {
|
|
151
|
+
_context2.next = 10;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
_context2.t0 = processName;
|
|
155
|
+
_context2.next = 6;
|
|
156
|
+
return nameDetail;
|
|
157
|
+
case 6:
|
|
158
|
+
_context2.t1 = _context2.sent;
|
|
159
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
|
|
160
|
+
case 10:
|
|
161
|
+
return _context2.abrupt("return", processName(nameDetail));
|
|
162
|
+
case 11:
|
|
163
|
+
_context2.next = 14;
|
|
164
|
+
break;
|
|
165
|
+
case 13:
|
|
166
|
+
return _context2.abrupt("return", text);
|
|
167
|
+
case 14:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context2.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee2);
|
|
172
|
+
}));
|
|
173
|
+
return function (_x) {
|
|
174
|
+
return _ref2.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
}()).then(function (resolvedName) {
|
|
177
|
+
setResolvedName(resolvedName);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}, [id, text, mentionProvider]);
|
|
181
|
+
return resolvedName;
|
|
182
|
+
};
|
|
@@ -2,7 +2,9 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention';
|
|
4
4
|
import { isPromise } from '@atlaskit/mention/types';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import Mention from '../ui/Mention';
|
|
7
|
+
import { Mention as MentionNext } from '../ui/Mention/mention';
|
|
6
8
|
const UNKNOWN_USER_ID = '_|unknown|_';
|
|
7
9
|
const MentionAssistiveTextComponent = ({
|
|
8
10
|
id,
|
|
@@ -57,17 +59,36 @@ export const MentionNodeView = props => {
|
|
|
57
59
|
localId
|
|
58
60
|
} = props.node.attrs;
|
|
59
61
|
const renderAssistiveTextWithProviders = providers => {
|
|
62
|
+
var _props$options;
|
|
60
63
|
const {
|
|
61
64
|
mentionProvider
|
|
62
65
|
} = providers;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
const profilecardProvider = getBooleanFF('platform.editor.mentions-in-editor-popup-on-click') ? (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider : undefined;
|
|
67
|
+
if (profilecardProvider) {
|
|
68
|
+
return (
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
/**
|
|
71
|
+
* Rename this to `Mention` when `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
72
|
+
*/
|
|
73
|
+
React.createElement(MentionNext, {
|
|
74
|
+
id: id,
|
|
75
|
+
text: text,
|
|
76
|
+
accessLevel: accessLevel,
|
|
77
|
+
mentionProvider: mentionProvider,
|
|
78
|
+
profilecardProvider: profilecardProvider,
|
|
79
|
+
localId: localId
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
return /*#__PURE__*/React.createElement(MentionAssistiveTextComponent, {
|
|
84
|
+
mentionProvider: mentionProvider,
|
|
85
|
+
id: id,
|
|
86
|
+
text: text,
|
|
87
|
+
providers: providerFactory,
|
|
88
|
+
accessLevel: accessLevel,
|
|
89
|
+
localId: localId
|
|
90
|
+
});
|
|
91
|
+
}
|
|
71
92
|
};
|
|
72
93
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
73
94
|
providers: ['mentionProvider', 'profilecardProvider'],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { PureComponent } from 'react';
|
|
3
|
+
import React, { PureComponent } from 'react';
|
|
5
4
|
import { ProviderFactory, WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
5
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
6
|
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
@@ -17,6 +16,10 @@ const refreshBrowserSelection = () => {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated should be replaced with `editor-plugin-mentions/src/ui/Mention/mention.tsx`
|
|
21
|
+
* when the feature flag `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
22
|
+
*/
|
|
20
23
|
export default class Mention extends PureComponent {
|
|
21
24
|
constructor(props) {
|
|
22
25
|
super(props);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { MentionWithProfileCard } from '@atlaskit/editor-common/mention';
|
|
4
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
6
|
+
import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention/resource';
|
|
7
|
+
import { isPromise } from '@atlaskit/mention/types';
|
|
8
|
+
|
|
9
|
+
// Workaround for a firefox issue where dom selection is off sync
|
|
10
|
+
// https://product-fabric.atlassian.net/browse/ED-12442
|
|
11
|
+
const refreshBrowserSelection = () => {
|
|
12
|
+
const domSelection = window.getSelection();
|
|
13
|
+
if (domSelection) {
|
|
14
|
+
const domRange = domSelection && domSelection.rangeCount === 1 && domSelection.getRangeAt(0).cloneRange();
|
|
15
|
+
if (domRange) {
|
|
16
|
+
domSelection.removeAllRanges();
|
|
17
|
+
domSelection.addRange(domRange);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This is the new preferred way to render mentions in the editor.
|
|
23
|
+
* Introduced behind the `platform.editor.mentions-in-editor-popup-on-click` feature flag.
|
|
24
|
+
*/
|
|
25
|
+
export const Mention = props => {
|
|
26
|
+
const {
|
|
27
|
+
accessLevel,
|
|
28
|
+
eventHandlers,
|
|
29
|
+
id,
|
|
30
|
+
text,
|
|
31
|
+
localId,
|
|
32
|
+
mentionProvider,
|
|
33
|
+
profilecardProvider: profilecardProviderPromise
|
|
34
|
+
} = props;
|
|
35
|
+
const [profilecardProvider, setProfilecardProvider] = useState(undefined);
|
|
36
|
+
const resolvedName = useResolvedName(id, text, mentionProvider);
|
|
37
|
+
|
|
38
|
+
// Resolve the profilecard provider
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
let isCancelled = false;
|
|
41
|
+
const resolveProfilecardProvider = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const profilecardProvider = await profilecardProviderPromise;
|
|
44
|
+
if (!isCancelled) {
|
|
45
|
+
setProfilecardProvider(profilecardProvider);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (!isCancelled) {
|
|
49
|
+
setProfilecardProvider(undefined);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if (profilecardProviderPromise) {
|
|
54
|
+
resolveProfilecardProvider();
|
|
55
|
+
}
|
|
56
|
+
return () => {
|
|
57
|
+
isCancelled = true;
|
|
58
|
+
};
|
|
59
|
+
}, [profilecardProviderPromise]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
// Workaround an issue where the selection is not updated immediately after adding
|
|
62
|
+
// a mention when "sanitizePrivateContent" is enabled in the editor on safari.
|
|
63
|
+
// This affects both insertion and paste behaviour it is applied to the component.
|
|
64
|
+
// https://product-fabric.atlassian.net/browse/ED-14859
|
|
65
|
+
if (browser.safari) {
|
|
66
|
+
setTimeout(refreshBrowserSelection, 0);
|
|
67
|
+
}
|
|
68
|
+
}, []);
|
|
69
|
+
const actionHandlers = {};
|
|
70
|
+
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(handler => {
|
|
71
|
+
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || (() => {});
|
|
72
|
+
});
|
|
73
|
+
if (profilecardProvider) {
|
|
74
|
+
return /*#__PURE__*/React.createElement(MentionWithProfileCard, _extends({
|
|
75
|
+
id: id,
|
|
76
|
+
text: resolvedName,
|
|
77
|
+
accessLevel: accessLevel,
|
|
78
|
+
mentionProvider: mentionProvider,
|
|
79
|
+
profilecardProvider: profilecardProvider,
|
|
80
|
+
localId: localId
|
|
81
|
+
}, actionHandlers));
|
|
82
|
+
} else {
|
|
83
|
+
return /*#__PURE__*/React.createElement(ResourcedMention, _extends({
|
|
84
|
+
id: id,
|
|
85
|
+
text: resolvedName,
|
|
86
|
+
accessLevel: accessLevel,
|
|
87
|
+
mentionProvider: mentionProvider,
|
|
88
|
+
localId: localId
|
|
89
|
+
}, actionHandlers));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const useResolvedName = (id, text, mentionProvider) => {
|
|
93
|
+
const [resolvedName, setResolvedName] = useState(text);
|
|
94
|
+
const processName = name => {
|
|
95
|
+
if (name.status === MentionNameStatus.OK) {
|
|
96
|
+
return `@${name.name || ''}`;
|
|
97
|
+
} else {
|
|
98
|
+
return `@_|unknown|_`;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (mentionProvider) {
|
|
103
|
+
mentionProvider.then(async provider => {
|
|
104
|
+
if (!text && isResolvingMentionProvider(provider)) {
|
|
105
|
+
const nameDetail = provider.resolveMentionName(id);
|
|
106
|
+
if (isPromise(nameDetail)) {
|
|
107
|
+
return processName(await nameDetail);
|
|
108
|
+
} else {
|
|
109
|
+
return processName(nameDetail);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
return text;
|
|
113
|
+
}
|
|
114
|
+
}).then(resolvedName => {
|
|
115
|
+
setResolvedName(resolvedName);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, [id, text, mentionProvider]);
|
|
119
|
+
return resolvedName;
|
|
120
|
+
};
|
|
@@ -5,7 +5,9 @@ import React, { useEffect, useState } from 'react';
|
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
6
|
import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention';
|
|
7
7
|
import { isPromise } from '@atlaskit/mention/types';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import Mention from '../ui/Mention';
|
|
10
|
+
import { Mention as MentionNext } from '../ui/Mention/mention';
|
|
9
11
|
var UNKNOWN_USER_ID = '_|unknown|_';
|
|
10
12
|
var MentionAssistiveTextComponent = function MentionAssistiveTextComponent(_ref) {
|
|
11
13
|
var id = _ref.id,
|
|
@@ -85,16 +87,35 @@ export var MentionNodeView = function MentionNodeView(props) {
|
|
|
85
87
|
accessLevel = _props$node$attrs.accessLevel,
|
|
86
88
|
localId = _props$node$attrs.localId;
|
|
87
89
|
var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
|
|
90
|
+
var _props$options;
|
|
88
91
|
var _ref3 = providers,
|
|
89
92
|
mentionProvider = _ref3.mentionProvider;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
var profilecardProvider = getBooleanFF('platform.editor.mentions-in-editor-popup-on-click') ? (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider : undefined;
|
|
94
|
+
if (profilecardProvider) {
|
|
95
|
+
return (
|
|
96
|
+
/*#__PURE__*/
|
|
97
|
+
/**
|
|
98
|
+
* Rename this to `Mention` when `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
99
|
+
*/
|
|
100
|
+
React.createElement(MentionNext, {
|
|
101
|
+
id: id,
|
|
102
|
+
text: text,
|
|
103
|
+
accessLevel: accessLevel,
|
|
104
|
+
mentionProvider: mentionProvider,
|
|
105
|
+
profilecardProvider: profilecardProvider,
|
|
106
|
+
localId: localId
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
} else {
|
|
110
|
+
return /*#__PURE__*/React.createElement(MentionAssistiveTextComponent, {
|
|
111
|
+
mentionProvider: mentionProvider,
|
|
112
|
+
id: id,
|
|
113
|
+
text: text,
|
|
114
|
+
providers: providerFactory,
|
|
115
|
+
accessLevel: accessLevel,
|
|
116
|
+
localId: localId
|
|
117
|
+
});
|
|
118
|
+
}
|
|
98
119
|
};
|
|
99
120
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
100
121
|
providers: ['mentionProvider', 'profilecardProvider'],
|
|
@@ -8,8 +8,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
-
import React from 'react';
|
|
12
|
-
import { PureComponent } from 'react';
|
|
11
|
+
import React, { PureComponent } from 'react';
|
|
13
12
|
import { ProviderFactory, WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
14
13
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
15
14
|
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
@@ -25,6 +24,10 @@ var refreshBrowserSelection = function refreshBrowserSelection() {
|
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated should be replaced with `editor-plugin-mentions/src/ui/Mention/mention.tsx`
|
|
29
|
+
* when the feature flag `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
30
|
+
*/
|
|
28
31
|
var Mention = /*#__PURE__*/function (_PureComponent) {
|
|
29
32
|
_inherits(Mention, _PureComponent);
|
|
30
33
|
var _super = _createSuper(Mention);
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import { MentionWithProfileCard } from '@atlaskit/editor-common/mention';
|
|
7
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { ResourcedMention } from '@atlaskit/mention/element';
|
|
9
|
+
import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention/resource';
|
|
10
|
+
import { isPromise } from '@atlaskit/mention/types';
|
|
11
|
+
|
|
12
|
+
// Workaround for a firefox issue where dom selection is off sync
|
|
13
|
+
// https://product-fabric.atlassian.net/browse/ED-12442
|
|
14
|
+
var refreshBrowserSelection = function refreshBrowserSelection() {
|
|
15
|
+
var domSelection = window.getSelection();
|
|
16
|
+
if (domSelection) {
|
|
17
|
+
var domRange = domSelection && domSelection.rangeCount === 1 && domSelection.getRangeAt(0).cloneRange();
|
|
18
|
+
if (domRange) {
|
|
19
|
+
domSelection.removeAllRanges();
|
|
20
|
+
domSelection.addRange(domRange);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* This is the new preferred way to render mentions in the editor.
|
|
26
|
+
* Introduced behind the `platform.editor.mentions-in-editor-popup-on-click` feature flag.
|
|
27
|
+
*/
|
|
28
|
+
export var Mention = function Mention(props) {
|
|
29
|
+
var accessLevel = props.accessLevel,
|
|
30
|
+
eventHandlers = props.eventHandlers,
|
|
31
|
+
id = props.id,
|
|
32
|
+
text = props.text,
|
|
33
|
+
localId = props.localId,
|
|
34
|
+
mentionProvider = props.mentionProvider,
|
|
35
|
+
profilecardProviderPromise = props.profilecardProvider;
|
|
36
|
+
var _useState = useState(undefined),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
profilecardProvider = _useState2[0],
|
|
39
|
+
setProfilecardProvider = _useState2[1];
|
|
40
|
+
var resolvedName = useResolvedName(id, text, mentionProvider);
|
|
41
|
+
|
|
42
|
+
// Resolve the profilecard provider
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
var isCancelled = false;
|
|
45
|
+
var resolveProfilecardProvider = /*#__PURE__*/function () {
|
|
46
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
47
|
+
var _profilecardProvider;
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_context.prev = 0;
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
return profilecardProviderPromise;
|
|
54
|
+
case 3:
|
|
55
|
+
_profilecardProvider = _context.sent;
|
|
56
|
+
if (!isCancelled) {
|
|
57
|
+
setProfilecardProvider(_profilecardProvider);
|
|
58
|
+
}
|
|
59
|
+
_context.next = 10;
|
|
60
|
+
break;
|
|
61
|
+
case 7:
|
|
62
|
+
_context.prev = 7;
|
|
63
|
+
_context.t0 = _context["catch"](0);
|
|
64
|
+
if (!isCancelled) {
|
|
65
|
+
setProfilecardProvider(undefined);
|
|
66
|
+
}
|
|
67
|
+
case 10:
|
|
68
|
+
case "end":
|
|
69
|
+
return _context.stop();
|
|
70
|
+
}
|
|
71
|
+
}, _callee, null, [[0, 7]]);
|
|
72
|
+
}));
|
|
73
|
+
return function resolveProfilecardProvider() {
|
|
74
|
+
return _ref.apply(this, arguments);
|
|
75
|
+
};
|
|
76
|
+
}();
|
|
77
|
+
if (profilecardProviderPromise) {
|
|
78
|
+
resolveProfilecardProvider();
|
|
79
|
+
}
|
|
80
|
+
return function () {
|
|
81
|
+
isCancelled = true;
|
|
82
|
+
};
|
|
83
|
+
}, [profilecardProviderPromise]);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
// Workaround an issue where the selection is not updated immediately after adding
|
|
86
|
+
// a mention when "sanitizePrivateContent" is enabled in the editor on safari.
|
|
87
|
+
// This affects both insertion and paste behaviour it is applied to the component.
|
|
88
|
+
// https://product-fabric.atlassian.net/browse/ED-14859
|
|
89
|
+
if (browser.safari) {
|
|
90
|
+
setTimeout(refreshBrowserSelection, 0);
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
93
|
+
var actionHandlers = {};
|
|
94
|
+
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (handler) {
|
|
95
|
+
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || function () {};
|
|
96
|
+
});
|
|
97
|
+
if (profilecardProvider) {
|
|
98
|
+
return /*#__PURE__*/React.createElement(MentionWithProfileCard, _extends({
|
|
99
|
+
id: id,
|
|
100
|
+
text: resolvedName,
|
|
101
|
+
accessLevel: accessLevel,
|
|
102
|
+
mentionProvider: mentionProvider,
|
|
103
|
+
profilecardProvider: profilecardProvider,
|
|
104
|
+
localId: localId
|
|
105
|
+
}, actionHandlers));
|
|
106
|
+
} else {
|
|
107
|
+
return /*#__PURE__*/React.createElement(ResourcedMention, _extends({
|
|
108
|
+
id: id,
|
|
109
|
+
text: resolvedName,
|
|
110
|
+
accessLevel: accessLevel,
|
|
111
|
+
mentionProvider: mentionProvider,
|
|
112
|
+
localId: localId
|
|
113
|
+
}, actionHandlers));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var useResolvedName = function useResolvedName(id, text, mentionProvider) {
|
|
117
|
+
var _useState3 = useState(text),
|
|
118
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
119
|
+
resolvedName = _useState4[0],
|
|
120
|
+
setResolvedName = _useState4[1];
|
|
121
|
+
var processName = function processName(name) {
|
|
122
|
+
if (name.status === MentionNameStatus.OK) {
|
|
123
|
+
return "@".concat(name.name || '');
|
|
124
|
+
} else {
|
|
125
|
+
return "@_|unknown|_";
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
useEffect(function () {
|
|
129
|
+
if (mentionProvider) {
|
|
130
|
+
mentionProvider.then( /*#__PURE__*/function () {
|
|
131
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(provider) {
|
|
132
|
+
var nameDetail;
|
|
133
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
134
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
135
|
+
case 0:
|
|
136
|
+
if (!(!text && isResolvingMentionProvider(provider))) {
|
|
137
|
+
_context2.next = 13;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
nameDetail = provider.resolveMentionName(id);
|
|
141
|
+
if (!isPromise(nameDetail)) {
|
|
142
|
+
_context2.next = 10;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
_context2.t0 = processName;
|
|
146
|
+
_context2.next = 6;
|
|
147
|
+
return nameDetail;
|
|
148
|
+
case 6:
|
|
149
|
+
_context2.t1 = _context2.sent;
|
|
150
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
|
|
151
|
+
case 10:
|
|
152
|
+
return _context2.abrupt("return", processName(nameDetail));
|
|
153
|
+
case 11:
|
|
154
|
+
_context2.next = 14;
|
|
155
|
+
break;
|
|
156
|
+
case 13:
|
|
157
|
+
return _context2.abrupt("return", text);
|
|
158
|
+
case 14:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context2.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee2);
|
|
163
|
+
}));
|
|
164
|
+
return function (_x) {
|
|
165
|
+
return _ref2.apply(this, arguments);
|
|
166
|
+
};
|
|
167
|
+
}()).then(function (resolvedName) {
|
|
168
|
+
setResolvedName(resolvedName);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}, [id, text, mentionProvider]);
|
|
172
|
+
return resolvedName;
|
|
173
|
+
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { AnalyticsEventPayload } from '@atlaskit/analytics-next';
|
|
3
|
+
import { type ProfilecardProvider } from '@atlaskit/editor-common/src/provider-factory/profile-card-provider';
|
|
3
4
|
import type { NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
6
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
@@ -13,6 +14,7 @@ export interface TeamInfoAttrAnalytics {
|
|
|
13
14
|
export interface MentionPluginConfig {
|
|
14
15
|
HighlightComponent?: React.ComponentType<React.PropsWithChildren<unknown>>;
|
|
15
16
|
insertDisplayName?: boolean;
|
|
17
|
+
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
16
18
|
}
|
|
17
19
|
export interface MentionPluginOptions extends MentionPluginConfig {
|
|
18
20
|
sanitizePrivateContent?: boolean;
|
|
@@ -9,6 +9,10 @@ export interface MentionProps {
|
|
|
9
9
|
accessLevel?: string;
|
|
10
10
|
localId?: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated should be replaced with `editor-plugin-mentions/src/ui/Mention/mention.tsx`
|
|
14
|
+
* when the feature flag `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
15
|
+
*/
|
|
12
16
|
export default class Mention extends PureComponent<MentionProps, {}> {
|
|
13
17
|
static displayName: string;
|
|
14
18
|
private providerFactory;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ProfilecardProvider } from '@atlaskit/editor-common/src/provider-factory/profile-card-provider';
|
|
3
|
+
import type { MentionEventHandlers } from '@atlaskit/editor-common/ui';
|
|
4
|
+
import { type MentionProvider } from '@atlaskit/mention/resource';
|
|
5
|
+
export interface MentionProps {
|
|
6
|
+
id: string;
|
|
7
|
+
eventHandlers?: MentionEventHandlers;
|
|
8
|
+
text: string;
|
|
9
|
+
accessLevel?: string;
|
|
10
|
+
localId?: string;
|
|
11
|
+
mentionProvider?: Promise<MentionProvider>;
|
|
12
|
+
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* This is the new preferred way to render mentions in the editor.
|
|
16
|
+
* Introduced behind the `platform.editor.mentions-in-editor-popup-on-click` feature flag.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Mention: (props: MentionProps) => JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { AnalyticsEventPayload } from '@atlaskit/analytics-next';
|
|
3
|
+
import { type ProfilecardProvider } from '@atlaskit/editor-common/src/provider-factory/profile-card-provider';
|
|
3
4
|
import type { NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
4
5
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
6
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
@@ -13,6 +14,7 @@ export interface TeamInfoAttrAnalytics {
|
|
|
13
14
|
export interface MentionPluginConfig {
|
|
14
15
|
HighlightComponent?: React.ComponentType<React.PropsWithChildren<unknown>>;
|
|
15
16
|
insertDisplayName?: boolean;
|
|
17
|
+
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
16
18
|
}
|
|
17
19
|
export interface MentionPluginOptions extends MentionPluginConfig {
|
|
18
20
|
sanitizePrivateContent?: boolean;
|
|
@@ -9,6 +9,10 @@ export interface MentionProps {
|
|
|
9
9
|
accessLevel?: string;
|
|
10
10
|
localId?: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated should be replaced with `editor-plugin-mentions/src/ui/Mention/mention.tsx`
|
|
14
|
+
* when the feature flag `platform.editor.mentions-in-editor-popup-on-click` is tidied up.
|
|
15
|
+
*/
|
|
12
16
|
export default class Mention extends PureComponent<MentionProps, {}> {
|
|
13
17
|
static displayName: string;
|
|
14
18
|
private providerFactory;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ProfilecardProvider } from '@atlaskit/editor-common/src/provider-factory/profile-card-provider';
|
|
3
|
+
import type { MentionEventHandlers } from '@atlaskit/editor-common/ui';
|
|
4
|
+
import { type MentionProvider } from '@atlaskit/mention/resource';
|
|
5
|
+
export interface MentionProps {
|
|
6
|
+
id: string;
|
|
7
|
+
eventHandlers?: MentionEventHandlers;
|
|
8
|
+
text: string;
|
|
9
|
+
accessLevel?: string;
|
|
10
|
+
localId?: string;
|
|
11
|
+
mentionProvider?: Promise<MentionProvider>;
|
|
12
|
+
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* This is the new preferred way to render mentions in the editor.
|
|
16
|
+
* Introduced behind the `platform.editor.mentions-in-editor-popup-on-click` feature flag.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Mention: (props: MentionProps) => JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^36.
|
|
36
|
+
"@atlaskit/adf-schema": "^36.10.7",
|
|
37
37
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
38
|
-
"@atlaskit/editor-common": "^
|
|
38
|
+
"@atlaskit/editor-common": "^81.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-context-identifier": "^1.1.0",
|
|
41
41
|
"@atlaskit/editor-plugin-type-ahead": "^1.2.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
43
43
|
"@atlaskit/icon": "^22.3.0",
|
|
44
44
|
"@atlaskit/mention": "^23.0.0",
|
|
45
|
+
"@atlaskit/platform-feature-flags": "^0.2.5",
|
|
45
46
|
"@atlaskit/theme": "^12.8.0",
|
|
46
47
|
"@atlaskit/tokens": "^1.49.0",
|
|
47
48
|
"@babel/runtime": "^7.0.0",
|
|
@@ -104,5 +105,10 @@
|
|
|
104
105
|
"@atlassian/tangerine/project-structure"
|
|
105
106
|
]
|
|
106
107
|
},
|
|
107
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
108
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
109
|
+
"platform-feature-flags": {
|
|
110
|
+
"platform.editor.mentions-in-editor-popup-on-click": {
|
|
111
|
+
"type": "boolean"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
108
114
|
}
|