@atlaskit/editor-plugin-mentions 2.10.9 → 2.11.1
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 +25 -0
- package/dist/cjs/mentionsPlugin.js +135 -10
- package/dist/cjs/nodeviews/mention.js +8 -4
- package/dist/cjs/pm-plugins/main.js +24 -13
- package/dist/cjs/ui/type-ahead/index.js +23 -6
- package/dist/es2019/mentionsPlugin.js +112 -4
- package/dist/es2019/nodeviews/mention.js +9 -5
- package/dist/es2019/pm-plugins/main.js +15 -4
- package/dist/es2019/ui/type-ahead/index.js +23 -6
- package/dist/esm/mentionsPlugin.js +134 -12
- package/dist/esm/nodeviews/mention.js +8 -4
- package/dist/esm/pm-plugins/main.js +23 -13
- package/dist/esm/ui/type-ahead/index.js +23 -6
- package/dist/types/mentionsPluginType.d.ts +11 -1
- 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 +11 -1
- 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 +12 -5
|
@@ -141,6 +141,7 @@ const buildNodesForTeamMention = (schema, selectedMention, mentionProvider, sani
|
|
|
141
141
|
// build team link
|
|
142
142
|
const defaultTeamLink = `${window.location.origin}/people/team/${teamId}`;
|
|
143
143
|
const teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
144
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
144
145
|
const teamLinkNode = fg('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
145
146
|
url: teamLink
|
|
146
147
|
}) :
|
|
@@ -219,7 +220,7 @@ export const createTypeAheadConfig = ({
|
|
|
219
220
|
const {
|
|
220
221
|
contextIdentifierProvider
|
|
221
222
|
} = (_api$contextIdentifie = api === null || api === void 0 ? void 0 : (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {};
|
|
222
|
-
return new Promise(resolve => {
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
223
224
|
const key = `loadingMentionsForTypeAhead_${uuid()}`;
|
|
224
225
|
const mentionsSubscribeCallback = (mentions, resultQuery = '', stats) => {
|
|
225
226
|
if (query !== resultQuery) {
|
|
@@ -251,7 +252,13 @@ export const createTypeAheadConfig = ({
|
|
|
251
252
|
}
|
|
252
253
|
};
|
|
253
254
|
subscriptionKeys.add(key);
|
|
254
|
-
mentionProvider.subscribe(key, mentionsSubscribeCallback)
|
|
255
|
+
mentionProvider.subscribe(key, mentionsSubscribeCallback, () => {
|
|
256
|
+
if (fg('platform_editor_offline_editing_ga')) {
|
|
257
|
+
mentionProvider.unsubscribe(key);
|
|
258
|
+
subscriptionKeys.delete(key);
|
|
259
|
+
reject('FETCH_ERROR');
|
|
260
|
+
}
|
|
261
|
+
});
|
|
255
262
|
mentionProvider.filter(query || '', {
|
|
256
263
|
...contextIdentifierProvider,
|
|
257
264
|
sessionId
|
|
@@ -282,7 +289,8 @@ export const createTypeAheadConfig = ({
|
|
|
282
289
|
name,
|
|
283
290
|
nickname,
|
|
284
291
|
accessLevel,
|
|
285
|
-
userType
|
|
292
|
+
userType,
|
|
293
|
+
isXProductUser
|
|
286
294
|
} = item.mention;
|
|
287
295
|
const trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
288
296
|
const renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
@@ -340,6 +348,9 @@ export const createTypeAheadConfig = ({
|
|
|
340
348
|
if (mentionProvider && isTeamType(userType)) {
|
|
341
349
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
342
350
|
}
|
|
351
|
+
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
352
|
+
mentionProvider.inviteXProductUser(id);
|
|
353
|
+
}
|
|
343
354
|
|
|
344
355
|
// Don't insert into document if document data is sanitized.
|
|
345
356
|
const text = sanitizePrivateContent ? '' : `@${renderName}`;
|
|
@@ -347,15 +358,21 @@ export const createTypeAheadConfig = ({
|
|
|
347
358
|
// Cache (locally) for later rendering
|
|
348
359
|
mentionProvider.cacheMentionName(id, renderName);
|
|
349
360
|
}
|
|
350
|
-
const annotationMarksForPos = fg(
|
|
361
|
+
const annotationMarksForPos = fg(
|
|
362
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
363
|
+
'editor_inline_comments_paste_insert_nodes') ? getAnnotationMarksForPos(state.tr.selection.$head) : undefined;
|
|
351
364
|
const mentionNode = schema.nodes.mention.createChecked({
|
|
352
365
|
text,
|
|
353
366
|
id,
|
|
354
367
|
accessLevel,
|
|
355
368
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
356
369
|
localId: mentionLocalId
|
|
357
|
-
}, null,
|
|
358
|
-
|
|
370
|
+
}, null,
|
|
371
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
372
|
+
fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
373
|
+
const space = schema.text(' ',
|
|
374
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
375
|
+
fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
359
376
|
return insert(Fragment.from([mentionNode, space]));
|
|
360
377
|
},
|
|
361
378
|
dismiss({
|
|
@@ -1,20 +1,79 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
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; }
|
|
3
4
|
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) { _defineProperty(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; }
|
|
4
|
-
import
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
import React, { useEffect, useMemo } from 'react';
|
|
7
|
+
import { useIntl } from 'react-intl-next';
|
|
5
8
|
import uuid from 'uuid';
|
|
6
9
|
import { mention } from '@atlaskit/adf-schema';
|
|
7
10
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
|
+
import { toolbarInsertBlockMessages as messages, mentionMessages } from '@atlaskit/editor-common/messages';
|
|
12
|
+
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
9
13
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
14
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
15
|
+
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
17
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
11
|
-
import { createMentionPlugin } from './pm-plugins/main';
|
|
18
|
+
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
12
19
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
13
20
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
14
|
-
var
|
|
15
|
-
var
|
|
21
|
+
var processName = function processName(name, intl) {
|
|
22
|
+
var unknownLabel = intl.formatMessage(mentionMessages.unknownLabel);
|
|
23
|
+
if (name.status === MentionNameStatus.OK) {
|
|
24
|
+
return "@".concat(name.name || unknownLabel);
|
|
25
|
+
} else {
|
|
26
|
+
return "@".concat(unknownLabel);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* We will need to clean this up once mentionProvider is
|
|
32
|
+
* put inside mention plugin.
|
|
33
|
+
* See: https://product-fabric.atlassian.net/browse/ED-26011
|
|
34
|
+
*/
|
|
35
|
+
function Component(_ref) {
|
|
36
|
+
var mentionProvider = _ref.mentionProvider,
|
|
16
37
|
api = _ref.api;
|
|
38
|
+
var mentionProviderMemo = useMemo(function () {
|
|
39
|
+
return mentionProvider;
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, []);
|
|
42
|
+
var intl = useIntl();
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
mentionProviderMemo === null || mentionProviderMemo === void 0 || mentionProviderMemo.then(function (mentionProviderSync) {
|
|
45
|
+
var _api$base;
|
|
46
|
+
api === null || api === void 0 || (_api$base = api.base) === null || _api$base === void 0 || (_api$base = _api$base.actions) === null || _api$base === void 0 || _api$base.registerMarks(function (_ref2) {
|
|
47
|
+
var tr = _ref2.tr,
|
|
48
|
+
node = _ref2.node,
|
|
49
|
+
pos = _ref2.pos;
|
|
50
|
+
var doc = tr.doc;
|
|
51
|
+
var schema = doc.type.schema;
|
|
52
|
+
var mentionNodeType = schema.nodes.mention;
|
|
53
|
+
var id = node.attrs.id;
|
|
54
|
+
if (node.type === mentionNodeType) {
|
|
55
|
+
if (isResolvingMentionProvider(mentionProviderSync)) {
|
|
56
|
+
var nameDetail = mentionProviderSync === null || mentionProviderSync === void 0 ? void 0 : mentionProviderSync.resolveMentionName(id);
|
|
57
|
+
var newText;
|
|
58
|
+
if (isPromise(nameDetail)) {
|
|
59
|
+
newText = "@".concat(intl.formatMessage(mentionMessages.unknownLabel));
|
|
60
|
+
} else {
|
|
61
|
+
newText = processName(nameDetail, intl);
|
|
62
|
+
}
|
|
63
|
+
var currentPos = tr.mapping.map(pos);
|
|
64
|
+
tr.replaceWith(currentPos, currentPos + node.nodeSize, schema.text(newText, node.marks));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}, [mentionProviderMemo, api, intl]);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
var mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
73
|
+
var options = _ref3.config,
|
|
74
|
+
api = _ref3.api;
|
|
17
75
|
var sessionId = uuid();
|
|
76
|
+
var previousMediaProvider;
|
|
18
77
|
var fireEvent = function fireEvent(payload, channel) {
|
|
19
78
|
var _api$analytics;
|
|
20
79
|
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;
|
|
@@ -46,13 +105,32 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
46
105
|
return [{
|
|
47
106
|
name: 'mention',
|
|
48
107
|
plugin: function plugin(pmPluginFactoryParams) {
|
|
49
|
-
return createMentionPlugin(
|
|
108
|
+
return createMentionPlugin({
|
|
109
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
110
|
+
fireEvent: fireEvent,
|
|
111
|
+
options: options,
|
|
112
|
+
api: api
|
|
113
|
+
});
|
|
50
114
|
}
|
|
51
115
|
}];
|
|
52
116
|
},
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
117
|
+
contentComponent: function contentComponent(_ref4) {
|
|
118
|
+
var providerFactory = _ref4.providerFactory;
|
|
119
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
120
|
+
providers: ['mentionProvider'],
|
|
121
|
+
providerFactory: providerFactory,
|
|
122
|
+
renderNode: function renderNode(_ref5) {
|
|
123
|
+
var mentionProvider = _ref5.mentionProvider;
|
|
124
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
125
|
+
mentionProvider: mentionProvider,
|
|
126
|
+
api: api
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref6) {
|
|
132
|
+
var editorView = _ref6.editorView,
|
|
133
|
+
disabled = _ref6.disabled;
|
|
56
134
|
return /*#__PURE__*/React.createElement(SecondaryToolbarComponent, {
|
|
57
135
|
editorView: editorView,
|
|
58
136
|
api: api,
|
|
@@ -72,7 +150,51 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
72
150
|
if (options !== null && options !== void 0 && options.handleMentionsChanged) {
|
|
73
151
|
options.handleMentionsChanged(mentionChanges);
|
|
74
152
|
}
|
|
75
|
-
}
|
|
153
|
+
},
|
|
154
|
+
setProvider: function () {
|
|
155
|
+
var _setProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
|
|
156
|
+
var _api$core$actions$exe;
|
|
157
|
+
var provider;
|
|
158
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
159
|
+
while (1) switch (_context.prev = _context.next) {
|
|
160
|
+
case 0:
|
|
161
|
+
if (fg('platform_editor_mention_provider_via_plugin_config')) {
|
|
162
|
+
_context.next = 2;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
return _context.abrupt("return", false);
|
|
166
|
+
case 2:
|
|
167
|
+
_context.next = 4;
|
|
168
|
+
return providerPromise;
|
|
169
|
+
case 4:
|
|
170
|
+
provider = _context.sent;
|
|
171
|
+
if (!(previousMediaProvider === provider)) {
|
|
172
|
+
_context.next = 7;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
return _context.abrupt("return", false);
|
|
176
|
+
case 7:
|
|
177
|
+
previousMediaProvider = provider;
|
|
178
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
|
|
179
|
+
var tr = _ref7.tr;
|
|
180
|
+
return tr.setMeta(mentionPluginKey, {
|
|
181
|
+
action: ACTIONS.SET_PROVIDER,
|
|
182
|
+
params: {
|
|
183
|
+
provider: provider
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
187
|
+
case 9:
|
|
188
|
+
case "end":
|
|
189
|
+
return _context.stop();
|
|
190
|
+
}
|
|
191
|
+
}, _callee);
|
|
192
|
+
}));
|
|
193
|
+
function setProvider(_x) {
|
|
194
|
+
return _setProvider.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
return setProvider;
|
|
197
|
+
}()
|
|
76
198
|
},
|
|
77
199
|
getSharedState: function getSharedState(editorState) {
|
|
78
200
|
if (!editorState) {
|
|
@@ -84,8 +206,8 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
84
206
|
});
|
|
85
207
|
},
|
|
86
208
|
pluginsOptions: {
|
|
87
|
-
quickInsert: function quickInsert(
|
|
88
|
-
var formatMessage =
|
|
209
|
+
quickInsert: function quickInsert(_ref8) {
|
|
210
|
+
var formatMessage = _ref8.formatMessage;
|
|
89
211
|
return [{
|
|
90
212
|
id: 'mention',
|
|
91
213
|
title: formatMessage(messages.mention),
|
|
@@ -1,23 +1,27 @@
|
|
|
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 var MentionNodeView = function MentionNodeView(props) {
|
|
5
|
-
var providerFactory = props.providerFactory
|
|
6
|
+
var providerFactory = props.providerFactory,
|
|
7
|
+
pluginInjectionApi = props.pluginInjectionApi;
|
|
6
8
|
var _props$node$attrs = props.node.attrs,
|
|
7
9
|
id = _props$node$attrs.id,
|
|
8
10
|
text = _props$node$attrs.text,
|
|
9
11
|
accessLevel = _props$node$attrs.accessLevel,
|
|
10
12
|
localId = _props$node$attrs.localId;
|
|
13
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['mention']),
|
|
14
|
+
mentionState = _useSharedPluginState.mentionState;
|
|
15
|
+
var mentionProvider = mentionState === null || mentionState === void 0 ? void 0 : mentionState.mentionProvider;
|
|
11
16
|
var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
|
|
12
17
|
var _props$options;
|
|
13
|
-
var
|
|
14
|
-
mentionProvider = _ref.mentionProvider;
|
|
18
|
+
var mentionProviderPromise = mentionProvider ? Promise.resolve(mentionProvider) : providers.mentionProvider;
|
|
15
19
|
var profilecardProvider = (_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.profilecardProvider;
|
|
16
20
|
return /*#__PURE__*/React.createElement(Mention, {
|
|
17
21
|
id: id,
|
|
18
22
|
text: text,
|
|
19
23
|
accessLevel: accessLevel,
|
|
20
|
-
mentionProvider:
|
|
24
|
+
mentionProvider: mentionProviderPromise,
|
|
21
25
|
profilecardProvider: profilecardProvider,
|
|
22
26
|
localId: localId
|
|
23
27
|
});
|
|
@@ -12,11 +12,11 @@ import { MentionNodeView } from '../nodeviews/mention';
|
|
|
12
12
|
import { MENTION_PROVIDER_REJECTED, MENTION_PROVIDER_UNDEFINED } from '../types';
|
|
13
13
|
import { mentionPluginKey } from './key';
|
|
14
14
|
import { canMentionBeCreatedInRange } from './utils';
|
|
15
|
-
var ACTIONS = {
|
|
15
|
+
export var ACTIONS = {
|
|
16
16
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
17
17
|
};
|
|
18
18
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
19
|
-
var PACKAGE_VERSION = "2.
|
|
19
|
+
var PACKAGE_VERSION = "2.11.1";
|
|
20
20
|
var setProvider = function setProvider(provider) {
|
|
21
21
|
return function (state, dispatch) {
|
|
22
22
|
if (dispatch) {
|
|
@@ -30,7 +30,11 @@ var setProvider = function setProvider(provider) {
|
|
|
30
30
|
return true;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
export function createMentionPlugin(
|
|
33
|
+
export function createMentionPlugin(_ref) {
|
|
34
|
+
var pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
35
|
+
fireEvent = _ref.fireEvent,
|
|
36
|
+
options = _ref.options,
|
|
37
|
+
api = _ref.api;
|
|
34
38
|
var mentionProvider;
|
|
35
39
|
var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes
|
|
36
40
|
// Ignored via go/ees005
|
|
@@ -61,12 +65,12 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
61
65
|
// Ignored via go/ees005
|
|
62
66
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
67
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
64
|
-
var
|
|
68
|
+
var _ref2 = tr.getMeta(mentionPluginKey) || {
|
|
65
69
|
action: null,
|
|
66
70
|
params: null
|
|
67
71
|
},
|
|
68
|
-
action =
|
|
69
|
-
params =
|
|
72
|
+
action = _ref2.action,
|
|
73
|
+
params = _ref2.params;
|
|
70
74
|
var hasNewPluginState = false;
|
|
71
75
|
var newPluginState = pluginState;
|
|
72
76
|
var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
|
|
@@ -97,6 +101,7 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
97
101
|
Component: MentionNodeView,
|
|
98
102
|
extraComponentProps: {
|
|
99
103
|
providerFactory: pmPluginFactoryParams.providerFactory,
|
|
104
|
+
pluginInjectionApi: api,
|
|
100
105
|
options: options
|
|
101
106
|
}
|
|
102
107
|
})
|
|
@@ -141,7 +146,12 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
141
146
|
}
|
|
142
147
|
return;
|
|
143
148
|
};
|
|
144
|
-
|
|
149
|
+
var 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
|
+
}
|
|
145
155
|
return {
|
|
146
156
|
destroy: function destroy() {
|
|
147
157
|
if (pmPluginFactoryParams.providerFactory) {
|
|
@@ -156,16 +166,16 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
|
|
|
156
166
|
if (options !== null && options !== void 0 && options.handleMentionsChanged && fg('confluence_updated_mentions_livepages')) {
|
|
157
167
|
var mentionSchema = newState.schema.nodes.mention;
|
|
158
168
|
var mentionNodesBefore = findChildrenByType(prevState.doc, mentionSchema);
|
|
159
|
-
var mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(function (
|
|
160
|
-
var node =
|
|
169
|
+
var mentionLocalIdsAfter = new Set(findChildrenByType(newState.doc, mentionSchema).map(function (_ref3) {
|
|
170
|
+
var node = _ref3.node;
|
|
161
171
|
return node.attrs.localId;
|
|
162
172
|
}));
|
|
163
173
|
if (mentionNodesBefore.length > mentionLocalIdsAfter.size) {
|
|
164
|
-
var deletedMentions = mentionNodesBefore.filter(function (
|
|
165
|
-
var node = _ref3.node;
|
|
166
|
-
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
167
|
-
}).map(function (_ref4) {
|
|
174
|
+
var deletedMentions = mentionNodesBefore.filter(function (_ref4) {
|
|
168
175
|
var node = _ref4.node;
|
|
176
|
+
return !mentionLocalIdsAfter.has(node.attrs.localId);
|
|
177
|
+
}).map(function (_ref5) {
|
|
178
|
+
var node = _ref5.node;
|
|
169
179
|
return {
|
|
170
180
|
type: 'deleted',
|
|
171
181
|
id: node.attrs.id,
|
|
@@ -155,6 +155,7 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
155
155
|
// build team link
|
|
156
156
|
var defaultTeamLink = "".concat(window.location.origin, "/people/team/").concat(teamId);
|
|
157
157
|
var teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
158
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
158
159
|
var teamLinkNode = fg('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
159
160
|
url: teamLink
|
|
160
161
|
}) :
|
|
@@ -226,7 +227,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
226
227
|
var mentionProvider = pluginState.mentionProvider;
|
|
227
228
|
var _ref8 = (_api$contextIdentifie = api === null || api === void 0 || (_api$contextIdentifie2 = api.contextIdentifier) === null || _api$contextIdentifie2 === void 0 ? void 0 : _api$contextIdentifie2.sharedState.currentState()) !== null && _api$contextIdentifie !== void 0 ? _api$contextIdentifie : {},
|
|
228
229
|
contextIdentifierProvider = _ref8.contextIdentifierProvider;
|
|
229
|
-
return new Promise(function (resolve) {
|
|
230
|
+
return new Promise(function (resolve, reject) {
|
|
230
231
|
var key = "loadingMentionsForTypeAhead_".concat(uuid());
|
|
231
232
|
var mentionsSubscribeCallback = function mentionsSubscribeCallback(mentions) {
|
|
232
233
|
var resultQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
@@ -262,7 +263,13 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
262
263
|
}
|
|
263
264
|
};
|
|
264
265
|
subscriptionKeys.add(key);
|
|
265
|
-
mentionProvider.subscribe(key, mentionsSubscribeCallback)
|
|
266
|
+
mentionProvider.subscribe(key, mentionsSubscribeCallback, function () {
|
|
267
|
+
if (fg('platform_editor_offline_editing_ga')) {
|
|
268
|
+
mentionProvider.unsubscribe(key);
|
|
269
|
+
subscriptionKeys.delete(key);
|
|
270
|
+
reject('FETCH_ERROR');
|
|
271
|
+
}
|
|
272
|
+
});
|
|
266
273
|
mentionProvider.filter(query || '', _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
|
|
267
274
|
sessionId: sessionId
|
|
268
275
|
}));
|
|
@@ -287,7 +294,8 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
287
294
|
name = _item$mention.name,
|
|
288
295
|
nickname = _item$mention.nickname,
|
|
289
296
|
accessLevel = _item$mention.accessLevel,
|
|
290
|
-
userType = _item$mention.userType
|
|
297
|
+
userType = _item$mention.userType,
|
|
298
|
+
isXProductUser = _item$mention.isXProductUser;
|
|
291
299
|
var trimmedNickname = nickname && nickname.startsWith('@') ? nickname.slice(1) : nickname;
|
|
292
300
|
var renderName = mentionInsertDisplayName || !trimmedNickname ? name : trimmedNickname;
|
|
293
301
|
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 +352,9 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
344
352
|
if (mentionProvider && isTeamType(userType)) {
|
|
345
353
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
346
354
|
}
|
|
355
|
+
if (isXProductUser && mentionProvider && mentionProvider.inviteXProductUser) {
|
|
356
|
+
mentionProvider.inviteXProductUser(id);
|
|
357
|
+
}
|
|
347
358
|
|
|
348
359
|
// Don't insert into document if document data is sanitized.
|
|
349
360
|
var text = sanitizePrivateContent ? '' : "@".concat(renderName);
|
|
@@ -351,15 +362,21 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
351
362
|
// Cache (locally) for later rendering
|
|
352
363
|
mentionProvider.cacheMentionName(id, renderName);
|
|
353
364
|
}
|
|
354
|
-
var annotationMarksForPos = fg(
|
|
365
|
+
var annotationMarksForPos = fg(
|
|
366
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
367
|
+
'editor_inline_comments_paste_insert_nodes') ? getAnnotationMarksForPos(state.tr.selection.$head) : undefined;
|
|
355
368
|
var mentionNode = schema.nodes.mention.createChecked({
|
|
356
369
|
text: text,
|
|
357
370
|
id: id,
|
|
358
371
|
accessLevel: accessLevel,
|
|
359
372
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
360
373
|
localId: mentionLocalId
|
|
361
|
-
}, null,
|
|
362
|
-
|
|
374
|
+
}, null,
|
|
375
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
376
|
+
fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
377
|
+
var space = schema.text(' ',
|
|
378
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
379
|
+
fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
363
380
|
return insert(Fragment.from([mentionNode, space]));
|
|
364
381
|
},
|
|
365
382
|
dismiss: function dismiss(_ref11) {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { BasePlugin } from '@atlaskit/editor-plugin-base';
|
|
3
4
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
4
5
|
import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
6
|
+
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
5
7
|
import type { MentionPluginOptions, MentionSharedState } from './types';
|
|
6
8
|
export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
7
9
|
pluginConfiguration: MentionPluginOptions | undefined;
|
|
8
10
|
dependencies: [
|
|
9
11
|
OptionalPlugin<AnalyticsPlugin>,
|
|
10
12
|
TypeAheadPlugin,
|
|
11
|
-
OptionalPlugin<ContextIdentifierPlugin
|
|
13
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
14
|
+
OptionalPlugin<BasePlugin>
|
|
12
15
|
];
|
|
13
16
|
sharedState: MentionSharedState | undefined;
|
|
14
17
|
actions: {
|
|
@@ -19,5 +22,12 @@ export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
|
19
22
|
id: string;
|
|
20
23
|
taskLocalId?: string;
|
|
21
24
|
}[]) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Used to update the initial provider passed to the mention plugin.
|
|
27
|
+
*
|
|
28
|
+
* @param provider Promise<MentionProvider>
|
|
29
|
+
* @returns {boolean} if setting the provider was successful or not
|
|
30
|
+
*/
|
|
31
|
+
setProvider: (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
22
32
|
};
|
|
23
33
|
}>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
4
6
|
import type { MentionPluginOptions } from '../types';
|
|
5
7
|
export type Props = InlineNodeViewComponentProps & {
|
|
6
8
|
options: MentionPluginOptions | undefined;
|
|
7
9
|
providerFactory: ProviderFactory;
|
|
10
|
+
pluginInjectionApi?: ExtractInjectionAPI<MentionsPlugin>;
|
|
8
11
|
};
|
|
9
12
|
export declare const MentionNodeView: (props: Props) => JSX.Element;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
3
4
|
import { type FireElementsChannelEvent, type MentionPluginOptions, type MentionPluginState } from '../types';
|
|
4
|
-
export declare
|
|
5
|
+
export declare const ACTIONS: {
|
|
6
|
+
SET_PROVIDER: string;
|
|
7
|
+
};
|
|
8
|
+
interface CreateMentionPlugin {
|
|
9
|
+
pmPluginFactoryParams: PMPluginFactoryParams;
|
|
10
|
+
fireEvent: FireElementsChannelEvent;
|
|
11
|
+
options?: MentionPluginOptions;
|
|
12
|
+
api?: ExtractInjectionAPI<MentionsPlugin>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createMentionPlugin({ pmPluginFactoryParams, fireEvent, options, api, }: CreateMentionPlugin): SafePlugin<MentionPluginState>;
|
|
15
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { type ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import type { Providers } from '@atlaskit/editor-common/provider-factory';
|
|
4
5
|
import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { MentionDescription, MentionProvider } from '@atlaskit/mention';
|
|
6
7
|
export declare const MENTION_PROVIDER_REJECTED = "REJECTED";
|
|
@@ -16,6 +17,7 @@ export interface MentionPluginConfig {
|
|
|
16
17
|
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
17
18
|
}
|
|
18
19
|
export interface MentionPluginOptions extends MentionPluginConfig {
|
|
20
|
+
mentionProvider?: Providers['mentionProvider'];
|
|
19
21
|
sanitizePrivateContent?: boolean;
|
|
20
22
|
allowZeroWidthSpaceAfter?: boolean;
|
|
21
23
|
handleMentionsChanged?: (mentionChanges: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { BasePlugin } from '@atlaskit/editor-plugin-base';
|
|
3
4
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
4
5
|
import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
6
|
+
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
5
7
|
import type { MentionPluginOptions, MentionSharedState } from './types';
|
|
6
8
|
export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
7
9
|
pluginConfiguration: MentionPluginOptions | undefined;
|
|
8
10
|
dependencies: [
|
|
9
11
|
OptionalPlugin<AnalyticsPlugin>,
|
|
10
12
|
TypeAheadPlugin,
|
|
11
|
-
OptionalPlugin<ContextIdentifierPlugin
|
|
13
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
14
|
+
OptionalPlugin<BasePlugin>
|
|
12
15
|
];
|
|
13
16
|
sharedState: MentionSharedState | undefined;
|
|
14
17
|
actions: {
|
|
@@ -19,5 +22,12 @@ export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
|
19
22
|
id: string;
|
|
20
23
|
taskLocalId?: string;
|
|
21
24
|
}[]) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Used to update the initial provider passed to the mention plugin.
|
|
27
|
+
*
|
|
28
|
+
* @param provider Promise<MentionProvider>
|
|
29
|
+
* @returns {boolean} if setting the provider was successful or not
|
|
30
|
+
*/
|
|
31
|
+
setProvider: (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
22
32
|
};
|
|
23
33
|
}>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
3
|
import type { InlineNodeViewComponentProps } from '@atlaskit/editor-common/react-node-view';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
4
6
|
import type { MentionPluginOptions } from '../types';
|
|
5
7
|
export type Props = InlineNodeViewComponentProps & {
|
|
6
8
|
options: MentionPluginOptions | undefined;
|
|
7
9
|
providerFactory: ProviderFactory;
|
|
10
|
+
pluginInjectionApi?: ExtractInjectionAPI<MentionsPlugin>;
|
|
8
11
|
};
|
|
9
12
|
export declare const MentionNodeView: (props: Props) => JSX.Element;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { MentionsPlugin } from '../mentionsPluginType';
|
|
3
4
|
import { type FireElementsChannelEvent, type MentionPluginOptions, type MentionPluginState } from '../types';
|
|
4
|
-
export declare
|
|
5
|
+
export declare const ACTIONS: {
|
|
6
|
+
SET_PROVIDER: string;
|
|
7
|
+
};
|
|
8
|
+
interface CreateMentionPlugin {
|
|
9
|
+
pmPluginFactoryParams: PMPluginFactoryParams;
|
|
10
|
+
fireEvent: FireElementsChannelEvent;
|
|
11
|
+
options?: MentionPluginOptions;
|
|
12
|
+
api?: ExtractInjectionAPI<MentionsPlugin>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createMentionPlugin({ pmPluginFactoryParams, fireEvent, options, api, }: CreateMentionPlugin): SafePlugin<MentionPluginState>;
|
|
15
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { type ProfilecardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
import type { Providers } from '@atlaskit/editor-common/provider-factory';
|
|
4
5
|
import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { MentionDescription, MentionProvider } from '@atlaskit/mention';
|
|
6
7
|
export declare const MENTION_PROVIDER_REJECTED = "REJECTED";
|
|
@@ -16,6 +17,7 @@ export interface MentionPluginConfig {
|
|
|
16
17
|
profilecardProvider?: Promise<ProfilecardProvider>;
|
|
17
18
|
}
|
|
18
19
|
export interface MentionPluginOptions extends MentionPluginConfig {
|
|
20
|
+
mentionProvider?: Providers['mentionProvider'];
|
|
19
21
|
sanitizePrivateContent?: boolean;
|
|
20
22
|
allowZeroWidthSpaceAfter?: boolean;
|
|
21
23
|
handleMentionsChanged?: (mentionChanges: {
|