@atlaskit/editor-plugin-mentions 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#122895](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122895)
8
+ [`49b8c7658f3b5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/49b8c7658f3b5) -
9
+ [ED-24173] bump @atlaskit/adf-schema to 40.3.0 and @atlassian/adf-schema-json to 1.18.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.0.3
16
+
17
+ ### Patch Changes
18
+
19
+ - [#122612](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122612)
20
+ [`01a85ce0a88ec`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/01a85ce0a88ec) -
21
+ [ux] ED-23705 Add logic to handle annotations on inline nodes when they are inserted or pasted.
22
+ Covers the following inline nodes: emoji, status, mention, date, inlineCard
23
+ - Updated dependencies
24
+
3
25
  ## 2.0.2
4
26
 
5
27
  ### 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 _utils = require("@atlaskit/editor-prosemirror/utils");
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 _utils2 = require("../pm-plugins/utils");
23
+ var _utils3 = require("../pm-plugins/utils");
22
24
  var _InviteItem = _interopRequireWildcard(require("../ui/InviteItem"));
23
- var _utils3 = require("../utils");
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, _utils3.shouldKeepInviteItem)(currentQuery, firstQueryWithoutResults);
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, _utils3.isTeamStats)(stats)) {
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, _utils3.isTeamType)(mention.userType) ? {
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, _utils2.getMentionPluginState)(editorState);
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, _utils2.getMentionPluginState)(state);
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, _utils3.isInviteItem)(item.mention)) {
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, _utils3.isInviteItem)(item.mention)) {
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, _utils.findParentNodeOfType)(state.schema.nodes.taskList)(state.selection);
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, _utils.findParentNodeOfType)(state.schema.nodes.taskItem)(state.selection);
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, _utils3.isTeamType)(userType)) {
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, _utils2.getMentionPluginState)(editorState);
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
- /** @jsx jsx */
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({
@@ -1,5 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /** @jsx jsx */
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
3
6
 
4
7
  import React, { useCallback, useEffect } from 'react';
5
8
 
@@ -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) {
@@ -1,5 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /** @jsx jsx */
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
3
6
 
4
7
  import React, { useCallback, useEffect } from 'react';
5
8
 
@@ -1,4 +1,7 @@
1
- /** @jsx jsx */
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
2
5
  import type { SyntheticEvent } from 'react';
3
6
  import React from 'react';
4
7
  import type { WrappedComponentProps } from 'react-intl-next';
@@ -1,4 +1,7 @@
1
- /** @jsx jsx */
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
2
5
  import type { SyntheticEvent } from 'react';
3
6
  import React from 'react';
4
7
  import type { WrappedComponentProps } from 'react-intl-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,18 +33,18 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^39.0.3",
36
+ "@atlaskit/adf-schema": "^40.3.0",
37
37
  "@atlaskit/analytics-gas-types": "^5.1.0",
38
- "@atlaskit/editor-common": "^86.0.0",
39
- "@atlaskit/editor-plugin-analytics": "^1.4.0",
38
+ "@atlaskit/editor-common": "^86.7.0",
39
+ "@atlaskit/editor-plugin-analytics": "^1.5.0",
40
40
  "@atlaskit/editor-plugin-context-identifier": "^1.1.0",
41
- "@atlaskit/editor-plugin-type-ahead": "^1.4.0",
41
+ "@atlaskit/editor-plugin-type-ahead": "^1.5.0",
42
42
  "@atlaskit/editor-prosemirror": "4.0.1",
43
- "@atlaskit/icon": "^22.6.0",
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.55.0",
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
  }