@atlaskit/editor-plugin-mentions 2.0.1 → 2.0.3
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 +16 -0
- package/dist/cjs/type-ahead/index.js +19 -16
- package/dist/cjs/ui/InviteItem/index.js +4 -1
- package/dist/es2019/type-ahead/index.js +5 -2
- package/dist/es2019/ui/InviteItem/index.js +4 -1
- package/dist/esm/type-ahead/index.js +5 -2
- package/dist/esm/ui/InviteItem/index.js +4 -1
- package/dist/types/ui/InviteItem/index.d.ts +4 -1
- package/dist/types-ts4.5/ui/InviteItem/index.d.ts +4 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-mentions
|
|
2
2
|
|
|
3
|
+
## 2.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#122612](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122612)
|
|
8
|
+
[`01a85ce0a88ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/01a85ce0a88ec) -
|
|
9
|
+
[ux] ED-23705 Add logic to handle annotations on inline nodes when they are inserted or pasted.
|
|
10
|
+
Covers the following inline nodes: emoji, status, mention, date, inlineCard
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 2.0.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 2.0.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -13,14 +13,16 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
15
15
|
var _typeAhead = require("@atlaskit/editor-common/type-ahead");
|
|
16
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
17
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
17
|
-
var
|
|
18
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
18
19
|
var _item = require("@atlaskit/mention/item");
|
|
19
20
|
var _resource = require("@atlaskit/mention/resource");
|
|
21
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
22
|
var _analytics = require("../analytics");
|
|
21
|
-
var
|
|
23
|
+
var _utils3 = require("../pm-plugins/utils");
|
|
22
24
|
var _InviteItem = _interopRequireWildcard(require("../ui/InviteItem"));
|
|
23
|
-
var
|
|
25
|
+
var _utils4 = require("../utils");
|
|
24
26
|
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); }
|
|
25
27
|
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 && Object.prototype.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; }
|
|
26
28
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -59,7 +61,7 @@ var withInviteItem = function withInviteItem(_ref3) {
|
|
|
59
61
|
mentionProvider: mentionProvider,
|
|
60
62
|
onInviteItemMount: onInviteItemMount
|
|
61
63
|
});
|
|
62
|
-
var keepInviteItem = (0,
|
|
64
|
+
var keepInviteItem = (0, _utils4.shouldKeepInviteItem)(currentQuery, firstQueryWithoutResults);
|
|
63
65
|
if (mentionItems.length === 0) {
|
|
64
66
|
return keepInviteItem ? [inviteItem] : [];
|
|
65
67
|
}
|
|
@@ -117,7 +119,7 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
117
119
|
var duration = 0;
|
|
118
120
|
var userOrTeamIds = null;
|
|
119
121
|
var teams = null;
|
|
120
|
-
if (!(0,
|
|
122
|
+
if (!(0, _utils4.isTeamStats)(stats)) {
|
|
121
123
|
// is from primary mention endpoint which could be just user mentions or user/team mentions
|
|
122
124
|
duration = stats && stats.duration;
|
|
123
125
|
teams = null;
|
|
@@ -129,7 +131,7 @@ var buildAndSendElementsTypeAheadAnalytics = function buildAndSendElementsTypeAh
|
|
|
129
131
|
duration = stats && stats.teamMentionDuration;
|
|
130
132
|
userOrTeamIds = null;
|
|
131
133
|
teams = mentions.map(function (mention) {
|
|
132
|
-
return (0,
|
|
134
|
+
return (0, _utils4.isTeamType)(mention.userType) ? {
|
|
133
135
|
teamId: mention.id,
|
|
134
136
|
includesYou: mention.context.includesYou,
|
|
135
137
|
memberCount: mention.context.memberCount
|
|
@@ -216,7 +218,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
216
218
|
var _api$contextIdentifie, _api$contextIdentifie2;
|
|
217
219
|
var query = _ref7.query,
|
|
218
220
|
editorState = _ref7.editorState;
|
|
219
|
-
var pluginState = (0,
|
|
221
|
+
var pluginState = (0, _utils3.getMentionPluginState)(editorState);
|
|
220
222
|
if (!(pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider)) {
|
|
221
223
|
return Promise.resolve([]);
|
|
222
224
|
}
|
|
@@ -275,7 +277,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
275
277
|
query = _ref9.query,
|
|
276
278
|
sourceListItem = _ref9.sourceListItem;
|
|
277
279
|
var schema = state.schema;
|
|
278
|
-
var pluginState = (0,
|
|
280
|
+
var pluginState = (0, _utils3.getMentionPluginState)(state);
|
|
279
281
|
var mentionProvider = pluginState.mentionProvider;
|
|
280
282
|
var _item$mention = item.mention,
|
|
281
283
|
id = _item$mention.id,
|
|
@@ -290,13 +292,13 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
290
292
|
var mentionContext = _objectSpread(_objectSpread({}, contextIdentifierProvider), {}, {
|
|
291
293
|
sessionId: sessionId
|
|
292
294
|
});
|
|
293
|
-
if (mentionProvider && !(0,
|
|
295
|
+
if (mentionProvider && !(0, _utils4.isInviteItem)(item.mention)) {
|
|
294
296
|
mentionProvider.recordMentionSelection(item.mention, mentionContext);
|
|
295
297
|
}
|
|
296
298
|
|
|
297
299
|
// use same timer as StatsModifier
|
|
298
300
|
var pickerElapsedTime = stats.startedAt ? performance.now() - stats.startedAt : 0;
|
|
299
|
-
if (mentionProvider && mentionProvider.shouldEnableInvite && (0,
|
|
301
|
+
if (mentionProvider && mentionProvider.shouldEnableInvite && (0, _utils4.isInviteItem)(item.mention)) {
|
|
300
302
|
// Don't fire event and the callback with selection by space press
|
|
301
303
|
if (mode !== 'space') {
|
|
302
304
|
fireEvent((0, _analytics.buildTypeAheadInviteItemClickedPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, mode, query, contextIdentifierProvider, mentionProvider.userRole));
|
|
@@ -307,10 +309,10 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
307
309
|
return state.tr;
|
|
308
310
|
}
|
|
309
311
|
var taskListId, taskItemId;
|
|
310
|
-
var taskList = (0,
|
|
312
|
+
var taskList = (0, _utils2.findParentNodeOfType)(state.schema.nodes.taskList)(state.selection);
|
|
311
313
|
if (taskList) {
|
|
312
314
|
taskListId = taskList.node.attrs.localId;
|
|
313
|
-
var taskItem = (0,
|
|
315
|
+
var taskItem = (0, _utils2.findParentNodeOfType)(state.schema.nodes.taskItem)(state.selection);
|
|
314
316
|
if (taskItem) {
|
|
315
317
|
taskItemId = taskItem.node.attrs.localId;
|
|
316
318
|
}
|
|
@@ -320,7 +322,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
320
322
|
return x.mention;
|
|
321
323
|
}), query, contextIdentifierProvider, taskListId, taskItemId));
|
|
322
324
|
sessionId = (0, _uuid.default)();
|
|
323
|
-
if (mentionProvider && (0,
|
|
325
|
+
if (mentionProvider && (0, _utils4.isTeamType)(userType)) {
|
|
324
326
|
return insert(buildNodesForTeamMention(schema, item.mention, mentionProvider, sanitizePrivateContent));
|
|
325
327
|
}
|
|
326
328
|
|
|
@@ -330,14 +332,15 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
330
332
|
// Cache (locally) for later rendering
|
|
331
333
|
mentionProvider.cacheMentionName(id, renderName);
|
|
332
334
|
}
|
|
335
|
+
var annotationMarksForPos = (0, _platformFeatureFlags.fg)('editor_inline_comments_paste_insert_nodes') ? (0, _utils.getAnnotationMarksForPos)(state.tr.selection.$head) : undefined;
|
|
333
336
|
var mentionNode = schema.nodes.mention.createChecked({
|
|
334
337
|
text: text,
|
|
335
338
|
id: id,
|
|
336
339
|
accessLevel: accessLevel,
|
|
337
340
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
338
341
|
localId: mentionLocalId
|
|
339
|
-
});
|
|
340
|
-
var space = schema.text(' ');
|
|
342
|
+
}, null, (0, _platformFeatureFlags.fg)('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
343
|
+
var space = schema.text(' ', (0, _platformFeatureFlags.fg)('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
341
344
|
return insert(_model.Fragment.from([mentionNode, space]));
|
|
342
345
|
},
|
|
343
346
|
dismiss: function dismiss(_ref11) {
|
|
@@ -350,7 +353,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
|
|
|
350
353
|
if (!wasItemInserted) {
|
|
351
354
|
fireEvent((0, _analytics.buildTypeAheadCancelPayload)(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
|
|
352
355
|
}
|
|
353
|
-
var pluginState = (0,
|
|
356
|
+
var pluginState = (0, _utils3.getMentionPluginState)(editorState);
|
|
354
357
|
if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
|
|
355
358
|
var mentionProvider = pluginState.mentionProvider;
|
|
356
359
|
var _iterator = _createForOfIteratorHelper(subscriptionKeys),
|
|
@@ -16,7 +16,10 @@ var _colors = require("@atlaskit/theme/colors");
|
|
|
16
16
|
var _styles = require("./styles");
|
|
17
17
|
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); }
|
|
18
18
|
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 && Object.prototype.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; }
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* @jsxRuntime classic
|
|
21
|
+
* @jsx jsx
|
|
22
|
+
*/
|
|
20
23
|
|
|
21
24
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
22
25
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import uuid from 'uuid';
|
|
3
3
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
4
|
+
import { getAnnotationMarksForPos } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
7
|
import { MENTION_ITEM_HEIGHT, MentionItem } from '@atlaskit/mention/item';
|
|
7
8
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from '../analytics';
|
|
9
11
|
import { getMentionPluginState } from '../pm-plugins/utils';
|
|
10
12
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../ui/InviteItem';
|
|
@@ -314,14 +316,15 @@ export const createTypeAheadConfig = ({
|
|
|
314
316
|
// Cache (locally) for later rendering
|
|
315
317
|
mentionProvider.cacheMentionName(id, renderName);
|
|
316
318
|
}
|
|
319
|
+
const annotationMarksForPos = fg('editor_inline_comments_paste_insert_nodes') ? getAnnotationMarksForPos(state.tr.selection.$head) : undefined;
|
|
317
320
|
const mentionNode = schema.nodes.mention.createChecked({
|
|
318
321
|
text,
|
|
319
322
|
id,
|
|
320
323
|
accessLevel,
|
|
321
324
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
322
325
|
localId: mentionLocalId
|
|
323
|
-
});
|
|
324
|
-
const space = schema.text(' ');
|
|
326
|
+
}, null, fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
327
|
+
const space = schema.text(' ', fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
325
328
|
return insert(Fragment.from([mentionNode, space]));
|
|
326
329
|
},
|
|
327
330
|
dismiss({
|
|
@@ -8,10 +8,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import uuid from 'uuid';
|
|
10
10
|
import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
|
|
11
|
+
import { getAnnotationMarksForPos } from '@atlaskit/editor-common/utils';
|
|
11
12
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
12
13
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
13
14
|
import { MENTION_ITEM_HEIGHT, MentionItem } from '@atlaskit/mention/item';
|
|
14
15
|
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
16
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
17
|
import { buildTypeAheadCancelPayload, buildTypeAheadInsertedPayload, buildTypeAheadInviteItemClickedPayload, buildTypeAheadInviteItemViewedPayload, buildTypeAheadRenderedPayload } from '../analytics';
|
|
16
18
|
import { getMentionPluginState } from '../pm-plugins/utils';
|
|
17
19
|
import InviteItem, { INVITE_ITEM_DESCRIPTION } from '../ui/InviteItem';
|
|
@@ -318,14 +320,15 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref6) {
|
|
|
318
320
|
// Cache (locally) for later rendering
|
|
319
321
|
mentionProvider.cacheMentionName(id, renderName);
|
|
320
322
|
}
|
|
323
|
+
var annotationMarksForPos = fg('editor_inline_comments_paste_insert_nodes') ? getAnnotationMarksForPos(state.tr.selection.$head) : undefined;
|
|
321
324
|
var mentionNode = schema.nodes.mention.createChecked({
|
|
322
325
|
text: text,
|
|
323
326
|
id: id,
|
|
324
327
|
accessLevel: accessLevel,
|
|
325
328
|
userType: userType === 'DEFAULT' ? null : userType,
|
|
326
329
|
localId: mentionLocalId
|
|
327
|
-
});
|
|
328
|
-
var space = schema.text(' ');
|
|
330
|
+
}, null, fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
331
|
+
var space = schema.text(' ', fg('editor_inline_comments_paste_insert_nodes') ? annotationMarksForPos : undefined);
|
|
329
332
|
return insert(Fragment.from([mentionNode, space]));
|
|
330
333
|
},
|
|
331
334
|
dismiss: function dismiss(_ref11) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-mentions",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Mentions plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^39.0.3",
|
|
37
37
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
38
|
-
"@atlaskit/editor-common": "^
|
|
38
|
+
"@atlaskit/editor-common": "^86.4.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.4.0",
|
|
40
40
|
"@atlaskit/editor-plugin-context-identifier": "^1.1.0",
|
|
41
41
|
"@atlaskit/editor-plugin-type-ahead": "^1.4.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
43
|
-
"@atlaskit/icon": "^22.
|
|
43
|
+
"@atlaskit/icon": "^22.7.0",
|
|
44
44
|
"@atlaskit/mention": "^23.2.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
46
46
|
"@atlaskit/theme": "^12.11.0",
|
|
47
|
-
"@atlaskit/tokens": "^1.
|
|
47
|
+
"@atlaskit/tokens": "^1.56.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
49
|
"@emotion/react": "^11.7.1",
|
|
50
50
|
"uuid": "^3.1.0"
|
|
@@ -107,6 +107,9 @@
|
|
|
107
107
|
"platform-feature-flags": {
|
|
108
108
|
"platform.editor.mentions-in-editor-popup-on-click": {
|
|
109
109
|
"type": "boolean"
|
|
110
|
+
},
|
|
111
|
+
"editor_inline_comments_paste_insert_nodes": {
|
|
112
|
+
"type": "boolean"
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
}
|