@atlaskit/editor-core 188.10.4 → 188.10.7

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/create-editor/ReactEditorView.js +3 -4
  3. package/dist/cjs/create-editor/create-editor.js +3 -6
  4. package/dist/cjs/create-editor/feature-flags-from-props.js +7 -9
  5. package/dist/cjs/labs/next/presets/universal.js +2 -1
  6. package/dist/cjs/plugins/index.js +0 -7
  7. package/dist/cjs/utils/performance/instrumented-plugin.js +4 -10
  8. package/dist/cjs/utils/performance/safer-transactions.js +2 -5
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/create-editor/ReactEditorView.js +3 -4
  11. package/dist/es2019/create-editor/create-editor.js +3 -6
  12. package/dist/es2019/create-editor/feature-flags-from-props.js +7 -9
  13. package/dist/es2019/labs/next/presets/universal.js +2 -1
  14. package/dist/es2019/plugins/index.js +0 -1
  15. package/dist/es2019/utils/performance/instrumented-plugin.js +4 -8
  16. package/dist/es2019/utils/performance/safer-transactions.js +2 -5
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/create-editor/ReactEditorView.js +3 -4
  19. package/dist/esm/create-editor/create-editor.js +3 -6
  20. package/dist/esm/create-editor/feature-flags-from-props.js +7 -9
  21. package/dist/esm/labs/next/presets/universal.js +2 -1
  22. package/dist/esm/plugins/index.js +0 -1
  23. package/dist/esm/utils/performance/instrumented-plugin.js +4 -10
  24. package/dist/esm/utils/performance/safer-transactions.js +2 -5
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/plugins/index.d.ts +0 -1
  27. package/dist/types/plugins/insert-block/types.d.ts +2 -4
  28. package/dist/types/types/editor-props.d.ts +1 -1
  29. package/dist/types/utils/performance/instrumented-plugin.d.ts +0 -3
  30. package/dist/types/utils/performance/safer-transactions.d.ts +1 -2
  31. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  32. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -4
  33. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  34. package/dist/types-ts4.5/utils/performance/instrumented-plugin.d.ts +0 -3
  35. package/dist/types-ts4.5/utils/performance/safer-transactions.d.ts +1 -2
  36. package/package.json +2 -2
  37. package/report.api.md +1 -9
  38. package/tmp/api-report-tmp.d.ts +1 -9
  39. package/dist/cjs/plugins/mentions/analytics.js +0 -157
  40. package/dist/cjs/plugins/mentions/index.js +0 -142
  41. package/dist/cjs/plugins/mentions/messages.js +0 -29
  42. package/dist/cjs/plugins/mentions/nodeviews/mention.js +0 -117
  43. package/dist/cjs/plugins/mentions/pm-plugins/key.js +0 -8
  44. package/dist/cjs/plugins/mentions/pm-plugins/main.js +0 -156
  45. package/dist/cjs/plugins/mentions/pm-plugins/utils.js +0 -23
  46. package/dist/cjs/plugins/mentions/type-ahead/index.js +0 -362
  47. package/dist/cjs/plugins/mentions/types.js +0 -5
  48. package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +0 -76
  49. package/dist/cjs/plugins/mentions/ui/InviteItem/styles.js +0 -19
  50. package/dist/cjs/plugins/mentions/ui/Mention/index.js +0 -98
  51. package/dist/cjs/plugins/mentions/ui/ToolbarMention/index.js +0 -63
  52. package/dist/cjs/plugins/mentions/utils.js +0 -32
  53. package/dist/es2019/plugins/mentions/analytics.js +0 -147
  54. package/dist/es2019/plugins/mentions/index.js +0 -124
  55. package/dist/es2019/plugins/mentions/messages.js +0 -23
  56. package/dist/es2019/plugins/mentions/nodeviews/mention.js +0 -80
  57. package/dist/es2019/plugins/mentions/pm-plugins/key.js +0 -2
  58. package/dist/es2019/plugins/mentions/pm-plugins/main.js +0 -143
  59. package/dist/es2019/plugins/mentions/pm-plugins/utils.js +0 -14
  60. package/dist/es2019/plugins/mentions/type-ahead/index.js +0 -338
  61. package/dist/es2019/plugins/mentions/types.js +0 -1
  62. package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +0 -66
  63. package/dist/es2019/plugins/mentions/ui/InviteItem/styles.js +0 -47
  64. package/dist/es2019/plugins/mentions/ui/Mention/index.js +0 -71
  65. package/dist/es2019/plugins/mentions/ui/ToolbarMention/index.js +0 -33
  66. package/dist/es2019/plugins/mentions/utils.js +0 -20
  67. package/dist/esm/plugins/mentions/analytics.js +0 -150
  68. package/dist/esm/plugins/mentions/index.js +0 -130
  69. package/dist/esm/plugins/mentions/messages.js +0 -23
  70. package/dist/esm/plugins/mentions/nodeviews/mention.js +0 -107
  71. package/dist/esm/plugins/mentions/pm-plugins/key.js +0 -2
  72. package/dist/esm/plugins/mentions/pm-plugins/main.js +0 -148
  73. package/dist/esm/plugins/mentions/pm-plugins/utils.js +0 -16
  74. package/dist/esm/plugins/mentions/type-ahead/index.js +0 -350
  75. package/dist/esm/plugins/mentions/types.js +0 -1
  76. package/dist/esm/plugins/mentions/ui/InviteItem/index.js +0 -65
  77. package/dist/esm/plugins/mentions/ui/InviteItem/styles.js +0 -12
  78. package/dist/esm/plugins/mentions/ui/Mention/index.js +0 -91
  79. package/dist/esm/plugins/mentions/ui/ToolbarMention/index.js +0 -53
  80. package/dist/esm/plugins/mentions/utils.js +0 -26
  81. package/dist/types/plugins/mentions/analytics.d.ts +0 -13
  82. package/dist/types/plugins/mentions/index.d.ts +0 -19
  83. package/dist/types/plugins/mentions/messages.d.ts +0 -22
  84. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +0 -9
  85. package/dist/types/plugins/mentions/pm-plugins/key.d.ts +0 -3
  86. package/dist/types/plugins/mentions/pm-plugins/main.d.ts +0 -6
  87. package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +0 -4
  88. package/dist/types/plugins/mentions/type-ahead/index.d.ts +0 -17
  89. package/dist/types/plugins/mentions/types.d.ts +0 -24
  90. package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
  91. package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
  92. package/dist/types/plugins/mentions/ui/Mention/index.d.ts +0 -19
  93. package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
  94. package/dist/types/plugins/mentions/utils.d.ts +0 -8
  95. package/dist/types-ts4.5/plugins/mentions/analytics.d.ts +0 -13
  96. package/dist/types-ts4.5/plugins/mentions/index.d.ts +0 -22
  97. package/dist/types-ts4.5/plugins/mentions/messages.d.ts +0 -22
  98. package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +0 -9
  99. package/dist/types-ts4.5/plugins/mentions/pm-plugins/key.d.ts +0 -3
  100. package/dist/types-ts4.5/plugins/mentions/pm-plugins/main.d.ts +0 -6
  101. package/dist/types-ts4.5/plugins/mentions/pm-plugins/utils.d.ts +0 -4
  102. package/dist/types-ts4.5/plugins/mentions/type-ahead/index.d.ts +0 -17
  103. package/dist/types-ts4.5/plugins/mentions/types.d.ts +0 -24
  104. package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
  105. package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
  106. package/dist/types-ts4.5/plugins/mentions/ui/Mention/index.d.ts +0 -19
  107. package/dist/types-ts4.5/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
  108. package/dist/types-ts4.5/plugins/mentions/utils.d.ts +0 -8
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
- var _react = _interopRequireWildcard(require("react"));
18
- var _element = require("@atlaskit/mention/element");
19
- var _providerFactory = require("@atlaskit/editor-common/provider-factory");
20
- var _utils = require("@atlaskit/editor-common/utils");
21
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
- // Workaround for a firefox issue where dom selection is off sync
26
- // https://product-fabric.atlassian.net/browse/ED-12442
27
- var refreshBrowserSelection = function refreshBrowserSelection() {
28
- var domSelection = window.getSelection();
29
- if (domSelection) {
30
- var domRange = domSelection && domSelection.rangeCount === 1 && domSelection.getRangeAt(0).cloneRange();
31
- if (domRange) {
32
- domSelection.removeAllRanges();
33
- domSelection.addRange(domRange);
34
- }
35
- }
36
- };
37
- var Mention = exports.default = /*#__PURE__*/function (_PureComponent) {
38
- (0, _inherits2.default)(Mention, _PureComponent);
39
- var _super = _createSuper(Mention);
40
- function Mention(props) {
41
- var _this;
42
- (0, _classCallCheck2.default)(this, Mention);
43
- _this = _super.call(this, props);
44
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderWithProvider", function (providers) {
45
- var _this$props = _this.props,
46
- accessLevel = _this$props.accessLevel,
47
- eventHandlers = _this$props.eventHandlers,
48
- id = _this$props.id,
49
- text = _this$props.text;
50
- var _ref = providers,
51
- mentionProvider = _ref.mentionProvider;
52
- var actionHandlers = {};
53
- ['onClick', 'onMouseEnter', 'onMouseLeave'].forEach(function (handler) {
54
- actionHandlers[handler] = eventHandlers && eventHandlers[handler] || function () {};
55
- });
56
- return /*#__PURE__*/_react.default.createElement(_element.ResourcedMention, (0, _extends2.default)({
57
- id: id,
58
- text: text,
59
- accessLevel: accessLevel,
60
- mentionProvider: mentionProvider
61
- }, actionHandlers));
62
- });
63
- _this.providerFactory = props.providers || new _providerFactory.ProviderFactory();
64
- return _this;
65
- }
66
- (0, _createClass2.default)(Mention, [{
67
- key: "componentDidMount",
68
- value: function componentDidMount() {
69
- // Workaround an issue where the selection is not updated immediately after adding
70
- // a mention when "sanitizePrivateContent" is enabled in the editor on safari.
71
- // This affects both insertion and paste behaviour it is applied to the component.
72
- // https://product-fabric.atlassian.net/browse/ED-14859
73
- if (_utils.browser.safari) {
74
- setTimeout(refreshBrowserSelection, 0);
75
- }
76
- }
77
- }, {
78
- key: "componentWillUnmount",
79
- value: function componentWillUnmount() {
80
- if (!this.props.providers) {
81
- // new ProviderFactory is created if no `providers` has been set
82
- // in this case when component is unmounted it's safe to destroy this providerFactory
83
- this.providerFactory.destroy();
84
- }
85
- }
86
- }, {
87
- key: "render",
88
- value: function render() {
89
- return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
90
- providers: ['mentionProvider', 'profilecardProvider'],
91
- providerFactory: this.providerFactory,
92
- renderNode: this.renderWithProvider
93
- });
94
- }
95
- }]);
96
- return Mention;
97
- }(_react.PureComponent);
98
- (0, _defineProperty2.default)(Mention, "displayName", 'Mention');
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _react = _interopRequireWildcard(require("react"));
17
- var _mention = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/mention"));
18
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
19
- var _reactIntlNext = require("react-intl-next");
20
- var _messages = require("../../messages");
21
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
24
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
25
- var ToolbarMention = /*#__PURE__*/function (_PureComponent) {
26
- (0, _inherits2.default)(ToolbarMention, _PureComponent);
27
- var _super = _createSuper(ToolbarMention);
28
- function ToolbarMention() {
29
- var _this;
30
- (0, _classCallCheck2.default)(this, ToolbarMention);
31
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
32
- args[_key] = arguments[_key];
33
- }
34
- _this = _super.call.apply(_super, [this].concat(args));
35
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleInsertMention", function () {
36
- if (!_this.props.editorView) {
37
- return false;
38
- }
39
- _this.props.onInsertMention();
40
- return true;
41
- });
42
- return _this;
43
- }
44
- (0, _createClass2.default)(ToolbarMention, [{
45
- key: "render",
46
- value: function render() {
47
- var mentionStringTranslated = this.props.intl.formatMessage(_messages.messages.mentionsIconLabel);
48
- return /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarButton, {
49
- testId: this.props.testId,
50
- buttonId: _uiMenu.TOOLBAR_BUTTON.MENTION,
51
- spacing: "none",
52
- onClick: this.handleInsertMention,
53
- disabled: this.props.isDisabled,
54
- title: mentionStringTranslated + '@',
55
- iconBefore: /*#__PURE__*/_react.default.createElement(_mention.default, {
56
- label: mentionStringTranslated
57
- })
58
- });
59
- }
60
- }]);
61
- return ToolbarMention;
62
- }(_react.PureComponent);
63
- var _default = exports.default = (0, _reactIntlNext.injectIntl)(ToolbarMention);
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldKeepInviteItem = exports.isTeamType = exports.isTeamStats = exports.isInviteItem = void 0;
7
- var _InviteItem = require("./ui/InviteItem");
8
- var isTeamType = exports.isTeamType = function isTeamType(userType) {
9
- return userType === 'TEAM';
10
- };
11
- var isTeamStats = exports.isTeamStats = function isTeamStats(stat) {
12
- return stat && !isNaN(stat.teamMentionDuration);
13
- };
14
- var isInviteItem = exports.isInviteItem = function isInviteItem(mention) {
15
- return mention && mention.id === _InviteItem.INVITE_ITEM_DESCRIPTION.id;
16
- };
17
-
18
- /**
19
- * Actions
20
- */
21
- var shouldKeepInviteItem = exports.shouldKeepInviteItem = function shouldKeepInviteItem(query, firstQueryWithoutResults) {
22
- if (!firstQueryWithoutResults) {
23
- return true;
24
- }
25
- var lastIndexWithResults = firstQueryWithoutResults.length - 1;
26
- var suffix = query.slice(lastIndexWithResults);
27
- if (query[lastIndexWithResults - 1] === ' ') {
28
- suffix = ' ' + suffix;
29
- }
30
- var depletedExtraWords = /\s[^\s]+\s/.test(suffix);
31
- return !depletedExtraWords;
32
- };
@@ -1,147 +0,0 @@
1
- import { OPERATIONAL_EVENT_TYPE, UI_EVENT_TYPE } from '@atlaskit/analytics-gas-types';
2
- import { isSpecialMention } from '@atlaskit/mention/resource';
3
- import { isTeamType } from './utils';
4
- const componentName = 'mention';
5
- export const buildAnalyticsPayload = (actionSubject, action, eventType, sessionId, otherAttributes = {}, tags = []) => ({
6
- action,
7
- actionSubject,
8
- eventType,
9
- attributes: {
10
- componentName,
11
- sessionId,
12
- ...otherAttributes
13
- },
14
- tags
15
- });
16
- const emptyQueryResponse = {
17
- queryLength: 0,
18
- spaceInQuery: false
19
- };
20
- const extractAttributesFromQuery = query => {
21
- if (query) {
22
- return {
23
- queryLength: query.length,
24
- spaceInQuery: query.indexOf(' ') !== -1
25
- };
26
- }
27
- return emptyQueryResponse;
28
- };
29
- export const buildTypeAheadCancelPayload = (duration, upKeyCount, downKeyCount, sessionId, query) => {
30
- const {
31
- queryLength,
32
- spaceInQuery
33
- } = extractAttributesFromQuery(query);
34
- return buildAnalyticsPayload('mentionTypeahead', 'cancelled', UI_EVENT_TYPE, sessionId, {
35
- duration,
36
- downKeyCount,
37
- upKeyCount,
38
- queryLength,
39
- spaceInQuery
40
- });
41
- };
42
- const getPosition = (mentionList, selectedMention) => {
43
- if (mentionList) {
44
- const index = mentionList.findIndex(mention => mention.id === selectedMention.id);
45
- return index === -1 ? undefined : index;
46
- }
47
- return;
48
- };
49
- const isClicked = insertType => insertType === 'selected';
50
- export const buildTypeAheadInviteItemViewedPayload = (sessionId, contextIdentifierProvider, userRole) => {
51
- const {
52
- containerId,
53
- objectId,
54
- childObjectId
55
- } = contextIdentifierProvider || {};
56
- return buildAnalyticsPayload('inviteItem', 'rendered', UI_EVENT_TYPE, sessionId, {
57
- containerId,
58
- objectId,
59
- childObjectId,
60
- userRole
61
- });
62
- };
63
- export const buildTypeAheadInviteExposurePayload = (sessionId, contextIdentifierProvider, inviteExperimentCohort, userRole) => {
64
- const {
65
- containerId,
66
- objectId,
67
- childObjectId
68
- } = contextIdentifierProvider || {};
69
- return buildAnalyticsPayload('feature', 'exposed', OPERATIONAL_EVENT_TYPE, sessionId, {
70
- flagKey: 'confluence.frontend.invite.from.mention',
71
- value: inviteExperimentCohort || 'not-enrolled',
72
- containerId,
73
- objectId,
74
- childObjectId,
75
- userRole
76
- }, ['measurement', 'hasCustomAttributes']);
77
- };
78
- export const buildTypeAheadInviteItemClickedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, query, contextIdentifierProvider, userRole) => {
79
- const {
80
- queryLength,
81
- spaceInQuery
82
- } = extractAttributesFromQuery(query);
83
- const {
84
- containerId,
85
- objectId,
86
- childObjectId
87
- } = contextIdentifierProvider || {};
88
- return buildAnalyticsPayload('inviteItem', isClicked(insertType) ? 'clicked' : 'pressed', UI_EVENT_TYPE, sessionId, {
89
- duration,
90
- queryLength,
91
- spaceInQuery,
92
- upKeyCount,
93
- downKeyCount,
94
- containerId,
95
- objectId,
96
- childObjectId,
97
- userRole
98
- });
99
- };
100
- export const buildTypeAheadInsertedPayload = (duration, upKeyCount, downKeyCount, sessionId, insertType, mention, mentionList, query, contextIdentifierProvider) => {
101
- const {
102
- queryLength,
103
- spaceInQuery
104
- } = extractAttributesFromQuery(query);
105
- let analyticsPayload = buildAnalyticsPayload('mentionTypeahead', isClicked(insertType) ? 'clicked' : 'pressed', UI_EVENT_TYPE, sessionId, {
106
- duration,
107
- position: getPosition(mentionList, mention),
108
- keyboardKey: isClicked(insertType) ? undefined : insertType,
109
- source: mention.source,
110
- queryLength,
111
- spaceInQuery,
112
- isSpecial: isSpecialMention(mention),
113
- accessLevel: mention.accessLevel || '',
114
- userType: mention.userType,
115
- userId: mention.id,
116
- upKeyCount,
117
- downKeyCount,
118
- memberCount: isTeamType(mention.userType) && mention.context ? mention.context.memberCount : null,
119
- includesYou: isTeamType(mention.userType) && mention.context ? mention.context.includesYou : null
120
- });
121
- if (contextIdentifierProvider) {
122
- analyticsPayload.containerId = contextIdentifierProvider.containerId || undefined;
123
- analyticsPayload.objectId = contextIdentifierProvider.objectId || undefined;
124
- analyticsPayload.childObjectId = contextIdentifierProvider.childObjectId || undefined;
125
- }
126
- return analyticsPayload;
127
- };
128
- export const buildTypeAheadRenderedPayload = (duration, userIds, query, teams) => {
129
- const {
130
- queryLength,
131
- spaceInQuery
132
- } = extractAttributesFromQuery(query);
133
- const actionSubject = userIds ? 'mentionTypeahead' : 'teamMentionTypeahead';
134
- return {
135
- action: 'rendered',
136
- actionSubject,
137
- eventType: OPERATIONAL_EVENT_TYPE,
138
- attributes: {
139
- componentName,
140
- duration,
141
- userIds,
142
- teams,
143
- queryLength,
144
- spaceInQuery
145
- }
146
- };
147
- };
@@ -1,124 +0,0 @@
1
- import React from 'react';
2
- import uuid from 'uuid';
3
- import { ELEMENTS_CHANNEL } from '@atlaskit/mention/resource';
4
- import { mention } from '@atlaskit/adf-schema';
5
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
6
- import ToolbarMention from './ui/ToolbarMention';
7
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
- import { IconMention } from '@atlaskit/editor-common/quick-insert';
9
- import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
- import { createTypeAheadConfig } from './type-ahead';
11
- import { mentionPluginKey } from './pm-plugins/key';
12
- import { createMentionPlugin } from './pm-plugins/main';
13
- export { mentionPluginKey };
14
- const mentionsPlugin = ({
15
- config: options,
16
- api
17
- }) => {
18
- let sessionId = uuid();
19
- const fireEvent = payload => {
20
- var _api$analytics$shared, _api$analytics;
21
- const {
22
- createAnalyticsEvent
23
- } = (_api$analytics$shared = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.sharedState.currentState()) !== null && _api$analytics$shared !== void 0 ? _api$analytics$shared : {};
24
- if (!createAnalyticsEvent) {
25
- return;
26
- }
27
- if (payload.attributes && !payload.attributes.sessionId) {
28
- payload.attributes.sessionId = sessionId;
29
- }
30
- createAnalyticsEvent(payload).fire(ELEMENTS_CHANNEL);
31
- };
32
- const typeAhead = createTypeAheadConfig({
33
- sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
34
- mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
35
- HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
36
- fireEvent
37
- });
38
- return {
39
- name: 'mention',
40
- nodes() {
41
- return [{
42
- name: 'mention',
43
- node: mention
44
- }];
45
- },
46
- pmPlugins() {
47
- return [{
48
- name: 'mention',
49
- plugin: pmPluginFactoryParams => createMentionPlugin(pmPluginFactoryParams, fireEvent, options)
50
- }];
51
- },
52
- secondaryToolbarComponent({
53
- editorView,
54
- disabled
55
- }) {
56
- const openMentionTypeAhead = () => {
57
- var _api$typeAhead, _api$typeAhead$action;
58
- api === null || api === void 0 ? void 0 : (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 ? void 0 : (_api$typeAhead$action = _api$typeAhead.actions) === null || _api$typeAhead$action === void 0 ? void 0 : _api$typeAhead$action.open({
59
- triggerHandler: typeAhead,
60
- inputMethod: INPUT_METHOD.INSERT_MENU
61
- });
62
- };
63
- return /*#__PURE__*/React.createElement(WithPluginState, {
64
- editorView: editorView,
65
- plugins: {
66
- mentionState: mentionPluginKey
67
- },
68
- render: ({
69
- mentionState = {}
70
- }) => !mentionState.mentionProvider ? null : /*#__PURE__*/React.createElement(ToolbarMention, {
71
- editorView: editorView,
72
- onInsertMention: openMentionTypeAhead,
73
- isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
74
- })
75
- });
76
- },
77
- actions: {
78
- openTypeAhead(inputMethod) {
79
- var _api$typeAhead2, _api$typeAhead2$actio;
80
- return Boolean(api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.open({
81
- triggerHandler: typeAhead,
82
- inputMethod
83
- }));
84
- }
85
- },
86
- getSharedState(editorState) {
87
- if (!editorState) {
88
- return undefined;
89
- }
90
- const mentionPluginState = mentionPluginKey.getState(editorState);
91
- return {
92
- ...mentionPluginState,
93
- typeAheadHandler: typeAhead
94
- };
95
- },
96
- pluginsOptions: {
97
- quickInsert: ({
98
- formatMessage
99
- }) => [{
100
- id: 'mention',
101
- title: formatMessage(messages.mention),
102
- description: formatMessage(messages.mentionDescription),
103
- keywords: ['team', 'user'],
104
- priority: 400,
105
- keyshortcut: '@',
106
- icon: () => /*#__PURE__*/React.createElement(IconMention, null),
107
- action(insert, state) {
108
- const tr = insert(undefined);
109
- const pluginState = mentionPluginKey.getState(state);
110
- if (pluginState && pluginState.canInsertMention === false) {
111
- return false;
112
- }
113
- api === null || api === void 0 ? void 0 : api.typeAhead.actions.openAtTransaction({
114
- triggerHandler: typeAhead,
115
- inputMethod: INPUT_METHOD.QUICK_INSERT
116
- })(tr);
117
- return tr;
118
- }
119
- }],
120
- typeAhead
121
- }
122
- };
123
- };
124
- export default mentionsPlugin;
@@ -1,23 +0,0 @@
1
- import { defineMessages } from 'react-intl-next';
2
- export const messages = defineMessages({
3
- inviteItemTitle: {
4
- id: 'fabric.editor.inviteItem.title',
5
- defaultMessage: '{userRole, select, admin {Invite} trusted {Invite} other {Add}} teammate to {productName}',
6
- description: 'Title of the invite teammate item in typeahead plugin'
7
- },
8
- mentionsAddLabel: {
9
- id: 'fabric.editor.mentionsAddLabel',
10
- defaultMessage: 'add-icon',
11
- description: 'icon label to describe adding a new mention'
12
- },
13
- mentionsIconLabel: {
14
- id: 'fabric.editor.mentionsIconLabel',
15
- defaultMessage: 'Mention',
16
- description: 'icon label to describe the mention icon'
17
- },
18
- mentionsNodeLabel: {
19
- id: 'fabric.editor.mentionNode.label',
20
- defaultMessage: 'Tagged user',
21
- description: 'Label to indicate mention node to Screen reader users, that preceeds with user name ex: "Tagged user @XXX'
22
- }
23
- });
@@ -1,80 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { WithProviders } from '@atlaskit/editor-common/provider-factory';
3
- import Mention from '../ui/Mention';
4
- import { useIntl } from 'react-intl-next';
5
- import { messages } from '../messages';
6
- import { isResolvingMentionProvider, MentionNameStatus } from '@atlaskit/mention';
7
- import { isPromise } from '@atlaskit/mention/types';
8
- const UNKNOWN_USER_ID = '_|unknown|_';
9
- const MentionAssistiveTextComponent = ({
10
- id,
11
- text,
12
- providers,
13
- accessLevel,
14
- mentionProvider
15
- }) => {
16
- const [resolvedName, setResolvedName] = useState(text);
17
- const intl = useIntl();
18
- const processName = name => {
19
- if (name.status === MentionNameStatus.OK) {
20
- return `@${name.name || ''}`;
21
- } else {
22
- return `@${UNKNOWN_USER_ID}`;
23
- }
24
- };
25
- useEffect(() => {
26
- if (mentionProvider) {
27
- mentionProvider.then(async provider => {
28
- if (!text && isResolvingMentionProvider(provider)) {
29
- const nameDetail = provider.resolveMentionName(id);
30
- if (isPromise(nameDetail)) {
31
- return processName(await nameDetail);
32
- } else {
33
- return processName(nameDetail);
34
- }
35
- } else {
36
- return text;
37
- }
38
- }).then(resolvedName => {
39
- setResolvedName(resolvedName);
40
- });
41
- }
42
- }, [id, text, mentionProvider]);
43
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
44
- className: 'assistive'
45
- }, `${intl.formatMessage(messages.mentionsNodeLabel)} ${resolvedName}`), /*#__PURE__*/React.createElement("span", {
46
- "aria-hidden": "true"
47
- }, /*#__PURE__*/React.createElement(Mention, {
48
- id: id,
49
- text: resolvedName,
50
- accessLevel: accessLevel,
51
- providers: providers
52
- })));
53
- };
54
- export const MentionNodeView = props => {
55
- const {
56
- providerFactory
57
- } = props;
58
- const {
59
- id,
60
- text,
61
- accessLevel
62
- } = props.node.attrs;
63
- const renderAssistiveTextWithProviders = providers => {
64
- const {
65
- mentionProvider
66
- } = providers;
67
- return /*#__PURE__*/React.createElement(MentionAssistiveTextComponent, {
68
- mentionProvider: mentionProvider,
69
- id: id,
70
- text: text,
71
- providers: providerFactory,
72
- accessLevel: accessLevel
73
- });
74
- };
75
- return /*#__PURE__*/React.createElement(WithProviders, {
76
- providers: ['mentionProvider', 'profilecardProvider'],
77
- providerFactory: providerFactory,
78
- renderNode: renderAssistiveTextWithProviders
79
- });
80
- };
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export const mentionPluginKey = new PluginKey('mentionPlugin');