@atlaskit/editor-plugin-mentions 2.10.8 → 2.11.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 +20 -0
- package/dist/cjs/mentionsPlugin.js +57 -4
- package/dist/cjs/nodeviews/mention.js +8 -4
- package/dist/cjs/pm-plugins/main.js +30 -14
- package/dist/cjs/ui/InviteItem/index.js +15 -3
- package/dist/cjs/ui/Mention/index.js +6 -0
- package/dist/cjs/ui/ToolbarMention/index.js +2 -0
- package/dist/cjs/ui/type-ahead/analytics.js +16 -4
- package/dist/cjs/ui/type-ahead/index.js +19 -3
- package/dist/cjs/ui/type-ahead/utils.js +7 -0
- package/dist/es2019/mentionsPlugin.js +30 -3
- package/dist/es2019/nodeviews/mention.js +9 -5
- package/dist/es2019/pm-plugins/main.js +21 -5
- package/dist/es2019/ui/InviteItem/index.js +15 -3
- package/dist/es2019/ui/Mention/index.js +6 -0
- package/dist/es2019/ui/ToolbarMention/index.js +2 -0
- package/dist/es2019/ui/type-ahead/analytics.js +16 -4
- package/dist/es2019/ui/type-ahead/index.js +20 -4
- package/dist/es2019/ui/type-ahead/utils.js +9 -1
- package/dist/esm/mentionsPlugin.js +58 -5
- package/dist/esm/nodeviews/mention.js +8 -4
- package/dist/esm/pm-plugins/main.js +29 -14
- package/dist/esm/ui/InviteItem/index.js +15 -3
- package/dist/esm/ui/Mention/index.js +6 -0
- package/dist/esm/ui/ToolbarMention/index.js +2 -0
- package/dist/esm/ui/type-ahead/analytics.js +16 -4
- package/dist/esm/ui/type-ahead/index.js +19 -3
- package/dist/esm/ui/type-ahead/utils.js +8 -0
- package/dist/types/mentionsPluginType.d.ts +8 -0
- package/dist/types/nodeviews/mention.d.ts +3 -0
- package/dist/types/pm-plugins/main.d.ts +13 -2
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types-ts4.5/mentionsPluginType.d.ts +8 -0
- package/dist/types-ts4.5/nodeviews/mention.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +13 -2
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#99344](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99344)
|
|
8
|
+
[`fbeb84f180cd2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fbeb84f180cd2) -
|
|
9
|
+
Added optional `isEligibleXProductUserInvite` and `inviteXProductUser` props which will be used in
|
|
10
|
+
CCEDITIONS-4746 (x-product-user-invite experiment). Project poster link -
|
|
11
|
+
https://hello.atlassian.net/wiki/spaces/CV1/pages/3685626022/Project+poster+-+Cross+Product+User+Search+Invites
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 2.10.9
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.10.8
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -5,13 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.mentionsPlugin = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
11
|
var _react = _interopRequireDefault(require("react"));
|
|
10
12
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
11
13
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
12
14
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
15
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
16
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
18
|
var _key = require("./pm-plugins/key");
|
|
16
19
|
var _main = require("./pm-plugins/main");
|
|
17
20
|
var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
|
|
@@ -22,6 +25,7 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
22
25
|
var options = _ref.config,
|
|
23
26
|
api = _ref.api;
|
|
24
27
|
var sessionId = (0, _uuid.default)();
|
|
28
|
+
var previousMediaProvider;
|
|
25
29
|
var fireEvent = function fireEvent(payload, channel) {
|
|
26
30
|
var _api$analytics;
|
|
27
31
|
var fireAnalyticsEvent = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent;
|
|
@@ -53,7 +57,12 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
53
57
|
return [{
|
|
54
58
|
name: 'mention',
|
|
55
59
|
plugin: function plugin(pmPluginFactoryParams) {
|
|
56
|
-
return (0, _main.createMentionPlugin)(
|
|
60
|
+
return (0, _main.createMentionPlugin)({
|
|
61
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
62
|
+
fireEvent: fireEvent,
|
|
63
|
+
options: options,
|
|
64
|
+
api: api
|
|
65
|
+
});
|
|
57
66
|
}
|
|
58
67
|
}];
|
|
59
68
|
},
|
|
@@ -79,7 +88,51 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
79
88
|
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
80
89
|
options.handleMentionsChanged(mentionChanges);
|
|
81
90
|
}
|
|
82
|
-
}
|
|
91
|
+
},
|
|
92
|
+
setProvider: function () {
|
|
93
|
+
var _setProvider = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(providerPromise) {
|
|
94
|
+
var _api$core$actions$exe;
|
|
95
|
+
var provider;
|
|
96
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
97
|
+
while (1) switch (_context.prev = _context.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_mention_provider_via_plugin_config')) {
|
|
100
|
+
_context.next = 2;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return _context.abrupt("return", false);
|
|
104
|
+
case 2:
|
|
105
|
+
_context.next = 4;
|
|
106
|
+
return providerPromise;
|
|
107
|
+
case 4:
|
|
108
|
+
provider = _context.sent;
|
|
109
|
+
if (!(previousMediaProvider === provider)) {
|
|
110
|
+
_context.next = 7;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
return _context.abrupt("return", false);
|
|
114
|
+
case 7:
|
|
115
|
+
previousMediaProvider = provider;
|
|
116
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref3) {
|
|
117
|
+
var tr = _ref3.tr;
|
|
118
|
+
return tr.setMeta(_key.mentionPluginKey, {
|
|
119
|
+
action: _main.ACTIONS.SET_PROVIDER,
|
|
120
|
+
params: {
|
|
121
|
+
provider: provider
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
125
|
+
case 9:
|
|
126
|
+
case "end":
|
|
127
|
+
return _context.stop();
|
|
128
|
+
}
|
|
129
|
+
}, _callee);
|
|
130
|
+
}));
|
|
131
|
+
function setProvider(_x) {
|
|
132
|
+
return _setProvider.apply(this, arguments);
|
|
133
|
+
}
|
|
134
|
+
return setProvider;
|
|
135
|
+
}()
|
|
83
136
|
},
|
|
84
137
|
getSharedState: function getSharedState(editorState) {
|
|
85
138
|
if (!editorState) {
|
|
@@ -91,8 +144,8 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
91
144
|
});
|
|
92
145
|
},
|
|
93
146
|
pluginsOptions: {
|
|
94
|
-
quickInsert: function quickInsert(
|
|
95
|
-
var formatMessage =
|
|
147
|
+
quickInsert: function quickInsert(_ref4) {
|
|
148
|
+
var formatMessage = _ref4.formatMessage;
|
|
96
149
|
return [{
|
|
97
150
|
id: 'mention',
|
|
98
151
|
title: formatMessage(_messages.toolbarInsertBlockMessages.mention),
|
|
@@ -6,25 +6,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.MentionNodeView = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
9
10
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
10
11
|
var _Mention = require("../ui/Mention");
|
|
11
12
|
var MentionNodeView = exports.MentionNodeView = function MentionNodeView(props) {
|
|
12
|
-
var providerFactory = props.providerFactory
|
|
13
|
+
var providerFactory = props.providerFactory,
|
|
14
|
+
pluginInjectionApi = props.pluginInjectionApi;
|
|
13
15
|
var _props$node$attrs = props.node.attrs,
|
|
14
16
|
id = _props$node$attrs.id,
|
|
15
17
|
text = _props$node$attrs.text,
|
|
16
18
|
accessLevel = _props$node$attrs.accessLevel,
|
|
17
19
|
localId = _props$node$attrs.localId;
|
|
20
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['mention']),
|
|
21
|
+
mentionState = _useSharedPluginState.mentionState;
|
|
22
|
+
var mentionProvider = mentionState === null || mentionState === void 0 ? void 0 : mentionState.mentionProvider;
|
|
18
23
|
var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
|
|
19
24
|
var _props$options;
|
|
20
|
-
var
|
|
21
|
-
mentionProvider = _ref.mentionProvider;
|
|
25
|
+
var mentionProviderPromise = mentionProvider ? Promise.resolve(mentionProvider) : providers.mentionProvider;
|
|
22
26
|
var profilecardProvider = (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider;
|
|
23
27
|
return /*#__PURE__*/_react.default.createElement(_Mention.Mention, {
|
|
24
28
|
id: id,
|
|
25
29
|
text: text,
|
|
26
30
|
accessLevel: accessLevel,
|
|
27
|
-
mentionProvider:
|
|
31
|
+
mentionProvider: mentionProviderPromise,
|
|
28
32
|
profilecardProvider: profilecardProvider,
|
|
29
33
|
localId: localId
|
|
30
34
|
});
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.ACTIONS = void 0;
|
|
7
8
|
exports.createMentionPlugin = createMentionPlugin;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -19,11 +20,11 @@ var _key = require("./key");
|
|
|
19
20
|
var _utils2 = require("./utils");
|
|
20
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
22
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
22
|
-
var ACTIONS = {
|
|
23
|
+
var ACTIONS = exports.ACTIONS = {
|
|
23
24
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
24
25
|
};
|
|
25
26
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
26
|
-
var PACKAGE_VERSION = "2.
|
|
27
|
+
var PACKAGE_VERSION = "2.11.0";
|
|
27
28
|
var setProvider = function setProvider(provider) {
|
|
28
29
|
return function (state, dispatch) {
|
|
29
30
|
if (dispatch) {
|
|
@@ -37,9 +38,16 @@ var setProvider = function setProvider(provider) {
|
|
|
37
38
|
return true;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
|
-
function createMentionPlugin(
|
|
41
|
+
function createMentionPlugin(_ref) {
|
|
42
|
+
var pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
43
|
+
fireEvent = _ref.fireEvent,
|
|
44
|
+
options = _ref.options,
|
|
45
|
+
api = _ref.api;
|
|
41
46
|
var mentionProvider;
|
|
42
|
-
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes
|
|
47
|
+
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
50
|
+
) {
|
|
43
51
|
if (event === _resource.SLI_EVENT_TYPE || event === _resource.SMART_EVENT_TYPE) {
|
|
44
52
|
fireEvent({
|
|
45
53
|
action: action,
|
|
@@ -62,13 +70,15 @@ function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
62
70
|
canInsertMention: canInsertMention
|
|
63
71
|
};
|
|
64
72
|
},
|
|
73
|
+
// Ignored via go/ees005
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
65
75
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
66
|
-
var
|
|
76
|
+
var _ref2 = tr.getMeta(_key.mentionPluginKey) || {
|
|
67
77
|
action: null,
|
|
68
78
|
params: null
|
|
69
79
|
},
|
|
70
|
-
action =
|
|
71
|
-
params =
|
|
80
|
+
action = _ref2.action,
|
|
81
|
+
params = _ref2.params;
|
|
72
82
|
var hasNewPluginState = false;
|
|
73
83
|
var newPluginState = pluginState;
|
|
74
84
|
var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
@@ -99,6 +109,7 @@ function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
99
109
|
Component: _mention.MentionNodeView,
|
|
100
110
|
extraComponentProps: {
|
|
101
111
|
providerFactory: pmPluginFactoryParams.providerFactory,
|
|
112
|
+
pluginInjectionApi: api,
|
|
102
113
|
options: options
|
|
103
114
|
}
|
|
104
115
|
})
|
|
@@ -143,7 +154,12 @@ function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
143
154
|
}
|
|
144
155
|
return;
|
|
145
156
|
};
|
|
146
|
-
|
|
157
|
+
var providerViaConfig = (0, _platformFeatureFlags.fg)('platform_editor_mention_provider_via_plugin_config');
|
|
158
|
+
if (providerViaConfig && options !== null && options !== void 0 && options.mentionProvider) {
|
|
159
|
+
providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
|
|
160
|
+
} else {
|
|
161
|
+
pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
|
|
162
|
+
}
|
|
147
163
|
return {
|
|
148
164
|
destroy: function destroy() {
|
|
149
165
|
if (pmPluginFactoryParams.providerFactory) {
|
|
@@ -158,16 +174,16 @@ function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
158
174
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && (0, _platformFeatureFlags.fg)('confluence_updated_mentions_livepages')) {
|
|
159
175
|
var mentionSchema = newState.schema.nodes.mention;
|
|
160
176
|
var mentionNodesBefore = (0, _utils.findChildrenByType)(prevState.doc, mentionSchema);
|
|
161
|
-
var mentionLocalIdsAfter = new Set((0, _utils.findChildrenByType)(newState.doc, mentionSchema).map(function (
|
|
162
|
-
var node =
|
|
177
|
+
var mentionLocalIdsAfter = new Set((0, _utils.findChildrenByType)(newState.doc, mentionSchema).map(function (_ref3) {
|
|
178
|
+
var node = _ref3.node;
|
|
163
179
|
return node.attrs.localId;
|
|
164
180
|
}));
|
|
165
181
|
if (mentionNodesBefore.length > mentionLocalIdsAfter.size) {
|
|
166
|
-
var deletedMentions = mentionNodesBefore.filter(function (
|
|
167
|
-
var node = _ref3.node;
|
|
168
|
-
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
169
|
-
}).map(function (_ref4) {
|
|
182
|
+
var deletedMentions = mentionNodesBefore.filter(function (_ref4) {
|
|
170
183
|
var node = _ref4.node;
|
|
184
|
+
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
185
|
+
}).map(function (_ref5) {
|
|
186
|
+
var node = _ref5.node;
|
|
171
187
|
return {
|
|
172
188
|
type: 'deleted',
|
|
173
189
|
id: node.attrs.id,
|
|
@@ -26,6 +26,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
26
26
|
var INVITE_ITEM_DESCRIPTION = exports.INVITE_ITEM_DESCRIPTION = {
|
|
27
27
|
id: 'invite-teammate'
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
// Ignored via go/ees005
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
32
|
var leftClick = function leftClick(event) {
|
|
30
33
|
return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
31
34
|
};
|
|
@@ -37,13 +40,19 @@ var InviteItem = function InviteItem(_ref) {
|
|
|
37
40
|
selected = _ref.selected,
|
|
38
41
|
userRole = _ref.userRole,
|
|
39
42
|
intl = _ref.intl;
|
|
40
|
-
var onSelected = (0, _react.useCallback)(
|
|
43
|
+
var onSelected = (0, _react.useCallback)(
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
function (event) {
|
|
41
47
|
if (leftClick(event) && onSelection) {
|
|
42
48
|
event.preventDefault();
|
|
43
49
|
onSelection(INVITE_ITEM_DESCRIPTION, event);
|
|
44
50
|
}
|
|
45
51
|
}, [onSelection]);
|
|
46
|
-
var onItemMouseEnter = (0, _react.useCallback)(
|
|
52
|
+
var onItemMouseEnter = (0, _react.useCallback)(
|
|
53
|
+
// Ignored via go/ees005
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
function (event) {
|
|
47
56
|
if (onMouseEnter) {
|
|
48
57
|
onMouseEnter(INVITE_ITEM_DESCRIPTION, event);
|
|
49
58
|
}
|
|
@@ -71,7 +80,10 @@ var InviteItem = function InviteItem(_ref) {
|
|
|
71
80
|
})), (0, _react2.jsx)("div", {
|
|
72
81
|
css: _styles.nameSectionStyle,
|
|
73
82
|
"data-testid": "name-section"
|
|
74
|
-
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage
|
|
83
|
+
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage
|
|
84
|
+
// Ignored via go/ees005
|
|
85
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
86
|
+
, (0, _extends2.default)({}, _messages.mentionMessages.inviteItemTitle, {
|
|
75
87
|
values: {
|
|
76
88
|
userRole: userRole || 'basic',
|
|
77
89
|
productName:
|
|
@@ -97,6 +97,8 @@ var Mention = exports.Mention = function Mention(props) {
|
|
|
97
97
|
}, []);
|
|
98
98
|
var actionHandlers = {};
|
|
99
99
|
['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (handler) {
|
|
100
|
+
// Ignored via go/ees005
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
102
|
actionHandlers[handler] = eventHandlers && eventHandlers[handler] || function () {};
|
|
101
103
|
});
|
|
102
104
|
if (profilecardProvider) {
|
|
@@ -108,6 +110,8 @@ var Mention = exports.Mention = function Mention(props) {
|
|
|
108
110
|
mentionProvider: mentionProvider,
|
|
109
111
|
profilecardProvider: profilecardProvider,
|
|
110
112
|
localId: localId
|
|
113
|
+
// Ignored via go/ees005
|
|
114
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
111
115
|
}, actionHandlers));
|
|
112
116
|
} else {
|
|
113
117
|
return /*#__PURE__*/_react.default.createElement(_element.ResourcedMention, (0, _extends2.default)({
|
|
@@ -116,6 +120,8 @@ var Mention = exports.Mention = function Mention(props) {
|
|
|
116
120
|
accessLevel: accessLevel,
|
|
117
121
|
mentionProvider: mentionProvider,
|
|
118
122
|
localId: localId
|
|
123
|
+
// Ignored via go/ees005
|
|
124
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
119
125
|
}, actionHandlers));
|
|
120
126
|
}
|
|
121
127
|
};
|
|
@@ -21,6 +21,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
21
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
22
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
23
23
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
24
26
|
var ToolbarMention = /*#__PURE__*/function (_PureComponent) {
|
|
25
27
|
function ToolbarMention() {
|
|
26
28
|
var _this;
|
|
@@ -21,7 +21,10 @@ var extractAttributesFromQuery = function extractAttributesFromQuery(query) {
|
|
|
21
21
|
}
|
|
22
22
|
return emptyQueryResponse;
|
|
23
23
|
};
|
|
24
|
-
var buildTypeAheadCancelPayload = exports.buildTypeAheadCancelPayload = function buildTypeAheadCancelPayload(duration, upKeyCount, downKeyCount, sessionId, query
|
|
24
|
+
var buildTypeAheadCancelPayload = exports.buildTypeAheadCancelPayload = function buildTypeAheadCancelPayload(duration, upKeyCount, downKeyCount, sessionId, query
|
|
25
|
+
// Ignored via go/ees005
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
27
|
+
) {
|
|
25
28
|
var _extractAttributesFro = extractAttributesFromQuery(query),
|
|
26
29
|
queryLength = _extractAttributesFro.queryLength,
|
|
27
30
|
spaceInQuery = _extractAttributesFro.spaceInQuery;
|
|
@@ -71,7 +74,10 @@ var buildTypeAheadInviteItemViewedPayload = exports.buildTypeAheadInviteItemView
|
|
|
71
74
|
}
|
|
72
75
|
};
|
|
73
76
|
};
|
|
74
|
-
var buildTypeAheadInviteItemClickedPayload = exports.buildTypeAheadInviteItemClickedPayload = function buildTypeAheadInviteItemClickedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
77
|
+
var buildTypeAheadInviteItemClickedPayload = exports.buildTypeAheadInviteItemClickedPayload = function buildTypeAheadInviteItemClickedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole
|
|
78
|
+
// Ignored via go/ees005
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
|
+
) {
|
|
75
81
|
var _extractAttributesFro2 = extractAttributesFromQuery(query),
|
|
76
82
|
queryLength = _extractAttributesFro2.queryLength,
|
|
77
83
|
spaceInQuery = _extractAttributesFro2.spaceInQuery;
|
|
@@ -99,7 +105,10 @@ var buildTypeAheadInviteItemClickedPayload = exports.buildTypeAheadInviteItemCli
|
|
|
99
105
|
}
|
|
100
106
|
};
|
|
101
107
|
};
|
|
102
|
-
var buildTypeAheadInsertedPayload = exports.buildTypeAheadInsertedPayload = function buildTypeAheadInsertedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
108
|
+
var buildTypeAheadInsertedPayload = exports.buildTypeAheadInsertedPayload = function buildTypeAheadInsertedPayload(duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionLocalId, mentionList, query, contextIdentifierProvider, taskListId, taskItemId
|
|
109
|
+
// Ignored via go/ees005
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
111
|
+
) {
|
|
103
112
|
var _extractAttributesFro3 = extractAttributesFromQuery(query),
|
|
104
113
|
queryLength = _extractAttributesFro3.queryLength,
|
|
105
114
|
spaceInQuery = _extractAttributesFro3.spaceInQuery;
|
|
@@ -140,7 +149,10 @@ var buildTypeAheadInsertedPayload = exports.buildTypeAheadInsertedPayload = func
|
|
|
140
149
|
}
|
|
141
150
|
};
|
|
142
151
|
};
|
|
143
|
-
var buildTypeAheadRenderedPayload = exports.buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams
|
|
152
|
+
var buildTypeAheadRenderedPayload = exports.buildTypeAheadRenderedPayload = function buildTypeAheadRenderedPayload(duration, userIds, query, teams
|
|
153
|
+
// Ignored via go/ees005
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
155
|
+
) {
|
|
144
156
|
var _extractAttributesFro4 = extractAttributesFromQuery(query),
|
|
145
157
|
queryLength = _extractAttributesFro4.queryLength,
|
|
146
158
|
spaceInQuery = _extractAttributesFro4.spaceInQuery;
|
|
@@ -133,7 +133,11 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
133
133
|
teams = mentions.map(function (mention) {
|
|
134
134
|
return (0, _utils4.isTeamType)(mention.userType) ? {
|
|
135
135
|
teamId: mention.id,
|
|
136
|
+
// Ignored via go/ees005
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
138
|
includesYou: mention.context.includesYou,
|
|
139
|
+
// Ignored via go/ees005
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
137
141
|
memberCount: mention.context.memberCount
|
|
138
142
|
} : null;
|
|
139
143
|
}).filter(function (m) {
|
|
@@ -149,7 +153,10 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
149
153
|
* When a team mention is selected, we render a team link and list of member/user mentions
|
|
150
154
|
* in editor content
|
|
151
155
|
*/
|
|
152
|
-
var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
156
|
+
var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selectedMention, mentionProvider, sanitizePrivateContent
|
|
157
|
+
// Ignored via go/ees005
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
159
|
+
) {
|
|
153
160
|
var nodes = schema.nodes,
|
|
154
161
|
marks = schema.marks;
|
|
155
162
|
var name = selectedMention.name,
|
|
@@ -162,7 +169,10 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
162
169
|
var teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
163
170
|
var teamLinkNode = (0, _platformFeatureFlags.fg)('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
164
171
|
url: teamLink
|
|
165
|
-
}) :
|
|
172
|
+
}) :
|
|
173
|
+
// Ignored via go/ees005
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
175
|
+
schema.text(name, [marks.link.create({
|
|
166
176
|
href: teamLink
|
|
167
177
|
})]);
|
|
168
178
|
var openBracketText = schema.text('(');
|
|
@@ -273,6 +283,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
273
283
|
onOpen: function onOpen() {
|
|
274
284
|
firstQueryWithoutResults = null;
|
|
275
285
|
},
|
|
286
|
+
// Ignored via go/ees005
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
276
288
|
selectItem: function selectItem(state, item, insert, _ref9) {
|
|
277
289
|
var _api$contextIdentifie3, _api$contextIdentifie4;
|
|
278
290
|
var mode = _ref9.mode,
|
|
@@ -287,7 +299,8 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
287
299
|
name = _item$mention.name,
|
|
288
300
|
nickname = _item$mention.nickname,
|
|
289
301
|
accessLevel = _item$mention.accessLevel,
|
|
290
|
-
userType = _item$mention.userType
|
|
302
|
+
userType = _item$mention.userType,
|
|
303
|
+
isXProductUser = _item$mention.isXProductUser;
|
|
291
304
|
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
292
305
|
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
293
306
|
var _ref10 = (_api$contextIdentifie3 = api === null || api === void 0 || (_api$contextIdentifie4 = api.contextIdentifier) === null || _api$contextIdentifie4 === void 0 ? void 0 : _api$contextIdentifie4.sharedState.currentState()) !== null && _api$contextIdentifie3 !== void 0 ? _api$contextIdentifie3 : {},
|
|
@@ -344,6 +357,9 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
344
357
|
if (mentionProvider && (0, _utils4.isTeamType)(userType)) {
|
|
345
358
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
346
359
|
}
|
|
360
|
+
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
361
|
+
mentionProvider.inviteXProductUser(id);
|
|
362
|
+
}
|
|
347
363
|
|
|
348
364
|
// Don't insert into document if document data is sanitized.
|
|
349
365
|
var text = sanitizePrivateContent ? '' : "@".concat(renderName);
|
|
@@ -5,9 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = void 0;
|
|
7
7
|
var _InviteItem = require("../InviteItem");
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
10
|
var isTeamType = exports.isTeamType = function isTeamType(userType) {
|
|
9
11
|
return userType === 'TEAM';
|
|
10
12
|
};
|
|
13
|
+
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
16
|
var isTeamStats = exports.isTeamStats = function isTeamStats(stat) {
|
|
12
17
|
return stat && !isNaN(stat.teamMentionDuration);
|
|
13
18
|
};
|
|
@@ -27,6 +32,8 @@ var shouldKeepInviteItem = exports.shouldKeepInviteItem = function shouldKeepInv
|
|
|
27
32
|
if (query[lastIndexWithResults - 1] === ' ') {
|
|
28
33
|
suffix = ' ' + suffix;
|
|
29
34
|
}
|
|
35
|
+
// Ignored via go/ees005
|
|
36
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
30
37
|
var depletedExtraWords = /\s[^\s]+\s/.test(suffix);
|
|
31
38
|
return !depletedExtraWords;
|
|
32
39
|
};
|
|
@@ -4,15 +4,17 @@ import { mention } from '@atlaskit/adf-schema';
|
|
|
4
4
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
8
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
8
|
-
import { createMentionPlugin } from './pm-plugins/main';
|
|
9
|
+
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
9
10
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
10
11
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
11
12
|
const mentionsPlugin = ({
|
|
12
13
|
config: options,
|
|
13
14
|
api
|
|
14
15
|
}) => {
|
|
15
|
-
|
|
16
|
+
const sessionId = uuid();
|
|
17
|
+
let previousMediaProvider;
|
|
16
18
|
const fireEvent = (payload, channel) => {
|
|
17
19
|
var _api$analytics, _api$analytics$action;
|
|
18
20
|
const fireAnalyticsEvent = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent;
|
|
@@ -43,7 +45,12 @@ const mentionsPlugin = ({
|
|
|
43
45
|
pmPlugins() {
|
|
44
46
|
return [{
|
|
45
47
|
name: 'mention',
|
|
46
|
-
plugin: pmPluginFactoryParams => createMentionPlugin(
|
|
48
|
+
plugin: pmPluginFactoryParams => createMentionPlugin({
|
|
49
|
+
pmPluginFactoryParams,
|
|
50
|
+
fireEvent,
|
|
51
|
+
options,
|
|
52
|
+
api
|
|
53
|
+
})
|
|
47
54
|
}];
|
|
48
55
|
},
|
|
49
56
|
secondaryToolbarComponent({
|
|
@@ -69,6 +76,26 @@ const mentionsPlugin = ({
|
|
|
69
76
|
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
70
77
|
options.handleMentionsChanged(mentionChanges);
|
|
71
78
|
}
|
|
79
|
+
},
|
|
80
|
+
setProvider: async providerPromise => {
|
|
81
|
+
var _api$core$actions$exe;
|
|
82
|
+
if (!fg('platform_editor_mention_provider_via_plugin_config')) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
const provider = await providerPromise;
|
|
86
|
+
// Prevent someone trying to set the exact same provider twice for performance reasons
|
|
87
|
+
if (previousMediaProvider === provider) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
previousMediaProvider = provider;
|
|
91
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
92
|
+
tr
|
|
93
|
+
}) => tr.setMeta(mentionPluginKey, {
|
|
94
|
+
action: ACTIONS.SET_PROVIDER,
|
|
95
|
+
params: {
|
|
96
|
+
provider
|
|
97
|
+
}
|
|
98
|
+
}))) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false;
|
|
72
99
|
}
|
|
73
100
|
},
|
|
74
101
|
getSharedState(editorState) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
3
4
|
import { Mention } from '../ui/Mention';
|
|
4
5
|
export const MentionNodeView = props => {
|
|
5
6
|
const {
|
|
6
|
-
providerFactory
|
|
7
|
+
providerFactory,
|
|
8
|
+
pluginInjectionApi
|
|
7
9
|
} = props;
|
|
8
10
|
const {
|
|
9
11
|
id,
|
|
@@ -11,17 +13,19 @@ export const MentionNodeView = props => {
|
|
|
11
13
|
accessLevel,
|
|
12
14
|
localId
|
|
13
15
|
} = props.node.attrs;
|
|
16
|
+
const {
|
|
17
|
+
mentionState
|
|
18
|
+
} = useSharedPluginState(pluginInjectionApi, ['mention']);
|
|
19
|
+
const mentionProvider = mentionState === null || mentionState === void 0 ? void 0 : mentionState.mentionProvider;
|
|
14
20
|
const renderAssistiveTextWithProviders = providers => {
|
|
15
21
|
var _props$options;
|
|
16
|
-
const
|
|
17
|
-
mentionProvider
|
|
18
|
-
} = providers;
|
|
22
|
+
const mentionProviderPromise = mentionProvider ? Promise.resolve(mentionProvider) : providers.mentionProvider;
|
|
19
23
|
const profilecardProvider = (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider;
|
|
20
24
|
return /*#__PURE__*/React.createElement(Mention, {
|
|
21
25
|
id: id,
|
|
22
26
|
text: text,
|
|
23
27
|
accessLevel: accessLevel,
|
|
24
|
-
mentionProvider:
|
|
28
|
+
mentionProvider: mentionProviderPromise,
|
|
25
29
|
profilecardProvider: profilecardProvider,
|
|
26
30
|
localId: localId
|
|
27
31
|
});
|
|
@@ -9,11 +9,11 @@ import { MentionNodeView } from '../nodeviews/mention';
|
|
|
9
9
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
10
10
|
import { mentionPluginKey } from './key';
|
|
11
11
|
import { canMentionBeCreatedInRange } from './utils';
|
|
12
|
-
const ACTIONS = {
|
|
12
|
+
export const ACTIONS = {
|
|
13
13
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
14
14
|
};
|
|
15
15
|
const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
16
|
-
const PACKAGE_VERSION = "2.
|
|
16
|
+
const PACKAGE_VERSION = "2.11.0";
|
|
17
17
|
const setProvider = provider => (state, dispatch) => {
|
|
18
18
|
if (dispatch) {
|
|
19
19
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -25,9 +25,17 @@ const setProvider = provider => (state, dispatch) => {
|
|
|
25
25
|
}
|
|
26
26
|
return true;
|
|
27
27
|
};
|
|
28
|
-
export function createMentionPlugin(
|
|
28
|
+
export function createMentionPlugin({
|
|
29
|
+
pmPluginFactoryParams,
|
|
30
|
+
fireEvent,
|
|
31
|
+
options,
|
|
32
|
+
api
|
|
33
|
+
}) {
|
|
29
34
|
let mentionProvider;
|
|
30
|
-
const sendAnalytics = (event, actionSubject, action, attributes
|
|
35
|
+
const sendAnalytics = (event, actionSubject, action, attributes
|
|
36
|
+
// Ignored via go/ees005
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
38
|
+
) => {
|
|
31
39
|
if (event === SLI_EVENT_TYPE || event === SMART_EVENT_TYPE) {
|
|
32
40
|
fireEvent({
|
|
33
41
|
action: action,
|
|
@@ -51,6 +59,8 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
51
59
|
canInsertMention
|
|
52
60
|
};
|
|
53
61
|
},
|
|
62
|
+
// Ignored via go/ees005
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
54
64
|
apply(tr, pluginState, oldState, newState) {
|
|
55
65
|
const {
|
|
56
66
|
action,
|
|
@@ -91,6 +101,7 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
91
101
|
Component: MentionNodeView,
|
|
92
102
|
extraComponentProps: {
|
|
93
103
|
providerFactory: pmPluginFactoryParams.providerFactory,
|
|
104
|
+
pluginInjectionApi: api,
|
|
94
105
|
options
|
|
95
106
|
}
|
|
96
107
|
})
|
|
@@ -135,7 +146,12 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
135
146
|
}
|
|
136
147
|
return;
|
|
137
148
|
};
|
|
138
|
-
|
|
149
|
+
const providerViaConfig = fg('platform_editor_mention_provider_via_plugin_config');
|
|
150
|
+
if (providerViaConfig && options !== null && options !== void 0 && options.mentionProvider) {
|
|
151
|
+
providerHandler('mentionProvider', options === null || options === void 0 ? void 0 : options.mentionProvider);
|
|
152
|
+
} else {
|
|
153
|
+
pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
|
|
154
|
+
}
|
|
139
155
|
return {
|
|
140
156
|
destroy() {
|
|
141
157
|
if (pmPluginFactoryParams.providerFactory) {
|