@atlaskit/editor-plugin-mentions 2.11.0 → 2.11.2
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 +19 -0
- package/dist/cjs/mentionsPlugin.js +82 -11
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/ui/type-ahead/index.js +18 -5
- package/dist/es2019/mentionsPlugin.js +83 -3
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/ui/type-ahead/index.js +18 -5
- package/dist/esm/mentionsPlugin.js +80 -12
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/ui/type-ahead/index.js +18 -5
- package/dist/types/mentionsPluginType.d.ts +22 -21
- package/dist/types-ts4.5/mentionsPluginType.d.ts +22 -21
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 2.11.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102447](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102447)
|
|
8
|
+
[`17f3bf711d55c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/17f3bf711d55c) -
|
|
9
|
+
Re-enable mentions while offline.
|
|
10
|
+
|
|
11
|
+
## 2.11.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#97984](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97984)
|
|
16
|
+
[`8ffeab9aaf1ab`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8ffeab9aaf1ab) -
|
|
17
|
+
[ux] [ED-23573] Added new actions (resolveMarks and registerMarks) to basePlugin. Callbacks added
|
|
18
|
+
to mentions, card, emoji and base plugins to handle conversion to inline code. Deprecated code
|
|
19
|
+
removed from editor-common.
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.11.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -8,22 +9,79 @@ exports.mentionsPlugin = void 0;
|
|
|
8
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _react =
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _reactIntlNext = require("react-intl-next");
|
|
12
14
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
13
15
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
14
16
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
15
17
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
18
|
+
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
16
19
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
20
|
+
var _resource = require("@atlaskit/mention/resource");
|
|
21
|
+
var _types = require("@atlaskit/mention/types");
|
|
17
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
23
|
var _key = require("./pm-plugins/key");
|
|
19
24
|
var _main = require("./pm-plugins/main");
|
|
20
25
|
var _SecondaryToolbarComponent = require("./ui/SecondaryToolbarComponent");
|
|
21
26
|
var _typeAhead = require("./ui/type-ahead");
|
|
27
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
+
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
29
|
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; }
|
|
23
30
|
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; }
|
|
24
|
-
var
|
|
25
|
-
var
|
|
31
|
+
var processName = function processName(name, intl) {
|
|
32
|
+
var unknownLabel = intl.formatMessage(_messages.mentionMessages.unknownLabel);
|
|
33
|
+
if (name.status === _types.MentionNameStatus.OK) {
|
|
34
|
+
return "@".concat(name.name || unknownLabel);
|
|
35
|
+
} else {
|
|
36
|
+
return "@".concat(unknownLabel);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* We will need to clean this up once mentionProvider is
|
|
42
|
+
* put inside mention plugin.
|
|
43
|
+
* See: https://product-fabric.atlassian.net/browse/ED-26011
|
|
44
|
+
*/
|
|
45
|
+
function Component(_ref) {
|
|
46
|
+
var mentionProvider = _ref.mentionProvider,
|
|
26
47
|
api = _ref.api;
|
|
48
|
+
var mentionProviderMemo = (0, _react.useMemo)(function () {
|
|
49
|
+
return mentionProvider;
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, []);
|
|
52
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
53
|
+
(0, _react.useEffect)(function () {
|
|
54
|
+
mentionProviderMemo === null || mentionProviderMemo === void 0 || mentionProviderMemo.then(function (mentionProviderSync) {
|
|
55
|
+
var _api$base;
|
|
56
|
+
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) {
|
|
57
|
+
var tr = _ref2.tr,
|
|
58
|
+
node = _ref2.node,
|
|
59
|
+
pos = _ref2.pos;
|
|
60
|
+
var doc = tr.doc;
|
|
61
|
+
var schema = doc.type.schema;
|
|
62
|
+
var mentionNodeType = schema.nodes.mention;
|
|
63
|
+
var id = node.attrs.id;
|
|
64
|
+
if (node.type === mentionNodeType) {
|
|
65
|
+
if ((0, _resource.isResolvingMentionProvider)(mentionProviderSync)) {
|
|
66
|
+
var nameDetail = mentionProviderSync === null || mentionProviderSync === void 0 ? void 0 : mentionProviderSync.resolveMentionName(id);
|
|
67
|
+
var newText;
|
|
68
|
+
if ((0, _types.isPromise)(nameDetail)) {
|
|
69
|
+
newText = "@".concat(intl.formatMessage(_messages.mentionMessages.unknownLabel));
|
|
70
|
+
} else {
|
|
71
|
+
newText = processName(nameDetail, intl);
|
|
72
|
+
}
|
|
73
|
+
var currentPos = tr.mapping.map(pos);
|
|
74
|
+
tr.replaceWith(currentPos, currentPos + node.nodeSize, schema.text(newText, node.marks));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}, [mentionProviderMemo, api, intl]);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref3) {
|
|
83
|
+
var options = _ref3.config,
|
|
84
|
+
api = _ref3.api;
|
|
27
85
|
var sessionId = (0, _uuid.default)();
|
|
28
86
|
var previousMediaProvider;
|
|
29
87
|
var fireEvent = function fireEvent(payload, channel) {
|
|
@@ -66,9 +124,23 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
66
124
|
}
|
|
67
125
|
}];
|
|
68
126
|
},
|
|
69
|
-
|
|
70
|
-
var
|
|
71
|
-
|
|
127
|
+
contentComponent: function contentComponent(_ref4) {
|
|
128
|
+
var providerFactory = _ref4.providerFactory;
|
|
129
|
+
return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
|
|
130
|
+
providers: ['mentionProvider'],
|
|
131
|
+
providerFactory: providerFactory,
|
|
132
|
+
renderNode: function renderNode(_ref5) {
|
|
133
|
+
var mentionProvider = _ref5.mentionProvider;
|
|
134
|
+
return /*#__PURE__*/_react.default.createElement(Component, {
|
|
135
|
+
mentionProvider: mentionProvider,
|
|
136
|
+
api: api
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref6) {
|
|
142
|
+
var editorView = _ref6.editorView,
|
|
143
|
+
disabled = _ref6.disabled;
|
|
72
144
|
return /*#__PURE__*/_react.default.createElement(_SecondaryToolbarComponent.SecondaryToolbarComponent, {
|
|
73
145
|
editorView: editorView,
|
|
74
146
|
api: api,
|
|
@@ -113,8 +185,8 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
113
185
|
return _context.abrupt("return", false);
|
|
114
186
|
case 7:
|
|
115
187
|
previousMediaProvider = provider;
|
|
116
|
-
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
117
|
-
var tr =
|
|
188
|
+
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref7) {
|
|
189
|
+
var tr = _ref7.tr;
|
|
118
190
|
return tr.setMeta(_key.mentionPluginKey, {
|
|
119
191
|
action: _main.ACTIONS.SET_PROVIDER,
|
|
120
192
|
params: {
|
|
@@ -144,8 +216,8 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
144
216
|
});
|
|
145
217
|
},
|
|
146
218
|
pluginsOptions: {
|
|
147
|
-
quickInsert: function quickInsert(
|
|
148
|
-
var formatMessage =
|
|
219
|
+
quickInsert: function quickInsert(_ref8) {
|
|
220
|
+
var formatMessage = _ref8.formatMessage;
|
|
149
221
|
return [{
|
|
150
222
|
id: 'mention',
|
|
151
223
|
title: formatMessage(_messages.toolbarInsertBlockMessages.mention),
|
|
@@ -153,7 +225,6 @@ var mentionsPlugin = exports.mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
153
225
|
keywords: ['team', 'user'],
|
|
154
226
|
priority: 400,
|
|
155
227
|
keyshortcut: '@',
|
|
156
|
-
isDisabledOffline: true,
|
|
157
228
|
icon: function icon() {
|
|
158
229
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconMention, null);
|
|
159
230
|
},
|
|
@@ -24,7 +24,7 @@ var ACTIONS = exports.ACTIONS = {
|
|
|
24
24
|
SET_PROVIDER: 'SET_PROVIDER'
|
|
25
25
|
};
|
|
26
26
|
var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
|
|
27
|
-
var PACKAGE_VERSION = "2.11.
|
|
27
|
+
var PACKAGE_VERSION = "2.11.2";
|
|
28
28
|
var setProvider = function setProvider(provider) {
|
|
29
29
|
return function (state, dispatch) {
|
|
30
30
|
if (dispatch) {
|
|
@@ -167,6 +167,7 @@ var buildNodesForTeamMention = function buildNodesForTeamMention(schema, selecte
|
|
|
167
167
|
// build team link
|
|
168
168
|
var defaultTeamLink = "".concat(window.location.origin, "/people/team/").concat(teamId);
|
|
169
169
|
var teamLink = context && context.teamLink ? context.teamLink : defaultTeamLink;
|
|
170
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
170
171
|
var teamLinkNode = (0, _platformFeatureFlags.fg)('team-mention-inline-smartlink') ? schema.nodes.inlineCard.create({
|
|
171
172
|
url: teamLink
|
|
172
173
|
}) :
|
|
@@ -238,7 +239,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
238
239
|
var mentionProvider = pluginState.mentionProvider;
|
|
239
240
|
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 : {},
|
|
240
241
|
contextIdentifierProvider = _ref8.contextIdentifierProvider;
|
|
241
|
-
return new Promise(function (resolve) {
|
|
242
|
+
return new Promise(function (resolve, reject) {
|
|
242
243
|
var key = "loadingMentionsForTypeAhead_".concat((0, _uuid.default)());
|
|
243
244
|
var mentionsSubscribeCallback = function mentionsSubscribeCallback(mentions) {
|
|
244
245
|
var resultQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
@@ -274,7 +275,13 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
274
275
|
}
|
|
275
276
|
};
|
|
276
277
|
subscriptionKeys.add(key);
|
|
277
|
-
mentionProvider.subscribe(key, mentionsSubscribeCallback)
|
|
278
|
+
mentionProvider.subscribe(key, mentionsSubscribeCallback, function () {
|
|
279
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_offline_editing_ga')) {
|
|
280
|
+
mentionProvider.unsubscribe(key);
|
|
281
|
+
subscriptionKeys.delete(key);
|
|
282
|
+
reject('FETCH_ERROR');
|
|
283
|
+
}
|
|
284
|
+
});
|
|
278
285
|
mentionProvider.filter(query || '', _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
|
|
279
286
|
sessionId: sessionId
|
|
280
287
|
}));
|
|
@@ -367,15 +374,21 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
367
374
|
// Cache (locally) for later rendering
|
|
368
375
|
mentionProvider.cacheMentionName(id, renderName);
|
|
369
376
|
}
|
|
370
|
-
var annotationMarksForPos = (0, _platformFeatureFlags.fg)(
|
|
377
|
+
var annotationMarksForPos = (0, _platformFeatureFlags.fg)(
|
|
378
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
379
|
+
'editor_inline_comments_paste_insert_nodes') ? (0, _utils.getAnnotationMarksForPos)(state.tr.selection.$head) : undefined;
|
|
371
380
|
var mentionNode = schema.nodes.mention.createChecked({
|
|
372
381
|
text: text,
|
|
373
382
|
id: id,
|
|
374
383
|
accessLevel: accessLevel,
|
|
375
384
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
376
385
|
localId: mentionLocalId
|
|
377
|
-
}, null,
|
|
378
|
-
|
|
386
|
+
}, null,
|
|
387
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
388
|
+
(0, _platformFeatureFlags.fg)('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
389
|
+
var space = schema.text(' ',
|
|
390
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
391
|
+
(0, _platformFeatureFlags.fg)('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
379
392
|
return insert(_model.Fragment.from([mentionNode, space]));
|
|
380
393
|
},
|
|
381
394
|
dismiss: function dismiss(_ref11) {
|
|
@@ -1,14 +1,79 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
2
3
|
import uuid from 'uuid';
|
|
3
4
|
import { mention } from '@atlaskit/adf-schema';
|
|
4
5
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { toolbarInsertBlockMessages as messages, mentionMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
8
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
9
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
10
|
+
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
7
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
12
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
9
13
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
10
14
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
11
15
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
16
|
+
const processName = (name, intl) => {
|
|
17
|
+
const unknownLabel = intl.formatMessage(mentionMessages.unknownLabel);
|
|
18
|
+
if (name.status === MentionNameStatus.OK) {
|
|
19
|
+
return `@${name.name || unknownLabel}`;
|
|
20
|
+
} else {
|
|
21
|
+
return `@${unknownLabel}`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* We will need to clean this up once mentionProvider is
|
|
27
|
+
* put inside mention plugin.
|
|
28
|
+
* See: https://product-fabric.atlassian.net/browse/ED-26011
|
|
29
|
+
*/
|
|
30
|
+
function Component({
|
|
31
|
+
mentionProvider,
|
|
32
|
+
api
|
|
33
|
+
}) {
|
|
34
|
+
const mentionProviderMemo = useMemo(() => {
|
|
35
|
+
return mentionProvider;
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, []);
|
|
38
|
+
const intl = useIntl();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
mentionProviderMemo === null || mentionProviderMemo === void 0 ? void 0 : mentionProviderMemo.then(mentionProviderSync => {
|
|
41
|
+
var _api$base, _api$base$actions;
|
|
42
|
+
api === null || api === void 0 ? void 0 : (_api$base = api.base) === null || _api$base === void 0 ? void 0 : (_api$base$actions = _api$base.actions) === null || _api$base$actions === void 0 ? void 0 : _api$base$actions.registerMarks(({
|
|
43
|
+
tr,
|
|
44
|
+
node,
|
|
45
|
+
pos
|
|
46
|
+
}) => {
|
|
47
|
+
const {
|
|
48
|
+
doc
|
|
49
|
+
} = tr;
|
|
50
|
+
const {
|
|
51
|
+
schema
|
|
52
|
+
} = doc.type;
|
|
53
|
+
const {
|
|
54
|
+
mention: mentionNodeType
|
|
55
|
+
} = schema.nodes;
|
|
56
|
+
const {
|
|
57
|
+
id
|
|
58
|
+
} = node.attrs;
|
|
59
|
+
if (node.type === mentionNodeType) {
|
|
60
|
+
if (isResolvingMentionProvider(mentionProviderSync)) {
|
|
61
|
+
const nameDetail = mentionProviderSync === null || mentionProviderSync === void 0 ? void 0 : mentionProviderSync.resolveMentionName(id);
|
|
62
|
+
let newText;
|
|
63
|
+
if (isPromise(nameDetail)) {
|
|
64
|
+
newText = `@${intl.formatMessage(mentionMessages.unknownLabel)}`;
|
|
65
|
+
} else {
|
|
66
|
+
newText = processName(nameDetail, intl);
|
|
67
|
+
}
|
|
68
|
+
const currentPos = tr.mapping.map(pos);
|
|
69
|
+
tr.replaceWith(currentPos, currentPos + node.nodeSize, schema.text(newText, node.marks));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}, [mentionProviderMemo, api, intl]);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
12
77
|
const mentionsPlugin = ({
|
|
13
78
|
config: options,
|
|
14
79
|
api
|
|
@@ -53,6 +118,22 @@ const mentionsPlugin = ({
|
|
|
53
118
|
})
|
|
54
119
|
}];
|
|
55
120
|
},
|
|
121
|
+
contentComponent({
|
|
122
|
+
providerFactory
|
|
123
|
+
}) {
|
|
124
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
125
|
+
providers: ['mentionProvider'],
|
|
126
|
+
providerFactory: providerFactory,
|
|
127
|
+
renderNode: ({
|
|
128
|
+
mentionProvider
|
|
129
|
+
}) => {
|
|
130
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
131
|
+
mentionProvider: mentionProvider,
|
|
132
|
+
api: api
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
},
|
|
56
137
|
secondaryToolbarComponent({
|
|
57
138
|
editorView,
|
|
58
139
|
disabled
|
|
@@ -118,7 +199,6 @@ const mentionsPlugin = ({
|
|
|
118
199
|
keywords: ['team', 'user'],
|
|
119
200
|
priority: 400,
|
|
120
201
|
keyshortcut: '@',
|
|
121
|
-
isDisabledOffline: true,
|
|
122
202
|
icon: () => /*#__PURE__*/React.createElement(IconMention, null),
|
|
123
203
|
action(insert, state) {
|
|
124
204
|
var _api$typeAhead2;
|
|
@@ -13,7 +13,7 @@ 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.11.
|
|
16
|
+
const PACKAGE_VERSION = "2.11.2";
|
|
17
17
|
const setProvider = provider => (state, dispatch) => {
|
|
18
18
|
if (dispatch) {
|
|
19
19
|
dispatch(state.tr.setMeta(mentionPluginKey, {
|
|
@@ -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
|
|
@@ -351,15 +358,21 @@ export const createTypeAheadConfig = ({
|
|
|
351
358
|
// Cache (locally) for later rendering
|
|
352
359
|
mentionProvider.cacheMentionName(id, renderName);
|
|
353
360
|
}
|
|
354
|
-
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;
|
|
355
364
|
const mentionNode = schema.nodes.mention.createChecked({
|
|
356
365
|
text,
|
|
357
366
|
id,
|
|
358
367
|
accessLevel,
|
|
359
368
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
360
369
|
localId: mentionLocalId
|
|
361
|
-
}, null,
|
|
362
|
-
|
|
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);
|
|
363
376
|
return insert(Fragment.from([mentionNode, space]));
|
|
364
377
|
},
|
|
365
378
|
dismiss({
|
|
@@ -3,20 +3,75 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
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; }
|
|
4
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; }
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { useEffect, useMemo } from 'react';
|
|
7
|
+
import { useIntl } from 'react-intl-next';
|
|
7
8
|
import uuid from 'uuid';
|
|
8
9
|
import { mention } from '@atlaskit/adf-schema';
|
|
9
10
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
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';
|
|
11
13
|
import { IconMention } from '@atlaskit/editor-common/quick-insert';
|
|
14
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
15
|
+
import { MentionNameStatus, isPromise } from '@atlaskit/mention/types';
|
|
12
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
17
|
import { mentionPluginKey } from './pm-plugins/key';
|
|
14
18
|
import { ACTIONS, createMentionPlugin } from './pm-plugins/main';
|
|
15
19
|
import { SecondaryToolbarComponent } from './ui/SecondaryToolbarComponent';
|
|
16
20
|
import { createTypeAheadConfig } from './ui/type-ahead';
|
|
17
|
-
var
|
|
18
|
-
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,
|
|
19
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;
|
|
20
75
|
var sessionId = uuid();
|
|
21
76
|
var previousMediaProvider;
|
|
22
77
|
var fireEvent = function fireEvent(payload, channel) {
|
|
@@ -59,9 +114,23 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
59
114
|
}
|
|
60
115
|
}];
|
|
61
116
|
},
|
|
62
|
-
|
|
63
|
-
var
|
|
64
|
-
|
|
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;
|
|
65
134
|
return /*#__PURE__*/React.createElement(SecondaryToolbarComponent, {
|
|
66
135
|
editorView: editorView,
|
|
67
136
|
api: api,
|
|
@@ -106,8 +175,8 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
106
175
|
return _context.abrupt("return", false);
|
|
107
176
|
case 7:
|
|
108
177
|
previousMediaProvider = provider;
|
|
109
|
-
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
110
|
-
var tr =
|
|
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;
|
|
111
180
|
return tr.setMeta(mentionPluginKey, {
|
|
112
181
|
action: ACTIONS.SET_PROVIDER,
|
|
113
182
|
params: {
|
|
@@ -137,8 +206,8 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
137
206
|
});
|
|
138
207
|
},
|
|
139
208
|
pluginsOptions: {
|
|
140
|
-
quickInsert: function quickInsert(
|
|
141
|
-
var formatMessage =
|
|
209
|
+
quickInsert: function quickInsert(_ref8) {
|
|
210
|
+
var formatMessage = _ref8.formatMessage;
|
|
142
211
|
return [{
|
|
143
212
|
id: 'mention',
|
|
144
213
|
title: formatMessage(messages.mention),
|
|
@@ -146,7 +215,6 @@ var mentionsPlugin = function mentionsPlugin(_ref) {
|
|
|
146
215
|
keywords: ['team', 'user'],
|
|
147
216
|
priority: 400,
|
|
148
217
|
keyshortcut: '@',
|
|
149
|
-
isDisabledOffline: true,
|
|
150
218
|
icon: function icon() {
|
|
151
219
|
return /*#__PURE__*/React.createElement(IconMention, null);
|
|
152
220
|
},
|
|
@@ -16,7 +16,7 @@ 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.11.
|
|
19
|
+
var PACKAGE_VERSION = "2.11.2";
|
|
20
20
|
var setProvider = function setProvider(provider) {
|
|
21
21
|
return function (state, dispatch) {
|
|
22
22
|
if (dispatch) {
|
|
@@ -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
|
}));
|
|
@@ -355,15 +362,21 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
355
362
|
// Cache (locally) for later rendering
|
|
356
363
|
mentionProvider.cacheMentionName(id, renderName);
|
|
357
364
|
}
|
|
358
|
-
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;
|
|
359
368
|
var mentionNode = schema.nodes.mention.createChecked({
|
|
360
369
|
text: text,
|
|
361
370
|
id: id,
|
|
362
371
|
accessLevel: accessLevel,
|
|
363
372
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
364
373
|
localId: mentionLocalId
|
|
365
|
-
}, null,
|
|
366
|
-
|
|
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);
|
|
367
380
|
return insert(Fragment.from([mentionNode, space]));
|
|
368
381
|
},
|
|
369
382
|
dismiss: function dismiss(_ref11) {
|
|
@@ -1,31 +1,32 @@
|
|
|
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';
|
|
5
6
|
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
6
7
|
import type { MentionPluginOptions, MentionSharedState } from './types';
|
|
8
|
+
export type MentionActionOpenTypeAhead = (inputMethod: TypeAheadInputMethod) => boolean;
|
|
9
|
+
export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
10
|
+
type: 'added' | 'deleted';
|
|
11
|
+
localId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
taskLocalId?: string;
|
|
14
|
+
}[]) => void;
|
|
15
|
+
export type MentionActionSetProvider = (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
16
|
+
export type MentionActions = {
|
|
17
|
+
openTypeAhead: MentionActionOpenTypeAhead;
|
|
18
|
+
announceMentionsInsertion: MentionActionAnnounceMentionsInsertion;
|
|
19
|
+
setProvider: MentionActionSetProvider;
|
|
20
|
+
};
|
|
21
|
+
export type MentionPluginDependencies = [
|
|
22
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
23
|
+
TypeAheadPlugin,
|
|
24
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
25
|
+
OptionalPlugin<BasePlugin>
|
|
26
|
+
];
|
|
7
27
|
export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
8
28
|
pluginConfiguration: MentionPluginOptions | undefined;
|
|
9
|
-
dependencies:
|
|
10
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
11
|
-
TypeAheadPlugin,
|
|
12
|
-
OptionalPlugin<ContextIdentifierPlugin>
|
|
13
|
-
];
|
|
29
|
+
dependencies: MentionPluginDependencies;
|
|
14
30
|
sharedState: MentionSharedState | undefined;
|
|
15
|
-
actions:
|
|
16
|
-
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
17
|
-
announceMentionsInsertion: (mentionIds: {
|
|
18
|
-
type: 'added' | 'deleted';
|
|
19
|
-
localId: string;
|
|
20
|
-
id: string;
|
|
21
|
-
taskLocalId?: string;
|
|
22
|
-
}[]) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Used to update the initial provider passed to the mention plugin.
|
|
25
|
-
*
|
|
26
|
-
* @param provider Promise<MentionProvider>
|
|
27
|
-
* @returns {boolean} if setting the provider was successful or not
|
|
28
|
-
*/
|
|
29
|
-
setProvider: (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
30
|
-
};
|
|
31
|
+
actions: MentionActions;
|
|
31
32
|
}>;
|
|
@@ -1,31 +1,32 @@
|
|
|
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';
|
|
5
6
|
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
6
7
|
import type { MentionPluginOptions, MentionSharedState } from './types';
|
|
8
|
+
export type MentionActionOpenTypeAhead = (inputMethod: TypeAheadInputMethod) => boolean;
|
|
9
|
+
export type MentionActionAnnounceMentionsInsertion = (mentionIds: {
|
|
10
|
+
type: 'added' | 'deleted';
|
|
11
|
+
localId: string;
|
|
12
|
+
id: string;
|
|
13
|
+
taskLocalId?: string;
|
|
14
|
+
}[]) => void;
|
|
15
|
+
export type MentionActionSetProvider = (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
16
|
+
export type MentionActions = {
|
|
17
|
+
openTypeAhead: MentionActionOpenTypeAhead;
|
|
18
|
+
announceMentionsInsertion: MentionActionAnnounceMentionsInsertion;
|
|
19
|
+
setProvider: MentionActionSetProvider;
|
|
20
|
+
};
|
|
21
|
+
export type MentionPluginDependencies = [
|
|
22
|
+
OptionalPlugin<AnalyticsPlugin>,
|
|
23
|
+
TypeAheadPlugin,
|
|
24
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
25
|
+
OptionalPlugin<BasePlugin>
|
|
26
|
+
];
|
|
7
27
|
export type MentionsPlugin = NextEditorPlugin<'mention', {
|
|
8
28
|
pluginConfiguration: MentionPluginOptions | undefined;
|
|
9
|
-
dependencies:
|
|
10
|
-
OptionalPlugin<AnalyticsPlugin>,
|
|
11
|
-
TypeAheadPlugin,
|
|
12
|
-
OptionalPlugin<ContextIdentifierPlugin>
|
|
13
|
-
];
|
|
29
|
+
dependencies: MentionPluginDependencies;
|
|
14
30
|
sharedState: MentionSharedState | undefined;
|
|
15
|
-
actions:
|
|
16
|
-
openTypeAhead: (inputMethod: TypeAheadInputMethod) => boolean;
|
|
17
|
-
announceMentionsInsertion: (mentionIds: {
|
|
18
|
-
type: 'added' | 'deleted';
|
|
19
|
-
localId: string;
|
|
20
|
-
id: string;
|
|
21
|
-
taskLocalId?: string;
|
|
22
|
-
}[]) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Used to update the initial provider passed to the mention plugin.
|
|
25
|
-
*
|
|
26
|
-
* @param provider Promise<MentionProvider>
|
|
27
|
-
* @returns {boolean} if setting the provider was successful or not
|
|
28
|
-
*/
|
|
29
|
-
setProvider: (provider: Promise<MentionProvider>) => Promise<boolean>;
|
|
30
|
-
};
|
|
31
|
+
actions: MentionActions;
|
|
31
32
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.2",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^99.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
|
+
"@atlaskit/editor-plugin-base": "^2.1.0",
|
|
37
38
|
"@atlaskit/editor-plugin-context-identifier": "^1.3.0",
|
|
38
39
|
"@atlaskit/editor-plugin-type-ahead": "^1.11.0",
|
|
39
40
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
40
|
-
"@atlaskit/icon": "^23.
|
|
41
|
+
"@atlaskit/icon": "^23.3.0",
|
|
41
42
|
"@atlaskit/mention": "^23.7.0",
|
|
42
43
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
43
44
|
"@atlaskit/theme": "^14.0.0",
|
|
44
|
-
"@atlaskit/tokens": "^
|
|
45
|
+
"@atlaskit/tokens": "^3.0.0",
|
|
45
46
|
"@babel/runtime": "^7.0.0",
|
|
46
47
|
"@emotion/react": "^11.7.1",
|
|
47
48
|
"uuid": "^3.1.0"
|
|
@@ -109,6 +110,9 @@
|
|
|
109
110
|
},
|
|
110
111
|
"platform_editor_mention_provider_via_plugin_config": {
|
|
111
112
|
"type": "boolean"
|
|
113
|
+
},
|
|
114
|
+
"platform_editor_offline_editing_ga": {
|
|
115
|
+
"type": "boolean"
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
}
|