@atlaskit/editor-plugin-mentions 16.0.2 → 16.1.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 +17 -0
- package/anchored-popup/package.json +10 -0
- package/dist/cjs/entry-points/anchored-popup.js +12 -0
- package/dist/cjs/mentionsPlugin.js +4 -12
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/AnchoredPopup.js +37 -0
- package/dist/cjs/ui/InlineInvitePopupContainer.js +157 -0
- package/dist/cjs/ui/type-ahead/index.js +18 -11
- package/dist/es2019/entry-points/anchored-popup.js +2 -0
- package/dist/es2019/mentionsPlugin.js +4 -10
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/AnchoredPopup.js +28 -0
- package/dist/es2019/ui/InlineInvitePopupContainer.js +146 -0
- package/dist/es2019/ui/type-ahead/index.js +18 -13
- package/dist/esm/entry-points/anchored-popup.js +2 -0
- package/dist/esm/mentionsPlugin.js +4 -12
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/AnchoredPopup.js +29 -0
- package/dist/esm/ui/InlineInvitePopupContainer.js +148 -0
- package/dist/esm/ui/type-ahead/index.js +18 -11
- package/dist/types/entry-points/anchored-popup.d.ts +2 -0
- package/dist/types/ui/AnchoredPopup.d.ts +13 -0
- package/dist/types/ui/InlineInvitePopupContainer.d.ts +11 -0
- package/package.json +11 -5
- package/dist/cjs/pm-plugins/mentionPlaceholder.js +0 -52
- package/dist/cjs/ui/InlineInviteRecaptchaContainer.js +0 -100
- package/dist/es2019/pm-plugins/mentionPlaceholder.js +0 -44
- package/dist/es2019/ui/InlineInviteRecaptchaContainer.js +0 -90
- package/dist/esm/pm-plugins/mentionPlaceholder.js +0 -44
- package/dist/esm/ui/InlineInviteRecaptchaContainer.js +0 -91
- package/dist/types/pm-plugins/mentionPlaceholder.d.ts +0 -11
- package/dist/types/ui/InlineInviteRecaptchaContainer.d.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 16.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`50992b74009d1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/50992b74009d1) -
|
|
8
|
+
Add InlineInvitePopup provider hook, replacing InlineInviteRecaptcha slot
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 16.0.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 16.0.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-mentions/anchored-popup",
|
|
3
|
+
"main": "../dist/cjs/entry-points/anchored-popup.js",
|
|
4
|
+
"module": "../dist/esm/entry-points/anchored-popup.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/entry-points/anchored-popup.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/entry-points/anchored-popup.d.ts"
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AnchoredPopup", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AnchoredPopup.AnchoredPopup;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _AnchoredPopup = require("../ui/AnchoredPopup");
|
|
@@ -27,8 +27,7 @@ var _mentionNodeSpec = require("./nodeviews/mentionNodeSpec");
|
|
|
27
27
|
var _agent = require("./pm-plugins/agent");
|
|
28
28
|
var _key = require("./pm-plugins/key");
|
|
29
29
|
var _main = require("./pm-plugins/main");
|
|
30
|
-
var
|
|
31
|
-
var _InlineInviteRecaptchaContainer = require("./ui/InlineInviteRecaptchaContainer");
|
|
30
|
+
var _InlineInvitePopupContainer = require("./ui/InlineInvitePopupContainer");
|
|
32
31
|
var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
|
|
33
32
|
var _typeAhead = require("./ui/type-ahead");
|
|
34
33
|
var _excluded2 = ["pendingPastedAgentMention"]; // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
@@ -145,14 +144,6 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
145
144
|
}
|
|
146
145
|
});
|
|
147
146
|
}
|
|
148
|
-
if ((0, _platformFeatureFlags.fg)('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
149
|
-
plugins.push({
|
|
150
|
-
name: 'mentionPlaceholder',
|
|
151
|
-
plugin: function plugin() {
|
|
152
|
-
return (0, _mentionPlaceholder.createMentionPlaceholderPlugin)();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
147
|
return plugins;
|
|
157
148
|
},
|
|
158
149
|
contentComponent: function contentComponent(_ref4) {
|
|
@@ -173,9 +164,10 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
173
164
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, {
|
|
174
165
|
mentionProvider: mentionProvider,
|
|
175
166
|
api: api
|
|
176
|
-
}), (0, _platformFeatureFlags.fg)('
|
|
167
|
+
}), (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/_react.default.createElement(_InlineInvitePopupContainer.InlineInvitePopupContainer, {
|
|
177
168
|
mentionProvider: mentionProvider,
|
|
178
|
-
api: api
|
|
169
|
+
api: api,
|
|
170
|
+
editorView: editorView
|
|
179
171
|
}));
|
|
180
172
|
}
|
|
181
173
|
});
|
|
@@ -67,7 +67,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
67
67
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
68
68
|
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
69
69
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
70
|
-
var PACKAGE_VERSION = "16.0.
|
|
70
|
+
var PACKAGE_VERSION = "16.0.3";
|
|
71
71
|
var setProvider = function setProvider(provider) {
|
|
72
72
|
return function (state, dispatch) {
|
|
73
73
|
if (dispatch) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AnchoredPopup = AnchoredPopup;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _popup = require("@atlaskit/popup/popup");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
11
|
+
/**
|
|
12
|
+
* A `<Popup>` anchored to an externally-supplied DOM node. Unlike `PopupTrigger`, it has no
|
|
13
|
+
* clickable trigger of its own — it opens whenever `isOpen` becomes true, so callers can drive
|
|
14
|
+
* it from any external signal.
|
|
15
|
+
*/
|
|
16
|
+
function AnchoredPopup(_ref) {
|
|
17
|
+
var anchorElement = _ref.anchorElement,
|
|
18
|
+
content = _ref.content,
|
|
19
|
+
isOpen = _ref.isOpen,
|
|
20
|
+
onClose = _ref.onClose;
|
|
21
|
+
var renderContent = (0, _react.useCallback)(function () {
|
|
22
|
+
return isOpen ? content : null;
|
|
23
|
+
}, [isOpen, content]);
|
|
24
|
+
var renderTrigger = (0, _react.useCallback)(function (triggerProps) {
|
|
25
|
+
if (anchorElement && typeof triggerProps.ref === 'function') {
|
|
26
|
+
triggerProps.ref(anchorElement);
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}, [anchorElement]);
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_popup.Popup, {
|
|
31
|
+
isOpen: isOpen,
|
|
32
|
+
onClose: onClose,
|
|
33
|
+
placement: "bottom-start",
|
|
34
|
+
content: renderContent,
|
|
35
|
+
trigger: renderTrigger
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/* InlineInvitePopupContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.InlineInvitePopupContainer = void 0;
|
|
10
|
+
var _runtime = require("@compiled/react/runtime");
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
var findMentionRange = function findMentionRange(doc, localId) {
|
|
15
|
+
var range = null;
|
|
16
|
+
doc.descendants(function (node, pos) {
|
|
17
|
+
if (range) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (node.type.name === 'mention' && node.attrs.localId === localId) {
|
|
21
|
+
range = {
|
|
22
|
+
from: pos,
|
|
23
|
+
to: pos + node.nodeSize
|
|
24
|
+
};
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
});
|
|
29
|
+
return range;
|
|
30
|
+
};
|
|
31
|
+
var InlineInvitePopupContainer = exports.InlineInvitePopupContainer = function InlineInvitePopupContainer(_ref) {
|
|
32
|
+
var _api$mention2, _api$core3;
|
|
33
|
+
var mentionProvider = _ref.mentionProvider,
|
|
34
|
+
api = _ref.api,
|
|
35
|
+
editorView = _ref.editorView;
|
|
36
|
+
var _useState = (0, _react.useState)(null),
|
|
37
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
38
|
+
provider = _useState2[0],
|
|
39
|
+
setProvider = _useState2[1];
|
|
40
|
+
var _useState3 = (0, _react.useState)(null),
|
|
41
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
42
|
+
anchorElement = _useState4[0],
|
|
43
|
+
setAnchorElement = _useState4[1];
|
|
44
|
+
var pendingMentionRef = (0, _react.useRef)(null);
|
|
45
|
+
(0, _react.useEffect)(function () {
|
|
46
|
+
if (!mentionProvider) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var isMounted = true;
|
|
50
|
+
var cleanupProvider;
|
|
51
|
+
mentionProvider.then(function (resolvedProvider) {
|
|
52
|
+
var _providerWithPopup$ge;
|
|
53
|
+
if (!isMounted) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var providerWithPopup = resolvedProvider;
|
|
57
|
+
var originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
|
|
58
|
+
providerWithPopup.getMentionDisabledState = function (mention) {
|
|
59
|
+
var _pendingMentionRef$cu;
|
|
60
|
+
if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
|
|
61
|
+
return {
|
|
62
|
+
disabled: true
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
|
|
66
|
+
};
|
|
67
|
+
cleanupProvider = function cleanupProvider() {
|
|
68
|
+
if (originalGetMentionDisabledState) {
|
|
69
|
+
providerWithPopup.getMentionDisabledState = originalGetMentionDisabledState;
|
|
70
|
+
} else {
|
|
71
|
+
delete providerWithPopup.getMentionDisabledState;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
setProvider(providerWithPopup);
|
|
75
|
+
}).catch(function () {});
|
|
76
|
+
return function () {
|
|
77
|
+
var _cleanupProvider;
|
|
78
|
+
isMounted = false;
|
|
79
|
+
(_cleanupProvider = cleanupProvider) === null || _cleanupProvider === void 0 || _cleanupProvider();
|
|
80
|
+
setProvider(null);
|
|
81
|
+
};
|
|
82
|
+
}, [mentionProvider]);
|
|
83
|
+
var removePendingMention = (0, _react.useCallback)(function () {
|
|
84
|
+
var _api$core;
|
|
85
|
+
var pending = pendingMentionRef.current;
|
|
86
|
+
if (pending && api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core = _api$core.actions) !== null && _api$core !== void 0 && _api$core.execute) {
|
|
87
|
+
api.core.actions.execute(function (_ref2) {
|
|
88
|
+
var tr = _ref2.tr;
|
|
89
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
90
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
pendingMentionRef.current = null;
|
|
94
|
+
setAnchorElement(null);
|
|
95
|
+
}, [api]);
|
|
96
|
+
var handleDismiss = (0, _react.useCallback)(function () {
|
|
97
|
+
removePendingMention();
|
|
98
|
+
}, [removePendingMention]);
|
|
99
|
+
var handleInviteComplete = (0, _react.useCallback)(function (result) {
|
|
100
|
+
var _result$invited$, _api$core2, _api$mention;
|
|
101
|
+
var pending = pendingMentionRef.current;
|
|
102
|
+
if (!pending) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
106
|
+
if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2 = _api$core2.actions) !== null && _api$core2 !== void 0 && _api$core2.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention = _api$mention.commands) !== null && _api$mention !== void 0 && _api$mention.insertMention)) {
|
|
107
|
+
removePendingMention();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
var userId = invitedUser.id,
|
|
111
|
+
email = invitedUser.email;
|
|
112
|
+
api.core.actions.execute(function (_ref3) {
|
|
113
|
+
var tr = _ref3.tr;
|
|
114
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
115
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
116
|
+
});
|
|
117
|
+
api.core.actions.execute(api.mention.commands.insertMention({
|
|
118
|
+
id: userId,
|
|
119
|
+
name: email,
|
|
120
|
+
userType: 'DEFAULT',
|
|
121
|
+
accessLevel: 'CONTAINER'
|
|
122
|
+
}));
|
|
123
|
+
pendingMentionRef.current = null;
|
|
124
|
+
setAnchorElement(null);
|
|
125
|
+
}, [api, removePendingMention]);
|
|
126
|
+
var handleReady = (0, _react.useCallback)(function (show) {
|
|
127
|
+
if (!provider) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (show) {
|
|
131
|
+
provider.showInlineInvitePopup = function (email, localId) {
|
|
132
|
+
pendingMentionRef.current = {
|
|
133
|
+
email: email,
|
|
134
|
+
localId: localId
|
|
135
|
+
};
|
|
136
|
+
setTimeout(function () {
|
|
137
|
+
var range = findMentionRange(editorView.state.doc, localId);
|
|
138
|
+
var dom = range ? editorView.nodeDOM(range.from) : null;
|
|
139
|
+
setAnchorElement(dom instanceof HTMLElement ? dom : null);
|
|
140
|
+
show(email);
|
|
141
|
+
}, 0);
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
delete provider.showInlineInvitePopup;
|
|
145
|
+
}
|
|
146
|
+
}, [provider, editorView]);
|
|
147
|
+
if (!(provider !== null && provider !== void 0 && provider.InlineInvitePopup) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2 = _api$mention2.commands) !== null && _api$mention2 !== void 0 && _api$mention2.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3 = _api$core3.actions) !== null && _api$core3 !== void 0 && _api$core3.execute)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
var PopupComponent = provider.InlineInvitePopup;
|
|
151
|
+
return /*#__PURE__*/_react.default.createElement(PopupComponent, {
|
|
152
|
+
anchorElement: anchorElement,
|
|
153
|
+
onInviteComplete: handleInviteComplete,
|
|
154
|
+
onDismiss: handleDismiss,
|
|
155
|
+
onReady: handleReady
|
|
156
|
+
});
|
|
157
|
+
};
|
|
@@ -26,7 +26,6 @@ var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
|
|
|
26
26
|
var _editorCommands = require("../../editor-commands");
|
|
27
27
|
var _key = require("../../pm-plugins/key");
|
|
28
28
|
var _main = require("../../pm-plugins/main");
|
|
29
|
-
var _mentionPlaceholder = require("../../pm-plugins/mentionPlaceholder");
|
|
30
29
|
var _utils2 = require("../../pm-plugins/utils");
|
|
31
30
|
var _InviteItem = _interopRequireWildcard(require("../InviteItem"));
|
|
32
31
|
var _InviteItemWithEmailDomain = _interopRequireDefault(require("../InviteItem/InviteItemWithEmailDomain"));
|
|
@@ -67,7 +66,7 @@ var createInviteItem = function createInviteItem(_ref) {
|
|
|
67
66
|
var isSelected = _ref2.isSelected,
|
|
68
67
|
onClick = _ref2.onClick,
|
|
69
68
|
onHover = _ref2.onHover;
|
|
70
|
-
return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && (0, _platformFeatureFlags.fg)('
|
|
69
|
+
return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') ? /*#__PURE__*/_react.default.createElement(_InviteItemWithEmailDomain.default, {
|
|
71
70
|
productName: mentionProvider ? mentionProvider.productName : undefined,
|
|
72
71
|
selected: isSelected,
|
|
73
72
|
onMount: onInviteItemMount,
|
|
@@ -490,10 +489,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
490
489
|
// Don't fire event and the callback with selection by space press
|
|
491
490
|
if (mode !== 'space') {
|
|
492
491
|
var _mentionProvider$getS3, _mentionProvider$getS4;
|
|
493
|
-
fireEvent((0, _analytics.buildTypeAheadInviteItemClickedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, (0, _platformFeatureFlags.fg)('
|
|
492
|
+
fireEvent((0, _analytics.buildTypeAheadInviteItemClickedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch') ? {
|
|
494
493
|
isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
|
|
495
494
|
} : {}));
|
|
496
|
-
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && (0, _platformFeatureFlags.fg)('
|
|
495
|
+
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && (0, _platformFeatureFlags.fg)('inline_invite_from_mentions_kill_switch')) {
|
|
497
496
|
// Get the email from query, using the same logic as InviteItemWithEmailDomain
|
|
498
497
|
var emailDomain = mentionProvider.userEmailDomain;
|
|
499
498
|
var email = query || '';
|
|
@@ -502,13 +501,21 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
502
501
|
email = "".concat(email.toLowerCase(), "@").concat(emailDomain);
|
|
503
502
|
}
|
|
504
503
|
// If query already includes @, use it as is
|
|
505
|
-
if (email && mentionProvider.
|
|
506
|
-
|
|
507
|
-
var _tr =
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
504
|
+
if (email && mentionProvider.showInlineInvitePopup) {
|
|
505
|
+
var pendingLocalId = crypto.randomUUID();
|
|
506
|
+
var _tr = insert((0, _editorCommands.createSingleMentionFragment)({
|
|
507
|
+
mentionProvider: mentionProvider,
|
|
508
|
+
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
509
|
+
tr: state.tr,
|
|
510
|
+
sanitizePrivateContent: sanitizePrivateContent
|
|
511
|
+
})({
|
|
512
|
+
name: email,
|
|
513
|
+
id: pendingLocalId,
|
|
514
|
+
userType: 'DEFAULT',
|
|
515
|
+
localId: pendingLocalId,
|
|
516
|
+
accessLevel: 'CONTAINER'
|
|
517
|
+
}));
|
|
518
|
+
mentionProvider.showInlineInvitePopup(email, pendingLocalId);
|
|
512
519
|
return _tr;
|
|
513
520
|
}
|
|
514
521
|
} else if (mentionProvider.onInviteItemClick) {
|
|
@@ -16,8 +16,7 @@ import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
|
16
16
|
import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
|
|
17
17
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
18
18
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
19
|
-
import {
|
|
20
|
-
import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
|
|
19
|
+
import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
|
|
21
20
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
22
21
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
23
22
|
const processName = (name, intl) => {
|
|
@@ -137,12 +136,6 @@ const mentionsPlugin = ({
|
|
|
137
136
|
})
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
|
-
if (fg('jira_invites_auto_tag_new_user_in_mentions_fg')) {
|
|
141
|
-
plugins.push({
|
|
142
|
-
name: 'mentionPlaceholder',
|
|
143
|
-
plugin: () => createMentionPlaceholderPlugin()
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
139
|
return plugins;
|
|
147
140
|
},
|
|
148
141
|
contentComponent({
|
|
@@ -165,9 +158,10 @@ const mentionsPlugin = ({
|
|
|
165
158
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
|
|
166
159
|
mentionProvider: mentionProvider,
|
|
167
160
|
api: api
|
|
168
|
-
}), fg('
|
|
161
|
+
}), fg('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/React.createElement(InlineInvitePopupContainer, {
|
|
169
162
|
mentionProvider: mentionProvider,
|
|
170
|
-
api: api
|
|
163
|
+
api: api,
|
|
164
|
+
editorView: editorView
|
|
171
165
|
}));
|
|
172
166
|
}
|
|
173
167
|
});
|
|
@@ -51,7 +51,7 @@ const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
51
51
|
const AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
52
52
|
const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
53
53
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
54
|
-
const PACKAGE_VERSION = "16.0.
|
|
54
|
+
const PACKAGE_VERSION = "16.0.3";
|
|
55
55
|
const setProvider = provider => (state, dispatch) => {
|
|
56
56
|
if (dispatch) {
|
|
57
57
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { Popup } from '@atlaskit/popup/popup';
|
|
3
|
+
/**
|
|
4
|
+
* A `<Popup>` anchored to an externally-supplied DOM node. Unlike `PopupTrigger`, it has no
|
|
5
|
+
* clickable trigger of its own — it opens whenever `isOpen` becomes true, so callers can drive
|
|
6
|
+
* it from any external signal.
|
|
7
|
+
*/
|
|
8
|
+
export function AnchoredPopup({
|
|
9
|
+
anchorElement,
|
|
10
|
+
content,
|
|
11
|
+
isOpen,
|
|
12
|
+
onClose
|
|
13
|
+
}) {
|
|
14
|
+
const renderContent = useCallback(() => isOpen ? content : null, [isOpen, content]);
|
|
15
|
+
const renderTrigger = useCallback(triggerProps => {
|
|
16
|
+
if (anchorElement && typeof triggerProps.ref === 'function') {
|
|
17
|
+
triggerProps.ref(anchorElement);
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}, [anchorElement]);
|
|
21
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
22
|
+
isOpen: isOpen,
|
|
23
|
+
onClose: onClose,
|
|
24
|
+
placement: "bottom-start",
|
|
25
|
+
content: renderContent,
|
|
26
|
+
trigger: renderTrigger
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* InlineInvitePopupContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
const findMentionRange = (doc, localId) => {
|
|
5
|
+
let range = null;
|
|
6
|
+
doc.descendants((node, pos) => {
|
|
7
|
+
if (range) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (node.type.name === 'mention' && node.attrs.localId === localId) {
|
|
11
|
+
range = {
|
|
12
|
+
from: pos,
|
|
13
|
+
to: pos + node.nodeSize
|
|
14
|
+
};
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
return range;
|
|
20
|
+
};
|
|
21
|
+
export const InlineInvitePopupContainer = ({
|
|
22
|
+
mentionProvider,
|
|
23
|
+
api,
|
|
24
|
+
editorView
|
|
25
|
+
}) => {
|
|
26
|
+
var _api$mention2, _api$mention2$command, _api$core3, _api$core3$actions;
|
|
27
|
+
const [provider, setProvider] = useState(null);
|
|
28
|
+
const [anchorElement, setAnchorElement] = useState(null);
|
|
29
|
+
const pendingMentionRef = useRef(null);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!mentionProvider) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let isMounted = true;
|
|
35
|
+
let cleanupProvider;
|
|
36
|
+
mentionProvider.then(resolvedProvider => {
|
|
37
|
+
var _providerWithPopup$ge;
|
|
38
|
+
if (!isMounted) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const providerWithPopup = resolvedProvider;
|
|
42
|
+
const originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
|
|
43
|
+
providerWithPopup.getMentionDisabledState = mention => {
|
|
44
|
+
var _pendingMentionRef$cu;
|
|
45
|
+
if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
|
|
46
|
+
return {
|
|
47
|
+
disabled: true
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
|
|
51
|
+
};
|
|
52
|
+
cleanupProvider = () => {
|
|
53
|
+
if (originalGetMentionDisabledState) {
|
|
54
|
+
providerWithPopup.getMentionDisabledState = originalGetMentionDisabledState;
|
|
55
|
+
} else {
|
|
56
|
+
delete providerWithPopup.getMentionDisabledState;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
setProvider(providerWithPopup);
|
|
60
|
+
}).catch(() => {});
|
|
61
|
+
return () => {
|
|
62
|
+
var _cleanupProvider;
|
|
63
|
+
isMounted = false;
|
|
64
|
+
(_cleanupProvider = cleanupProvider) === null || _cleanupProvider === void 0 ? void 0 : _cleanupProvider();
|
|
65
|
+
setProvider(null);
|
|
66
|
+
};
|
|
67
|
+
}, [mentionProvider]);
|
|
68
|
+
const removePendingMention = useCallback(() => {
|
|
69
|
+
var _api$core, _api$core$actions;
|
|
70
|
+
const pending = pendingMentionRef.current;
|
|
71
|
+
if (pending && api !== null && api !== void 0 && (_api$core = api.core) !== null && _api$core !== void 0 && (_api$core$actions = _api$core.actions) !== null && _api$core$actions !== void 0 && _api$core$actions.execute) {
|
|
72
|
+
api.core.actions.execute(({
|
|
73
|
+
tr
|
|
74
|
+
}) => {
|
|
75
|
+
const range = findMentionRange(tr.doc, pending.localId);
|
|
76
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
pendingMentionRef.current = null;
|
|
80
|
+
setAnchorElement(null);
|
|
81
|
+
}, [api]);
|
|
82
|
+
const handleDismiss = useCallback(() => {
|
|
83
|
+
removePendingMention();
|
|
84
|
+
}, [removePendingMention]);
|
|
85
|
+
const handleInviteComplete = useCallback(result => {
|
|
86
|
+
var _result$invited$, _api$core2, _api$core2$actions, _api$mention, _api$mention$commands;
|
|
87
|
+
const pending = pendingMentionRef.current;
|
|
88
|
+
if (!pending) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
92
|
+
if (!invitedUser || !(api !== null && api !== void 0 && (_api$core2 = api.core) !== null && _api$core2 !== void 0 && (_api$core2$actions = _api$core2.actions) !== null && _api$core2$actions !== void 0 && _api$core2$actions.execute) || !(api !== null && api !== void 0 && (_api$mention = api.mention) !== null && _api$mention !== void 0 && (_api$mention$commands = _api$mention.commands) !== null && _api$mention$commands !== void 0 && _api$mention$commands.insertMention)) {
|
|
93
|
+
removePendingMention();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const {
|
|
97
|
+
id: userId,
|
|
98
|
+
email
|
|
99
|
+
} = invitedUser;
|
|
100
|
+
api.core.actions.execute(({
|
|
101
|
+
tr
|
|
102
|
+
}) => {
|
|
103
|
+
const range = findMentionRange(tr.doc, pending.localId);
|
|
104
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
105
|
+
});
|
|
106
|
+
api.core.actions.execute(api.mention.commands.insertMention({
|
|
107
|
+
id: userId,
|
|
108
|
+
name: email,
|
|
109
|
+
userType: 'DEFAULT',
|
|
110
|
+
accessLevel: 'CONTAINER'
|
|
111
|
+
}));
|
|
112
|
+
pendingMentionRef.current = null;
|
|
113
|
+
setAnchorElement(null);
|
|
114
|
+
}, [api, removePendingMention]);
|
|
115
|
+
const handleReady = useCallback(show => {
|
|
116
|
+
if (!provider) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (show) {
|
|
120
|
+
provider.showInlineInvitePopup = (email, localId) => {
|
|
121
|
+
pendingMentionRef.current = {
|
|
122
|
+
email,
|
|
123
|
+
localId
|
|
124
|
+
};
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
const range = findMentionRange(editorView.state.doc, localId);
|
|
127
|
+
const dom = range ? editorView.nodeDOM(range.from) : null;
|
|
128
|
+
setAnchorElement(dom instanceof HTMLElement ? dom : null);
|
|
129
|
+
show(email);
|
|
130
|
+
}, 0);
|
|
131
|
+
};
|
|
132
|
+
} else {
|
|
133
|
+
delete provider.showInlineInvitePopup;
|
|
134
|
+
}
|
|
135
|
+
}, [provider, editorView]);
|
|
136
|
+
if (!(provider !== null && provider !== void 0 && provider.InlineInvitePopup) || !(api !== null && api !== void 0 && (_api$mention2 = api.mention) !== null && _api$mention2 !== void 0 && (_api$mention2$command = _api$mention2.commands) !== null && _api$mention2$command !== void 0 && _api$mention2$command.insertMention) || !(api !== null && api !== void 0 && (_api$core3 = api.core) !== null && _api$core3 !== void 0 && (_api$core3$actions = _api$core3.actions) !== null && _api$core3$actions !== void 0 && _api$core3$actions.execute)) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const PopupComponent = provider.InlineInvitePopup;
|
|
140
|
+
return /*#__PURE__*/React.createElement(PopupComponent, {
|
|
141
|
+
anchorElement: anchorElement,
|
|
142
|
+
onInviteComplete: handleInviteComplete,
|
|
143
|
+
onDismiss: handleDismiss,
|
|
144
|
+
onReady: handleReady
|
|
145
|
+
});
|
|
146
|
+
};
|
|
@@ -16,7 +16,6 @@ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
|
16
16
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
17
17
|
import { mentionPluginKey } from '../../pm-plugins/key';
|
|
18
18
|
import { ACTIONS } from '../../pm-plugins/main';
|
|
19
|
-
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
20
19
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
21
20
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
22
21
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
@@ -44,7 +43,7 @@ const createInviteItem = ({
|
|
|
44
43
|
onHover
|
|
45
44
|
}) => {
|
|
46
45
|
var _mentionProvider$getS;
|
|
47
|
-
return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && fg('
|
|
46
|
+
return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && fg('inline_invite_from_mentions_kill_switch') ? /*#__PURE__*/React.createElement(InviteItemWithEmailDomain, {
|
|
48
47
|
productName: mentionProvider ? mentionProvider.productName : undefined,
|
|
49
48
|
selected: isSelected,
|
|
50
49
|
onMount: onInviteItemMount,
|
|
@@ -460,10 +459,10 @@ export const createTypeAheadConfig = ({
|
|
|
460
459
|
// Don't fire event and the callback with selection by space press
|
|
461
460
|
if (mode !== 'space') {
|
|
462
461
|
var _mentionProvider$getS3, _mentionProvider$getS4;
|
|
463
|
-
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('
|
|
462
|
+
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('inline_invite_from_mentions_kill_switch') ? {
|
|
464
463
|
isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
|
|
465
464
|
} : {}));
|
|
466
|
-
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('
|
|
465
|
+
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('inline_invite_from_mentions_kill_switch')) {
|
|
467
466
|
// Get the email from query, using the same logic as InviteItemWithEmailDomain
|
|
468
467
|
const emailDomain = mentionProvider.userEmailDomain;
|
|
469
468
|
let email = query || '';
|
|
@@ -472,15 +471,21 @@ export const createTypeAheadConfig = ({
|
|
|
472
471
|
email = `${email.toLowerCase()}@${emailDomain}`;
|
|
473
472
|
}
|
|
474
473
|
// If query already includes @, use it as is
|
|
475
|
-
if (email && mentionProvider.
|
|
476
|
-
|
|
477
|
-
const {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
474
|
+
if (email && mentionProvider.showInlineInvitePopup) {
|
|
475
|
+
const pendingLocalId = crypto.randomUUID();
|
|
476
|
+
const tr = insert(createSingleMentionFragment({
|
|
477
|
+
mentionProvider,
|
|
478
|
+
mentionInsertDisplayName,
|
|
479
|
+
tr: state.tr,
|
|
480
|
+
sanitizePrivateContent
|
|
481
|
+
})({
|
|
482
|
+
name: email,
|
|
483
|
+
id: pendingLocalId,
|
|
484
|
+
userType: 'DEFAULT',
|
|
485
|
+
localId: pendingLocalId,
|
|
486
|
+
accessLevel: 'CONTAINER'
|
|
487
|
+
}));
|
|
488
|
+
mentionProvider.showInlineInvitePopup(email, pendingLocalId);
|
|
484
489
|
return tr;
|
|
485
490
|
}
|
|
486
491
|
} else if (mentionProvider.onInviteItemClick) {
|