@atlaskit/editor-plugin-mentions 15.1.1 → 15.2.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 +11 -0
- package/dist/cjs/mentionsPlugin.js +4 -12
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/InlineInvitePopupContainer.js +148 -0
- package/dist/cjs/ui/type-ahead/index.js +20 -11
- package/dist/es2019/mentionsPlugin.js +4 -10
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/InlineInvitePopupContainer.js +137 -0
- package/dist/es2019/ui/type-ahead/index.js +20 -13
- package/dist/esm/mentionsPlugin.js +4 -12
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/InlineInvitePopupContainer.js +139 -0
- package/dist/esm/ui/type-ahead/index.js +20 -11
- package/dist/types/ui/InlineInvitePopupContainer.d.ts +11 -0
- package/package.json +9 -3
- 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,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 15.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`0adaa36b0a6bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0adaa36b0a6bc) -
|
|
8
|
+
Add InlineInvitePopup provider hook, replacing InlineInviteRecaptcha slot
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 15.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -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 = "15.1.
|
|
70
|
+
var PACKAGE_VERSION = "15.1.1";
|
|
71
71
|
var setProvider = function setProvider(provider) {
|
|
72
72
|
return function (state, dispatch) {
|
|
73
73
|
if (dispatch) {
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
mentionProvider.then(function (resolvedProvider) {
|
|
51
|
+
var _providerWithPopup$ge;
|
|
52
|
+
if (!isMounted) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var providerWithPopup = resolvedProvider;
|
|
56
|
+
var originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
|
|
57
|
+
providerWithPopup.getMentionDisabledState = function (mention) {
|
|
58
|
+
var _pendingMentionRef$cu;
|
|
59
|
+
if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
|
|
60
|
+
return {
|
|
61
|
+
disabled: true
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
|
|
65
|
+
};
|
|
66
|
+
setProvider(providerWithPopup);
|
|
67
|
+
}).catch(function () {});
|
|
68
|
+
return function () {
|
|
69
|
+
isMounted = false;
|
|
70
|
+
setProvider(null);
|
|
71
|
+
};
|
|
72
|
+
}, [mentionProvider]);
|
|
73
|
+
var removePendingMention = (0, _react.useCallback)(function () {
|
|
74
|
+
var _api$core;
|
|
75
|
+
var pending = pendingMentionRef.current;
|
|
76
|
+
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) {
|
|
77
|
+
api.core.actions.execute(function (_ref2) {
|
|
78
|
+
var tr = _ref2.tr;
|
|
79
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
80
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
pendingMentionRef.current = null;
|
|
84
|
+
setAnchorElement(null);
|
|
85
|
+
}, [api]);
|
|
86
|
+
var handleDismiss = (0, _react.useCallback)(function () {
|
|
87
|
+
removePendingMention();
|
|
88
|
+
}, [removePendingMention]);
|
|
89
|
+
var handleInviteComplete = (0, _react.useCallback)(function (result) {
|
|
90
|
+
var _result$invited$, _api$core2, _api$mention;
|
|
91
|
+
var pending = pendingMentionRef.current;
|
|
92
|
+
if (!pending) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
96
|
+
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)) {
|
|
97
|
+
removePendingMention();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var userId = invitedUser.id,
|
|
101
|
+
email = invitedUser.email;
|
|
102
|
+
var name = email.split('@')[0] || email;
|
|
103
|
+
api.core.actions.execute(function (_ref3) {
|
|
104
|
+
var tr = _ref3.tr;
|
|
105
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
106
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
107
|
+
});
|
|
108
|
+
api.core.actions.execute(api.mention.commands.insertMention({
|
|
109
|
+
id: userId,
|
|
110
|
+
name: name,
|
|
111
|
+
userType: 'DEFAULT',
|
|
112
|
+
accessLevel: 'CONTAINER'
|
|
113
|
+
}));
|
|
114
|
+
pendingMentionRef.current = null;
|
|
115
|
+
setAnchorElement(null);
|
|
116
|
+
}, [api, removePendingMention]);
|
|
117
|
+
var handleReady = (0, _react.useCallback)(function (show) {
|
|
118
|
+
if (!provider) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (show) {
|
|
122
|
+
provider.showInlineInvitePopup = function (email, localId) {
|
|
123
|
+
pendingMentionRef.current = {
|
|
124
|
+
email: email,
|
|
125
|
+
localId: localId
|
|
126
|
+
};
|
|
127
|
+
setTimeout(function () {
|
|
128
|
+
var range = findMentionRange(editorView.state.doc, localId);
|
|
129
|
+
var dom = range ? editorView.nodeDOM(range.from) : null;
|
|
130
|
+
setAnchorElement(dom instanceof HTMLElement ? dom : null);
|
|
131
|
+
show(email);
|
|
132
|
+
}, 0);
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
delete provider.showInlineInvitePopup;
|
|
136
|
+
}
|
|
137
|
+
}, [provider, editorView]);
|
|
138
|
+
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)) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
var PopupComponent = provider.InlineInvitePopup;
|
|
142
|
+
return /*#__PURE__*/_react.default.createElement(PopupComponent, {
|
|
143
|
+
anchorElement: anchorElement,
|
|
144
|
+
onInviteComplete: handleInviteComplete,
|
|
145
|
+
onDismiss: handleDismiss,
|
|
146
|
+
onReady: handleReady
|
|
147
|
+
});
|
|
148
|
+
};
|
|
@@ -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,23 @@ 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
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
504
|
+
if (email && mentionProvider.showInlineInvitePopup) {
|
|
505
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
506
|
+
var pendingLocalId = (0, _uuid.default)();
|
|
507
|
+
var pendingName = email.split('@')[0] || email;
|
|
508
|
+
var _tr = insert((0, _editorCommands.createSingleMentionFragment)({
|
|
509
|
+
mentionProvider: mentionProvider,
|
|
510
|
+
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
511
|
+
tr: state.tr,
|
|
512
|
+
sanitizePrivateContent: sanitizePrivateContent
|
|
513
|
+
})({
|
|
514
|
+
name: pendingName,
|
|
515
|
+
id: pendingLocalId,
|
|
516
|
+
userType: 'DEFAULT',
|
|
517
|
+
localId: pendingLocalId,
|
|
518
|
+
accessLevel: 'CONTAINER'
|
|
519
|
+
}));
|
|
520
|
+
mentionProvider.showInlineInvitePopup(email, pendingLocalId);
|
|
512
521
|
return _tr;
|
|
513
522
|
}
|
|
514
523
|
} 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 = "15.1.
|
|
54
|
+
const PACKAGE_VERSION = "15.1.1";
|
|
55
55
|
const setProvider = provider => (state, dispatch) => {
|
|
56
56
|
if (dispatch) {
|
|
57
57
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
mentionProvider.then(resolvedProvider => {
|
|
36
|
+
var _providerWithPopup$ge;
|
|
37
|
+
if (!isMounted) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const providerWithPopup = resolvedProvider;
|
|
41
|
+
const originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
|
|
42
|
+
providerWithPopup.getMentionDisabledState = mention => {
|
|
43
|
+
var _pendingMentionRef$cu;
|
|
44
|
+
if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
|
|
45
|
+
return {
|
|
46
|
+
disabled: true
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
|
|
50
|
+
};
|
|
51
|
+
setProvider(providerWithPopup);
|
|
52
|
+
}).catch(() => {});
|
|
53
|
+
return () => {
|
|
54
|
+
isMounted = false;
|
|
55
|
+
setProvider(null);
|
|
56
|
+
};
|
|
57
|
+
}, [mentionProvider]);
|
|
58
|
+
const removePendingMention = useCallback(() => {
|
|
59
|
+
var _api$core, _api$core$actions;
|
|
60
|
+
const pending = pendingMentionRef.current;
|
|
61
|
+
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) {
|
|
62
|
+
api.core.actions.execute(({
|
|
63
|
+
tr
|
|
64
|
+
}) => {
|
|
65
|
+
const range = findMentionRange(tr.doc, pending.localId);
|
|
66
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
pendingMentionRef.current = null;
|
|
70
|
+
setAnchorElement(null);
|
|
71
|
+
}, [api]);
|
|
72
|
+
const handleDismiss = useCallback(() => {
|
|
73
|
+
removePendingMention();
|
|
74
|
+
}, [removePendingMention]);
|
|
75
|
+
const handleInviteComplete = useCallback(result => {
|
|
76
|
+
var _result$invited$, _api$core2, _api$core2$actions, _api$mention, _api$mention$commands;
|
|
77
|
+
const pending = pendingMentionRef.current;
|
|
78
|
+
if (!pending) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
82
|
+
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)) {
|
|
83
|
+
removePendingMention();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const {
|
|
87
|
+
id: userId,
|
|
88
|
+
email
|
|
89
|
+
} = invitedUser;
|
|
90
|
+
const name = email.split('@')[0] || email;
|
|
91
|
+
api.core.actions.execute(({
|
|
92
|
+
tr
|
|
93
|
+
}) => {
|
|
94
|
+
const range = findMentionRange(tr.doc, pending.localId);
|
|
95
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
96
|
+
});
|
|
97
|
+
api.core.actions.execute(api.mention.commands.insertMention({
|
|
98
|
+
id: userId,
|
|
99
|
+
name,
|
|
100
|
+
userType: 'DEFAULT',
|
|
101
|
+
accessLevel: 'CONTAINER'
|
|
102
|
+
}));
|
|
103
|
+
pendingMentionRef.current = null;
|
|
104
|
+
setAnchorElement(null);
|
|
105
|
+
}, [api, removePendingMention]);
|
|
106
|
+
const handleReady = useCallback(show => {
|
|
107
|
+
if (!provider) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (show) {
|
|
111
|
+
provider.showInlineInvitePopup = (email, localId) => {
|
|
112
|
+
pendingMentionRef.current = {
|
|
113
|
+
email,
|
|
114
|
+
localId
|
|
115
|
+
};
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
const range = findMentionRange(editorView.state.doc, localId);
|
|
118
|
+
const dom = range ? editorView.nodeDOM(range.from) : null;
|
|
119
|
+
setAnchorElement(dom instanceof HTMLElement ? dom : null);
|
|
120
|
+
show(email);
|
|
121
|
+
}, 0);
|
|
122
|
+
};
|
|
123
|
+
} else {
|
|
124
|
+
delete provider.showInlineInvitePopup;
|
|
125
|
+
}
|
|
126
|
+
}, [provider, editorView]);
|
|
127
|
+
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)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const PopupComponent = provider.InlineInvitePopup;
|
|
131
|
+
return /*#__PURE__*/React.createElement(PopupComponent, {
|
|
132
|
+
anchorElement: anchorElement,
|
|
133
|
+
onInviteComplete: handleInviteComplete,
|
|
134
|
+
onDismiss: handleDismiss,
|
|
135
|
+
onReady: handleReady
|
|
136
|
+
});
|
|
137
|
+
};
|
|
@@ -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,23 @@ 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
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
476
|
+
const pendingLocalId = uuid();
|
|
477
|
+
const pendingName = email.split('@')[0] || email;
|
|
478
|
+
const tr = insert(createSingleMentionFragment({
|
|
479
|
+
mentionProvider,
|
|
480
|
+
mentionInsertDisplayName,
|
|
481
|
+
tr: state.tr,
|
|
482
|
+
sanitizePrivateContent
|
|
483
|
+
})({
|
|
484
|
+
name: pendingName,
|
|
485
|
+
id: pendingLocalId,
|
|
486
|
+
userType: 'DEFAULT',
|
|
487
|
+
localId: pendingLocalId,
|
|
488
|
+
accessLevel: 'CONTAINER'
|
|
489
|
+
}));
|
|
490
|
+
mentionProvider.showInlineInvitePopup(email, pendingLocalId);
|
|
484
491
|
return tr;
|
|
485
492
|
}
|
|
486
493
|
} else if (mentionProvider.onInviteItemClick) {
|
|
@@ -23,8 +23,7 @@ import { mentionNodeSpec } from './nodeviews/mentionNodeSpec';
|
|
|
23
23
|
import { agentMentionPluginKey, createAgentMentionPlugin } from './pm-plugins/agent';
|
|
24
24
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
25
25
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
26
|
-
import {
|
|
27
|
-
import { InlineInviteRecaptchaContainer } from './ui/InlineInviteRecaptchaContainer';
|
|
26
|
+
import { InlineInvitePopupContainer } from './ui/InlineInvitePopupContainer';
|
|
28
27
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
29
28
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
30
29
|
var processName = function processName(name, intl) {
|
|
@@ -137,14 +136,6 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
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: function plugin() {
|
|
144
|
-
return createMentionPlaceholderPlugin();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
139
|
return plugins;
|
|
149
140
|
},
|
|
150
141
|
contentComponent: function contentComponent(_ref4) {
|
|
@@ -165,9 +156,10 @@ var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
|
165
156
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, {
|
|
166
157
|
mentionProvider: mentionProvider,
|
|
167
158
|
api: api
|
|
168
|
-
}), fg('
|
|
159
|
+
}), fg('inline_invite_from_mentions_kill_switch') && /*#__PURE__*/React.createElement(InlineInvitePopupContainer, {
|
|
169
160
|
mentionProvider: mentionProvider,
|
|
170
|
-
api: api
|
|
161
|
+
api: api,
|
|
162
|
+
editorView: editorView
|
|
171
163
|
}));
|
|
172
164
|
}
|
|
173
165
|
});
|
|
@@ -58,7 +58,7 @@ var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
|
|
|
58
58
|
var AGENT_MENTION_INACTIVITY_MS = 3000;
|
|
59
59
|
var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
|
|
60
60
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
61
|
-
var PACKAGE_VERSION = "15.1.
|
|
61
|
+
var PACKAGE_VERSION = "15.1.1";
|
|
62
62
|
var setProvider = function setProvider(provider) {
|
|
63
63
|
return function (state, dispatch) {
|
|
64
64
|
if (dispatch) {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/* InlineInvitePopupContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
var findMentionRange = function findMentionRange(doc, localId) {
|
|
6
|
+
var range = null;
|
|
7
|
+
doc.descendants(function (node, pos) {
|
|
8
|
+
if (range) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (node.type.name === 'mention' && node.attrs.localId === localId) {
|
|
12
|
+
range = {
|
|
13
|
+
from: pos,
|
|
14
|
+
to: pos + node.nodeSize
|
|
15
|
+
};
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
return range;
|
|
21
|
+
};
|
|
22
|
+
export var InlineInvitePopupContainer = function InlineInvitePopupContainer(_ref) {
|
|
23
|
+
var _api$mention2, _api$core3;
|
|
24
|
+
var mentionProvider = _ref.mentionProvider,
|
|
25
|
+
api = _ref.api,
|
|
26
|
+
editorView = _ref.editorView;
|
|
27
|
+
var _useState = useState(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
provider = _useState2[0],
|
|
30
|
+
setProvider = _useState2[1];
|
|
31
|
+
var _useState3 = useState(null),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
anchorElement = _useState4[0],
|
|
34
|
+
setAnchorElement = _useState4[1];
|
|
35
|
+
var pendingMentionRef = useRef(null);
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
if (!mentionProvider) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var isMounted = true;
|
|
41
|
+
mentionProvider.then(function (resolvedProvider) {
|
|
42
|
+
var _providerWithPopup$ge;
|
|
43
|
+
if (!isMounted) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
var providerWithPopup = resolvedProvider;
|
|
47
|
+
var originalGetMentionDisabledState = (_providerWithPopup$ge = providerWithPopup.getMentionDisabledState) === null || _providerWithPopup$ge === void 0 ? void 0 : _providerWithPopup$ge.bind(providerWithPopup);
|
|
48
|
+
providerWithPopup.getMentionDisabledState = function (mention) {
|
|
49
|
+
var _pendingMentionRef$cu;
|
|
50
|
+
if (((_pendingMentionRef$cu = pendingMentionRef.current) === null || _pendingMentionRef$cu === void 0 ? void 0 : _pendingMentionRef$cu.localId) === mention.id) {
|
|
51
|
+
return {
|
|
52
|
+
disabled: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return originalGetMentionDisabledState === null || originalGetMentionDisabledState === void 0 ? void 0 : originalGetMentionDisabledState(mention);
|
|
56
|
+
};
|
|
57
|
+
setProvider(providerWithPopup);
|
|
58
|
+
}).catch(function () {});
|
|
59
|
+
return function () {
|
|
60
|
+
isMounted = false;
|
|
61
|
+
setProvider(null);
|
|
62
|
+
};
|
|
63
|
+
}, [mentionProvider]);
|
|
64
|
+
var removePendingMention = useCallback(function () {
|
|
65
|
+
var _api$core;
|
|
66
|
+
var pending = pendingMentionRef.current;
|
|
67
|
+
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) {
|
|
68
|
+
api.core.actions.execute(function (_ref2) {
|
|
69
|
+
var tr = _ref2.tr;
|
|
70
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
71
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
pendingMentionRef.current = null;
|
|
75
|
+
setAnchorElement(null);
|
|
76
|
+
}, [api]);
|
|
77
|
+
var handleDismiss = useCallback(function () {
|
|
78
|
+
removePendingMention();
|
|
79
|
+
}, [removePendingMention]);
|
|
80
|
+
var handleInviteComplete = useCallback(function (result) {
|
|
81
|
+
var _result$invited$, _api$core2, _api$mention;
|
|
82
|
+
var pending = pendingMentionRef.current;
|
|
83
|
+
if (!pending) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
var invitedUser = (_result$invited$ = result.invited[0]) !== null && _result$invited$ !== void 0 ? _result$invited$ : result.requested[0];
|
|
87
|
+
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)) {
|
|
88
|
+
removePendingMention();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
var userId = invitedUser.id,
|
|
92
|
+
email = invitedUser.email;
|
|
93
|
+
var name = email.split('@')[0] || email;
|
|
94
|
+
api.core.actions.execute(function (_ref3) {
|
|
95
|
+
var tr = _ref3.tr;
|
|
96
|
+
var range = findMentionRange(tr.doc, pending.localId);
|
|
97
|
+
return range ? tr.delete(range.from, range.to) : null;
|
|
98
|
+
});
|
|
99
|
+
api.core.actions.execute(api.mention.commands.insertMention({
|
|
100
|
+
id: userId,
|
|
101
|
+
name: name,
|
|
102
|
+
userType: 'DEFAULT',
|
|
103
|
+
accessLevel: 'CONTAINER'
|
|
104
|
+
}));
|
|
105
|
+
pendingMentionRef.current = null;
|
|
106
|
+
setAnchorElement(null);
|
|
107
|
+
}, [api, removePendingMention]);
|
|
108
|
+
var handleReady = useCallback(function (show) {
|
|
109
|
+
if (!provider) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (show) {
|
|
113
|
+
provider.showInlineInvitePopup = function (email, localId) {
|
|
114
|
+
pendingMentionRef.current = {
|
|
115
|
+
email: email,
|
|
116
|
+
localId: localId
|
|
117
|
+
};
|
|
118
|
+
setTimeout(function () {
|
|
119
|
+
var range = findMentionRange(editorView.state.doc, localId);
|
|
120
|
+
var dom = range ? editorView.nodeDOM(range.from) : null;
|
|
121
|
+
setAnchorElement(dom instanceof HTMLElement ? dom : null);
|
|
122
|
+
show(email);
|
|
123
|
+
}, 0);
|
|
124
|
+
};
|
|
125
|
+
} else {
|
|
126
|
+
delete provider.showInlineInvitePopup;
|
|
127
|
+
}
|
|
128
|
+
}, [provider, editorView]);
|
|
129
|
+
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)) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
var PopupComponent = provider.InlineInvitePopup;
|
|
133
|
+
return /*#__PURE__*/React.createElement(PopupComponent, {
|
|
134
|
+
anchorElement: anchorElement,
|
|
135
|
+
onInviteComplete: handleInviteComplete,
|
|
136
|
+
onDismiss: handleDismiss,
|
|
137
|
+
onReady: handleReady
|
|
138
|
+
});
|
|
139
|
+
};
|
|
@@ -23,7 +23,6 @@ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
|
|
|
23
23
|
import { createSingleMentionFragment } from '../../editor-commands';
|
|
24
24
|
import { mentionPluginKey } from '../../pm-plugins/key';
|
|
25
25
|
import { ACTIONS } from '../../pm-plugins/main';
|
|
26
|
-
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../../pm-plugins/mentionPlaceholder';
|
|
27
26
|
import { getMentionPluginState } from '../../pm-plugins/utils';
|
|
28
27
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../InviteItem';
|
|
29
28
|
import InviteItemWithEmailDomain from '../InviteItem/InviteItemWithEmailDomain';
|
|
@@ -58,7 +57,7 @@ var createInviteItem = function createInviteItem(_ref) {
|
|
|
58
57
|
var isSelected = _ref2.isSelected,
|
|
59
58
|
onClick = _ref2.onClick,
|
|
60
59
|
onHover = _ref2.onHover;
|
|
61
|
-
return emailDomain && (_mentionProvider$getS = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS !== void 0 && _mentionProvider$getS.call(mentionProvider) && fg('
|
|
60
|
+
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, {
|
|
62
61
|
productName: mentionProvider ? mentionProvider.productName : undefined,
|
|
63
62
|
selected: isSelected,
|
|
64
63
|
onMount: onInviteItemMount,
|
|
@@ -481,10 +480,10 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
481
480
|
// Don't fire event and the callback with selection by space press
|
|
482
481
|
if (mode !== 'space') {
|
|
483
482
|
var _mentionProvider$getS3, _mentionProvider$getS4;
|
|
484
|
-
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('
|
|
483
|
+
fireEvent(buildTypeAheadInviteItemClickedPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole, fg('inline_invite_from_mentions_kill_switch') ? {
|
|
485
484
|
isInlineInviteMentionsEnabled: (_mentionProvider$getS3 = mentionProvider.getShouldEnableInlineInvite) === null || _mentionProvider$getS3 === void 0 ? void 0 : _mentionProvider$getS3.call(mentionProvider)
|
|
486
485
|
} : {}));
|
|
487
|
-
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('
|
|
486
|
+
if ((_mentionProvider$getS4 = mentionProvider.getShouldEnableInlineInvite) !== null && _mentionProvider$getS4 !== void 0 && _mentionProvider$getS4.call(mentionProvider) && fg('inline_invite_from_mentions_kill_switch')) {
|
|
488
487
|
// Get the email from query, using the same logic as InviteItemWithEmailDomain
|
|
489
488
|
var emailDomain = mentionProvider.userEmailDomain;
|
|
490
489
|
var email = query || '';
|
|
@@ -493,13 +492,23 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
|
|
|
493
492
|
email = "".concat(email.toLowerCase(), "@").concat(emailDomain);
|
|
494
493
|
}
|
|
495
494
|
// If query already includes @, use it as is
|
|
496
|
-
if (email && mentionProvider.
|
|
497
|
-
|
|
498
|
-
var
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
495
|
+
if (email && mentionProvider.showInlineInvitePopup) {
|
|
496
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
497
|
+
var pendingLocalId = uuid();
|
|
498
|
+
var pendingName = email.split('@')[0] || email;
|
|
499
|
+
var _tr = insert(createSingleMentionFragment({
|
|
500
|
+
mentionProvider: mentionProvider,
|
|
501
|
+
mentionInsertDisplayName: mentionInsertDisplayName,
|
|
502
|
+
tr: state.tr,
|
|
503
|
+
sanitizePrivateContent: sanitizePrivateContent
|
|
504
|
+
})({
|
|
505
|
+
name: pendingName,
|
|
506
|
+
id: pendingLocalId,
|
|
507
|
+
userType: 'DEFAULT',
|
|
508
|
+
localId: pendingLocalId,
|
|
509
|
+
accessLevel: 'CONTAINER'
|
|
510
|
+
}));
|
|
511
|
+
mentionProvider.showInlineInvitePopup(email, pendingLocalId);
|
|
503
512
|
return _tr;
|
|
504
513
|
}
|
|
505
514
|
} else if (mentionProvider.onInviteItemClick) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
4
|
+
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
5
|
+
interface Props {
|
|
6
|
+
api: ExtractInjectionAPI<MentionsPlugin> | undefined;
|
|
7
|
+
editorView: EditorView;
|
|
8
|
+
mentionProvider: Promise<MentionProvider> | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare const InlineInvitePopupContainer: ({ mentionProvider, api, editorView, }: Props) => JSX.Element | null;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.2.0",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/insm": "^1.2.0",
|
|
35
35
|
"@atlaskit/link": "^5.0.0",
|
|
36
36
|
"@atlaskit/lozenge": "^15.0.0",
|
|
37
|
-
"@atlaskit/mention": "^27.
|
|
37
|
+
"@atlaskit/mention": "^27.13.0",
|
|
38
38
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
40
40
|
"@atlaskit/popper": "^9.0.0",
|
|
@@ -55,12 +55,15 @@
|
|
|
55
55
|
"uuid": "^3.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@atlaskit/editor-common": "^117.
|
|
58
|
+
"@atlaskit/editor-common": "^117.5.0",
|
|
59
59
|
"react": "^18.2.0 || ^19.2.0",
|
|
60
60
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
61
61
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@atlaskit/button": "^25.0.0",
|
|
65
|
+
"@atlaskit/editor-core": "^222.1.0",
|
|
66
|
+
"@atlaskit/popup": "^6.0.0",
|
|
64
67
|
"@testing-library/react": "^16.3.0",
|
|
65
68
|
"react": "^19.2.0",
|
|
66
69
|
"react-dom": "^19.2.0",
|
|
@@ -117,6 +120,9 @@
|
|
|
117
120
|
"jira_invites_auto_tag_new_user_in_mentions_fg": {
|
|
118
121
|
"type": "boolean"
|
|
119
122
|
},
|
|
123
|
+
"inline_invite_from_mentions_kill_switch": {
|
|
124
|
+
"type": "boolean"
|
|
125
|
+
},
|
|
120
126
|
"people-teams_migrate-user-profile-card": {
|
|
121
127
|
"type": "boolean"
|
|
122
128
|
},
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MENTION_PLACEHOLDER_ACTIONS = void 0;
|
|
7
|
-
exports.createMentionPlaceholderPlugin = createMentionPlaceholderPlugin;
|
|
8
|
-
exports.mentionPlaceholderPluginKey = void 0;
|
|
9
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
|
-
var mentionPlaceholderPluginKey = exports.mentionPlaceholderPluginKey = new _state.PluginKey('mentionPlaceholderPlugin');
|
|
13
|
-
var MENTION_PLACEHOLDER_ACTIONS = exports.MENTION_PLACEHOLDER_ACTIONS = {
|
|
14
|
-
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
15
|
-
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
16
|
-
};
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
18
|
-
function createMentionPlaceholderPlugin() {
|
|
19
|
-
return new _safePlugin.SafePlugin({
|
|
20
|
-
key: mentionPlaceholderPluginKey,
|
|
21
|
-
state: {
|
|
22
|
-
init: function init() {
|
|
23
|
-
return {};
|
|
24
|
-
},
|
|
25
|
-
apply: function apply(tr, pluginState) {
|
|
26
|
-
var meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
27
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
28
|
-
return {
|
|
29
|
-
placeholder: meta.placeholder
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
return pluginState;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
props: {
|
|
39
|
-
decorations: function decorations(state) {
|
|
40
|
-
var pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
41
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
42
|
-
var selection = state.selection;
|
|
43
|
-
var span = document.createElement('span');
|
|
44
|
-
span.textContent = pluginState.placeholder;
|
|
45
|
-
span.style.setProperty('color', "var(--ds-text-accent-blue, #1558BC)");
|
|
46
|
-
return _view.DecorationSet.create(state.doc, [_view.Decoration.widget(selection.from, span)]);
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/* InlineInviteRecaptchaContainer.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.InlineInviteRecaptchaContainer = 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
|
-
var _mentionPlaceholder = require("../pm-plugins/mentionPlaceholder");
|
|
14
|
-
var _analytics = require("../ui/type-ahead/analytics");
|
|
15
|
-
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); }
|
|
16
|
-
/**
|
|
17
|
-
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
18
|
-
* Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
|
|
19
|
-
* and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
|
|
20
|
-
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
21
|
-
*/
|
|
22
|
-
var InlineInviteRecaptchaContainer = exports.InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
|
|
23
|
-
var _api$mention2, _api$core3;
|
|
24
|
-
var mentionProvider = _ref.mentionProvider,
|
|
25
|
-
api = _ref.api;
|
|
26
|
-
var _useState = (0, _react.useState)(null),
|
|
27
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
28
|
-
provider = _useState2[0],
|
|
29
|
-
setProvider = _useState2[1];
|
|
30
|
-
(0, _react.useEffect)(function () {
|
|
31
|
-
if (!mentionProvider) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
var isMounted = true;
|
|
35
|
-
mentionProvider.then(function (resolvedProvider) {
|
|
36
|
-
if (!isMounted) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
setProvider(resolvedProvider);
|
|
40
|
-
}).catch(function () {
|
|
41
|
-
// Silently handle promise rejection
|
|
42
|
-
});
|
|
43
|
-
return function () {
|
|
44
|
-
isMounted = false;
|
|
45
|
-
setProvider(null);
|
|
46
|
-
};
|
|
47
|
-
}, [mentionProvider]);
|
|
48
|
-
var handleSuccess = (0, _react.useCallback)(function (userId, email) {
|
|
49
|
-
var _api$mention, _api$core;
|
|
50
|
-
if (!(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) || !(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)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
var name = email.split('@')[0] || email;
|
|
54
|
-
api.core.actions.execute(api.mention.commands.insertMention({
|
|
55
|
-
id: userId,
|
|
56
|
-
name: name,
|
|
57
|
-
userType: 'DEFAULT',
|
|
58
|
-
accessLevel: 'CONTAINER'
|
|
59
|
-
}));
|
|
60
|
-
api.core.actions.execute(function (_ref2) {
|
|
61
|
-
var tr = _ref2.tr;
|
|
62
|
-
tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
|
|
63
|
-
action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
64
|
-
});
|
|
65
|
-
return tr;
|
|
66
|
-
});
|
|
67
|
-
}, [api]);
|
|
68
|
-
var handleClose = (0, _react.useCallback)(function () {
|
|
69
|
-
var _api$core2;
|
|
70
|
-
if (!(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)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
api.core.actions.execute(function (_ref3) {
|
|
74
|
-
var tr = _ref3.tr;
|
|
75
|
-
tr.setMeta(_mentionPlaceholder.mentionPlaceholderPluginKey, {
|
|
76
|
-
action: _mentionPlaceholder.MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
77
|
-
});
|
|
78
|
-
return tr;
|
|
79
|
-
});
|
|
80
|
-
}, [api]);
|
|
81
|
-
var handleReady = (0, _react.useCallback)(function (showRecaptcha) {
|
|
82
|
-
if (provider) {
|
|
83
|
-
if (showRecaptcha) {
|
|
84
|
-
provider.showInlineInviteRecaptcha = showRecaptcha;
|
|
85
|
-
} else {
|
|
86
|
-
delete provider.showInlineInviteRecaptcha;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, [provider]);
|
|
90
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(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)) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
var RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
94
|
-
return /*#__PURE__*/_react.default.createElement(RecaptchaComponent, {
|
|
95
|
-
analyticsSource: _analytics.MENTION_SOURCE,
|
|
96
|
-
onSuccess: handleSuccess,
|
|
97
|
-
onClose: handleClose,
|
|
98
|
-
onReady: handleReady
|
|
99
|
-
});
|
|
100
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
export const mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
|
|
5
|
-
export const MENTION_PLACEHOLDER_ACTIONS = {
|
|
6
|
-
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
7
|
-
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
8
|
-
};
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
10
|
-
export function createMentionPlaceholderPlugin() {
|
|
11
|
-
return new SafePlugin({
|
|
12
|
-
key: mentionPlaceholderPluginKey,
|
|
13
|
-
state: {
|
|
14
|
-
init: () => ({}),
|
|
15
|
-
apply(tr, pluginState) {
|
|
16
|
-
const meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
17
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
18
|
-
return {
|
|
19
|
-
placeholder: meta.placeholder
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
return pluginState;
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
props: {
|
|
29
|
-
decorations: state => {
|
|
30
|
-
const pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
31
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
32
|
-
const {
|
|
33
|
-
selection
|
|
34
|
-
} = state;
|
|
35
|
-
const span = document.createElement('span');
|
|
36
|
-
span.textContent = pluginState.placeholder;
|
|
37
|
-
span.style.setProperty('color', "var(--ds-text-accent-blue, #1558BC)");
|
|
38
|
-
return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
3
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
|
|
5
|
-
import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
|
|
6
|
-
/**
|
|
7
|
-
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
8
|
-
* Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
|
|
9
|
-
* and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
|
|
10
|
-
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
11
|
-
*/
|
|
12
|
-
export const InlineInviteRecaptchaContainer = ({
|
|
13
|
-
mentionProvider,
|
|
14
|
-
api
|
|
15
|
-
}) => {
|
|
16
|
-
var _api$mention2, _api$mention2$command, _api$core3, _api$core3$actions;
|
|
17
|
-
const [provider, setProvider] = useState(null);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!mentionProvider) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
let isMounted = true;
|
|
23
|
-
mentionProvider.then(resolvedProvider => {
|
|
24
|
-
if (!isMounted) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
setProvider(resolvedProvider);
|
|
28
|
-
}).catch(() => {
|
|
29
|
-
// Silently handle promise rejection
|
|
30
|
-
});
|
|
31
|
-
return () => {
|
|
32
|
-
isMounted = false;
|
|
33
|
-
setProvider(null);
|
|
34
|
-
};
|
|
35
|
-
}, [mentionProvider]);
|
|
36
|
-
const handleSuccess = useCallback((userId, email) => {
|
|
37
|
-
var _api$mention, _api$mention$commands, _api$core, _api$core$actions;
|
|
38
|
-
if (!(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) || !(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)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const name = email.split('@')[0] || email;
|
|
42
|
-
api.core.actions.execute(api.mention.commands.insertMention({
|
|
43
|
-
id: userId,
|
|
44
|
-
name,
|
|
45
|
-
userType: 'DEFAULT',
|
|
46
|
-
accessLevel: 'CONTAINER'
|
|
47
|
-
}));
|
|
48
|
-
api.core.actions.execute(({
|
|
49
|
-
tr
|
|
50
|
-
}) => {
|
|
51
|
-
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
52
|
-
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
53
|
-
});
|
|
54
|
-
return tr;
|
|
55
|
-
});
|
|
56
|
-
}, [api]);
|
|
57
|
-
const handleClose = useCallback(() => {
|
|
58
|
-
var _api$core2, _api$core2$actions;
|
|
59
|
-
if (!(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)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
api.core.actions.execute(({
|
|
63
|
-
tr
|
|
64
|
-
}) => {
|
|
65
|
-
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
66
|
-
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
67
|
-
});
|
|
68
|
-
return tr;
|
|
69
|
-
});
|
|
70
|
-
}, [api]);
|
|
71
|
-
const handleReady = useCallback(showRecaptcha => {
|
|
72
|
-
if (provider) {
|
|
73
|
-
if (showRecaptcha) {
|
|
74
|
-
provider.showInlineInviteRecaptcha = showRecaptcha;
|
|
75
|
-
} else {
|
|
76
|
-
delete provider.showInlineInviteRecaptcha;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}, [provider]);
|
|
80
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(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)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
84
|
-
return /*#__PURE__*/React.createElement(RecaptchaComponent, {
|
|
85
|
-
analyticsSource: MENTION_SOURCE,
|
|
86
|
-
onSuccess: handleSuccess,
|
|
87
|
-
onClose: handleClose,
|
|
88
|
-
onReady: handleReady
|
|
89
|
-
});
|
|
90
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
export var mentionPlaceholderPluginKey = new PluginKey('mentionPlaceholderPlugin');
|
|
5
|
-
export var MENTION_PLACEHOLDER_ACTIONS = {
|
|
6
|
-
SHOW_PLACEHOLDER: 'SHOW_PLACEHOLDER',
|
|
7
|
-
HIDE_PLACEHOLDER: 'HIDE_PLACEHOLDER'
|
|
8
|
-
};
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
10
|
-
export function createMentionPlaceholderPlugin() {
|
|
11
|
-
return new SafePlugin({
|
|
12
|
-
key: mentionPlaceholderPluginKey,
|
|
13
|
-
state: {
|
|
14
|
-
init: function init() {
|
|
15
|
-
return {};
|
|
16
|
-
},
|
|
17
|
-
apply: function apply(tr, pluginState) {
|
|
18
|
-
var meta = tr.getMeta(mentionPlaceholderPluginKey);
|
|
19
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.SHOW_PLACEHOLDER) {
|
|
20
|
-
return {
|
|
21
|
-
placeholder: meta.placeholder
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.action) === MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER) {
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
return pluginState;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
props: {
|
|
31
|
-
decorations: function decorations(state) {
|
|
32
|
-
var pluginState = mentionPlaceholderPluginKey.getState(state);
|
|
33
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.placeholder) {
|
|
34
|
-
var selection = state.selection;
|
|
35
|
-
var span = document.createElement('span');
|
|
36
|
-
span.textContent = pluginState.placeholder;
|
|
37
|
-
span.style.setProperty('color', "var(--ds-text-accent-blue, #1558BC)");
|
|
38
|
-
return DecorationSet.create(state.doc, [Decoration.widget(selection.from, span)]);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/* InlineInviteRecaptchaContainer.tsx generated by @compiled/babel-plugin v2.0.0 */
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
5
|
-
import { mentionPlaceholderPluginKey, MENTION_PLACEHOLDER_ACTIONS } from '../pm-plugins/mentionPlaceholder';
|
|
6
|
-
import { MENTION_SOURCE } from '../ui/type-ahead/analytics';
|
|
7
|
-
/**
|
|
8
|
-
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
9
|
-
* Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
|
|
10
|
-
* and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
|
|
11
|
-
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
12
|
-
*/
|
|
13
|
-
export var InlineInviteRecaptchaContainer = function InlineInviteRecaptchaContainer(_ref) {
|
|
14
|
-
var _api$mention2, _api$core3;
|
|
15
|
-
var mentionProvider = _ref.mentionProvider,
|
|
16
|
-
api = _ref.api;
|
|
17
|
-
var _useState = useState(null),
|
|
18
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
-
provider = _useState2[0],
|
|
20
|
-
setProvider = _useState2[1];
|
|
21
|
-
useEffect(function () {
|
|
22
|
-
if (!mentionProvider) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
var isMounted = true;
|
|
26
|
-
mentionProvider.then(function (resolvedProvider) {
|
|
27
|
-
if (!isMounted) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
setProvider(resolvedProvider);
|
|
31
|
-
}).catch(function () {
|
|
32
|
-
// Silently handle promise rejection
|
|
33
|
-
});
|
|
34
|
-
return function () {
|
|
35
|
-
isMounted = false;
|
|
36
|
-
setProvider(null);
|
|
37
|
-
};
|
|
38
|
-
}, [mentionProvider]);
|
|
39
|
-
var handleSuccess = useCallback(function (userId, email) {
|
|
40
|
-
var _api$mention, _api$core;
|
|
41
|
-
if (!(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) || !(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)) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
var name = email.split('@')[0] || email;
|
|
45
|
-
api.core.actions.execute(api.mention.commands.insertMention({
|
|
46
|
-
id: userId,
|
|
47
|
-
name: name,
|
|
48
|
-
userType: 'DEFAULT',
|
|
49
|
-
accessLevel: 'CONTAINER'
|
|
50
|
-
}));
|
|
51
|
-
api.core.actions.execute(function (_ref2) {
|
|
52
|
-
var tr = _ref2.tr;
|
|
53
|
-
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
54
|
-
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
55
|
-
});
|
|
56
|
-
return tr;
|
|
57
|
-
});
|
|
58
|
-
}, [api]);
|
|
59
|
-
var handleClose = useCallback(function () {
|
|
60
|
-
var _api$core2;
|
|
61
|
-
if (!(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)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
api.core.actions.execute(function (_ref3) {
|
|
65
|
-
var tr = _ref3.tr;
|
|
66
|
-
tr.setMeta(mentionPlaceholderPluginKey, {
|
|
67
|
-
action: MENTION_PLACEHOLDER_ACTIONS.HIDE_PLACEHOLDER
|
|
68
|
-
});
|
|
69
|
-
return tr;
|
|
70
|
-
});
|
|
71
|
-
}, [api]);
|
|
72
|
-
var handleReady = useCallback(function (showRecaptcha) {
|
|
73
|
-
if (provider) {
|
|
74
|
-
if (showRecaptcha) {
|
|
75
|
-
provider.showInlineInviteRecaptcha = showRecaptcha;
|
|
76
|
-
} else {
|
|
77
|
-
delete provider.showInlineInviteRecaptcha;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}, [provider]);
|
|
81
|
-
if (!(provider !== null && provider !== void 0 && provider.InlineInviteRecaptcha) || !(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)) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
var RecaptchaComponent = provider.InlineInviteRecaptcha;
|
|
85
|
-
return /*#__PURE__*/React.createElement(RecaptchaComponent, {
|
|
86
|
-
analyticsSource: MENTION_SOURCE,
|
|
87
|
-
onSuccess: handleSuccess,
|
|
88
|
-
onClose: handleClose,
|
|
89
|
-
onReady: handleReady
|
|
90
|
-
});
|
|
91
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export declare const mentionPlaceholderPluginKey: PluginKey;
|
|
4
|
-
export declare const MENTION_PLACEHOLDER_ACTIONS: {
|
|
5
|
-
SHOW_PLACEHOLDER: string;
|
|
6
|
-
HIDE_PLACEHOLDER: string;
|
|
7
|
-
};
|
|
8
|
-
export type MentionPlaceholderPluginState = {
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function createMentionPlaceholderPlugin(): SafePlugin<{}>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
3
|
-
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
4
|
-
interface Props {
|
|
5
|
-
api: ExtractInjectionAPI<MentionsPlugin> | undefined;
|
|
6
|
-
mentionProvider: Promise<MentionProvider> | undefined;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Container that renders the recaptcha component from the mention provider and manages handleSuccess.
|
|
10
|
-
* Does NOT pass email - the provider's component uses useInlineInviteRecaptcha hook internally
|
|
11
|
-
* and wires showRecaptcha to the provider. When user clicks invite item, type-ahead calls
|
|
12
|
-
* mentionProvider.showInlineInviteRecaptcha(email) which passes email to the component.
|
|
13
|
-
*/
|
|
14
|
-
export declare const InlineInviteRecaptchaContainer: ({ mentionProvider, api, }: Props) => JSX.Element | null;
|
|
15
|
-
export {};
|