@atlaskit/editor-core 188.10.5 → 188.11.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.
Files changed (181) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/architecture/0003-explicit-plugin-dependencies.md +1 -1
  3. package/dist/cjs/labs/next/presets/universal.js +4 -3
  4. package/dist/cjs/messages.js +1 -2
  5. package/dist/cjs/plugins/index.js +0 -14
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/es2019/labs/next/presets/universal.js +3 -2
  8. package/dist/es2019/messages.js +1 -2
  9. package/dist/es2019/plugins/index.js +0 -2
  10. package/dist/es2019/version-wrapper.js +1 -1
  11. package/dist/esm/labs/next/presets/universal.js +3 -2
  12. package/dist/esm/messages.js +1 -2
  13. package/dist/esm/plugins/index.js +0 -2
  14. package/dist/esm/version-wrapper.js +1 -1
  15. package/dist/types/messages.d.ts +1 -2
  16. package/dist/types/plugins/index.d.ts +0 -2
  17. package/dist/types/plugins/insert-block/types.d.ts +2 -4
  18. package/dist/types/types/editor-props.d.ts +1 -1
  19. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  20. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  21. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  22. package/dist/types-ts4.5/messages.d.ts +1 -2
  23. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  24. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -4
  25. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  26. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  27. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  28. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  29. package/package.json +7 -10
  30. package/report.api.md +1 -9
  31. package/tmp/api-report-tmp.d.ts +1 -9
  32. package/dist/cjs/plugins/date/actions.js +0 -105
  33. package/dist/cjs/plugins/date/commands.js +0 -118
  34. package/dist/cjs/plugins/date/index.js +0 -13
  35. package/dist/cjs/plugins/date/nodeviews/date.js +0 -44
  36. package/dist/cjs/plugins/date/nodeviews/messages.js +0 -14
  37. package/dist/cjs/plugins/date/plugin.js +0 -197
  38. package/dist/cjs/plugins/date/pm-plugins/keymap.js +0 -41
  39. package/dist/cjs/plugins/date/pm-plugins/main.js +0 -39
  40. package/dist/cjs/plugins/date/pm-plugins/plugin-key.js +0 -8
  41. package/dist/cjs/plugins/date/pm-plugins/types.js +0 -5
  42. package/dist/cjs/plugins/date/pm-plugins/utils.js +0 -70
  43. package/dist/cjs/plugins/date/types.js +0 -5
  44. package/dist/cjs/plugins/date/ui/DatePicker/date-picker-input.js +0 -244
  45. package/dist/cjs/plugins/date/ui/DatePicker/index.js +0 -168
  46. package/dist/cjs/plugins/date/utils/formatParse.js +0 -88
  47. package/dist/cjs/plugins/date/utils/internal.js +0 -176
  48. package/dist/cjs/plugins/mentions/analytics.js +0 -157
  49. package/dist/cjs/plugins/mentions/index.js +0 -142
  50. package/dist/cjs/plugins/mentions/messages.js +0 -29
  51. package/dist/cjs/plugins/mentions/nodeviews/mention.js +0 -117
  52. package/dist/cjs/plugins/mentions/pm-plugins/key.js +0 -8
  53. package/dist/cjs/plugins/mentions/pm-plugins/main.js +0 -156
  54. package/dist/cjs/plugins/mentions/pm-plugins/utils.js +0 -23
  55. package/dist/cjs/plugins/mentions/type-ahead/index.js +0 -362
  56. package/dist/cjs/plugins/mentions/types.js +0 -5
  57. package/dist/cjs/plugins/mentions/ui/InviteItem/index.js +0 -76
  58. package/dist/cjs/plugins/mentions/ui/InviteItem/styles.js +0 -19
  59. package/dist/cjs/plugins/mentions/ui/Mention/index.js +0 -98
  60. package/dist/cjs/plugins/mentions/ui/ToolbarMention/index.js +0 -63
  61. package/dist/cjs/plugins/mentions/utils.js +0 -32
  62. package/dist/es2019/plugins/date/actions.js +0 -93
  63. package/dist/es2019/plugins/date/commands.js +0 -113
  64. package/dist/es2019/plugins/date/index.js +0 -1
  65. package/dist/es2019/plugins/date/nodeviews/date.js +0 -47
  66. package/dist/es2019/plugins/date/nodeviews/messages.js +0 -8
  67. package/dist/es2019/plugins/date/plugin.js +0 -183
  68. package/dist/es2019/plugins/date/pm-plugins/keymap.js +0 -34
  69. package/dist/es2019/plugins/date/pm-plugins/main.js +0 -35
  70. package/dist/es2019/plugins/date/pm-plugins/plugin-key.js +0 -2
  71. package/dist/es2019/plugins/date/pm-plugins/types.js +0 -1
  72. package/dist/es2019/plugins/date/pm-plugins/utils.js +0 -70
  73. package/dist/es2019/plugins/date/types.js +0 -1
  74. package/dist/es2019/plugins/date/ui/DatePicker/date-picker-input.js +0 -233
  75. package/dist/es2019/plugins/date/ui/DatePicker/index.js +0 -152
  76. package/dist/es2019/plugins/date/utils/formatParse.js +0 -83
  77. package/dist/es2019/plugins/date/utils/internal.js +0 -151
  78. package/dist/es2019/plugins/mentions/analytics.js +0 -147
  79. package/dist/es2019/plugins/mentions/index.js +0 -124
  80. package/dist/es2019/plugins/mentions/messages.js +0 -23
  81. package/dist/es2019/plugins/mentions/nodeviews/mention.js +0 -80
  82. package/dist/es2019/plugins/mentions/pm-plugins/key.js +0 -2
  83. package/dist/es2019/plugins/mentions/pm-plugins/main.js +0 -143
  84. package/dist/es2019/plugins/mentions/pm-plugins/utils.js +0 -14
  85. package/dist/es2019/plugins/mentions/type-ahead/index.js +0 -338
  86. package/dist/es2019/plugins/mentions/types.js +0 -1
  87. package/dist/es2019/plugins/mentions/ui/InviteItem/index.js +0 -66
  88. package/dist/es2019/plugins/mentions/ui/InviteItem/styles.js +0 -47
  89. package/dist/es2019/plugins/mentions/ui/Mention/index.js +0 -71
  90. package/dist/es2019/plugins/mentions/ui/ToolbarMention/index.js +0 -33
  91. package/dist/es2019/plugins/mentions/utils.js +0 -20
  92. package/dist/esm/plugins/date/actions.js +0 -99
  93. package/dist/esm/plugins/date/commands.js +0 -112
  94. package/dist/esm/plugins/date/index.js +0 -1
  95. package/dist/esm/plugins/date/nodeviews/date.js +0 -37
  96. package/dist/esm/plugins/date/nodeviews/messages.js +0 -8
  97. package/dist/esm/plugins/date/plugin.js +0 -185
  98. package/dist/esm/plugins/date/pm-plugins/keymap.js +0 -34
  99. package/dist/esm/plugins/date/pm-plugins/main.js +0 -34
  100. package/dist/esm/plugins/date/pm-plugins/plugin-key.js +0 -2
  101. package/dist/esm/plugins/date/pm-plugins/types.js +0 -1
  102. package/dist/esm/plugins/date/pm-plugins/utils.js +0 -61
  103. package/dist/esm/plugins/date/types.js +0 -1
  104. package/dist/esm/plugins/date/ui/DatePicker/date-picker-input.js +0 -238
  105. package/dist/esm/plugins/date/ui/DatePicker/index.js +0 -162
  106. package/dist/esm/plugins/date/utils/formatParse.js +0 -79
  107. package/dist/esm/plugins/date/utils/internal.js +0 -165
  108. package/dist/esm/plugins/mentions/analytics.js +0 -150
  109. package/dist/esm/plugins/mentions/index.js +0 -130
  110. package/dist/esm/plugins/mentions/messages.js +0 -23
  111. package/dist/esm/plugins/mentions/nodeviews/mention.js +0 -107
  112. package/dist/esm/plugins/mentions/pm-plugins/key.js +0 -2
  113. package/dist/esm/plugins/mentions/pm-plugins/main.js +0 -148
  114. package/dist/esm/plugins/mentions/pm-plugins/utils.js +0 -16
  115. package/dist/esm/plugins/mentions/type-ahead/index.js +0 -350
  116. package/dist/esm/plugins/mentions/types.js +0 -1
  117. package/dist/esm/plugins/mentions/ui/InviteItem/index.js +0 -65
  118. package/dist/esm/plugins/mentions/ui/InviteItem/styles.js +0 -12
  119. package/dist/esm/plugins/mentions/ui/Mention/index.js +0 -91
  120. package/dist/esm/plugins/mentions/ui/ToolbarMention/index.js +0 -53
  121. package/dist/esm/plugins/mentions/utils.js +0 -26
  122. package/dist/types/plugins/date/actions.d.ts +0 -47
  123. package/dist/types/plugins/date/commands.d.ts +0 -12
  124. package/dist/types/plugins/date/index.d.ts +0 -1
  125. package/dist/types/plugins/date/nodeviews/date.d.ts +0 -3
  126. package/dist/types/plugins/date/nodeviews/messages.d.ts +0 -7
  127. package/dist/types/plugins/date/plugin.d.ts +0 -3
  128. package/dist/types/plugins/date/pm-plugins/keymap.d.ts +0 -3
  129. package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -6
  130. package/dist/types/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
  131. package/dist/types/plugins/date/pm-plugins/types.d.ts +0 -12
  132. package/dist/types/plugins/date/pm-plugins/utils.d.ts +0 -5
  133. package/dist/types/plugins/date/types.d.ts +0 -1
  134. package/dist/types/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
  135. package/dist/types/plugins/date/ui/DatePicker/index.d.ts +0 -36
  136. package/dist/types/plugins/date/utils/formatParse.d.ts +0 -27
  137. package/dist/types/plugins/date/utils/internal.d.ts +0 -33
  138. package/dist/types/plugins/mentions/analytics.d.ts +0 -13
  139. package/dist/types/plugins/mentions/index.d.ts +0 -19
  140. package/dist/types/plugins/mentions/messages.d.ts +0 -22
  141. package/dist/types/plugins/mentions/nodeviews/mention.d.ts +0 -9
  142. package/dist/types/plugins/mentions/pm-plugins/key.d.ts +0 -3
  143. package/dist/types/plugins/mentions/pm-plugins/main.d.ts +0 -6
  144. package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +0 -4
  145. package/dist/types/plugins/mentions/type-ahead/index.d.ts +0 -17
  146. package/dist/types/plugins/mentions/types.d.ts +0 -24
  147. package/dist/types/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
  148. package/dist/types/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
  149. package/dist/types/plugins/mentions/ui/Mention/index.d.ts +0 -19
  150. package/dist/types/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
  151. package/dist/types/plugins/mentions/utils.d.ts +0 -8
  152. package/dist/types-ts4.5/plugins/date/actions.d.ts +0 -58
  153. package/dist/types-ts4.5/plugins/date/commands.d.ts +0 -14
  154. package/dist/types-ts4.5/plugins/date/index.d.ts +0 -1
  155. package/dist/types-ts4.5/plugins/date/nodeviews/date.d.ts +0 -3
  156. package/dist/types-ts4.5/plugins/date/nodeviews/messages.d.ts +0 -7
  157. package/dist/types-ts4.5/plugins/date/plugin.d.ts +0 -3
  158. package/dist/types-ts4.5/plugins/date/pm-plugins/keymap.d.ts +0 -3
  159. package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -6
  160. package/dist/types-ts4.5/plugins/date/pm-plugins/plugin-key.d.ts +0 -3
  161. package/dist/types-ts4.5/plugins/date/pm-plugins/types.d.ts +0 -12
  162. package/dist/types-ts4.5/plugins/date/pm-plugins/utils.d.ts +0 -5
  163. package/dist/types-ts4.5/plugins/date/types.d.ts +0 -1
  164. package/dist/types-ts4.5/plugins/date/ui/DatePicker/date-picker-input.d.ts +0 -24
  165. package/dist/types-ts4.5/plugins/date/ui/DatePicker/index.d.ts +0 -36
  166. package/dist/types-ts4.5/plugins/date/utils/formatParse.d.ts +0 -27
  167. package/dist/types-ts4.5/plugins/date/utils/internal.d.ts +0 -33
  168. package/dist/types-ts4.5/plugins/mentions/analytics.d.ts +0 -13
  169. package/dist/types-ts4.5/plugins/mentions/index.d.ts +0 -22
  170. package/dist/types-ts4.5/plugins/mentions/messages.d.ts +0 -22
  171. package/dist/types-ts4.5/plugins/mentions/nodeviews/mention.d.ts +0 -9
  172. package/dist/types-ts4.5/plugins/mentions/pm-plugins/key.d.ts +0 -3
  173. package/dist/types-ts4.5/plugins/mentions/pm-plugins/main.d.ts +0 -6
  174. package/dist/types-ts4.5/plugins/mentions/pm-plugins/utils.d.ts +0 -4
  175. package/dist/types-ts4.5/plugins/mentions/type-ahead/index.d.ts +0 -17
  176. package/dist/types-ts4.5/plugins/mentions/types.d.ts +0 -24
  177. package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/index.d.ts +0 -22
  178. package/dist/types-ts4.5/plugins/mentions/ui/InviteItem/styles.d.ts +0 -8
  179. package/dist/types-ts4.5/plugins/mentions/ui/Mention/index.d.ts +0 -19
  180. package/dist/types-ts4.5/plugins/mentions/ui/ToolbarMention/index.d.ts +0 -13
  181. package/dist/types-ts4.5/plugins/mentions/utils.d.ts +0 -8
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- Object.defineProperty(exports, "mentionPluginKey", {
9
- enumerable: true,
10
- get: function get() {
11
- return _key.mentionPluginKey;
12
- }
13
- });
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = _interopRequireDefault(require("react"));
16
- var _uuid = _interopRequireDefault(require("uuid"));
17
- var _resource = require("@atlaskit/mention/resource");
18
- var _adfSchema = require("@atlaskit/adf-schema");
19
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
20
- var _ToolbarMention = _interopRequireDefault(require("./ui/ToolbarMention"));
21
- var _analytics = require("@atlaskit/editor-common/analytics");
22
- var _quickInsert = require("@atlaskit/editor-common/quick-insert");
23
- var _messages = require("@atlaskit/editor-common/messages");
24
- var _typeAhead = require("./type-ahead");
25
- var _key = require("./pm-plugins/key");
26
- var _main = require("./pm-plugins/main");
27
- 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; }
28
- 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; }
29
- var mentionsPlugin = function mentionsPlugin(_ref) {
30
- var options = _ref.config,
31
- api = _ref.api;
32
- var sessionId = (0, _uuid.default)();
33
- var fireEvent = function fireEvent(payload) {
34
- var _api$analytics$shared, _api$analytics;
35
- var _ref2 = (_api$analytics$shared = api === null || api === 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 : {},
36
- createAnalyticsEvent = _ref2.createAnalyticsEvent;
37
- if (!createAnalyticsEvent) {
38
- return;
39
- }
40
- if (payload.attributes && !payload.attributes.sessionId) {
41
- payload.attributes.sessionId = sessionId;
42
- }
43
- createAnalyticsEvent(payload).fire(_resource.ELEMENTS_CHANNEL);
44
- };
45
- var typeAhead = (0, _typeAhead.createTypeAheadConfig)({
46
- sanitizePrivateContent: options === null || options === void 0 ? void 0 : options.sanitizePrivateContent,
47
- mentionInsertDisplayName: options === null || options === void 0 ? void 0 : options.insertDisplayName,
48
- HighlightComponent: options === null || options === void 0 ? void 0 : options.HighlightComponent,
49
- fireEvent: fireEvent
50
- });
51
- return {
52
- name: 'mention',
53
- nodes: function nodes() {
54
- return [{
55
- name: 'mention',
56
- node: _adfSchema.mention
57
- }];
58
- },
59
- pmPlugins: function pmPlugins() {
60
- return [{
61
- name: 'mention',
62
- plugin: function plugin(pmPluginFactoryParams) {
63
- return (0, _main.createMentionPlugin)(pmPluginFactoryParams, fireEvent, options);
64
- }
65
- }];
66
- },
67
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref3) {
68
- var editorView = _ref3.editorView,
69
- disabled = _ref3.disabled;
70
- var openMentionTypeAhead = function openMentionTypeAhead() {
71
- var _api$typeAhead;
72
- api === null || api === void 0 || (_api$typeAhead = api.typeAhead) === null || _api$typeAhead === void 0 || (_api$typeAhead = _api$typeAhead.actions) === null || _api$typeAhead === void 0 || _api$typeAhead.open({
73
- triggerHandler: typeAhead,
74
- inputMethod: _analytics.INPUT_METHOD.INSERT_MENU
75
- });
76
- };
77
- return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
78
- editorView: editorView,
79
- plugins: {
80
- mentionState: _key.mentionPluginKey
81
- },
82
- render: function render(_ref4) {
83
- var _ref4$mentionState = _ref4.mentionState,
84
- mentionState = _ref4$mentionState === void 0 ? {} : _ref4$mentionState;
85
- return !mentionState.mentionProvider ? null : /*#__PURE__*/_react.default.createElement(_ToolbarMention.default, {
86
- editorView: editorView,
87
- onInsertMention: openMentionTypeAhead,
88
- isDisabled: disabled || (api === null || api === void 0 ? void 0 : api.typeAhead.actions.isAllowed(editorView.state))
89
- });
90
- }
91
- });
92
- },
93
- actions: {
94
- openTypeAhead: function openTypeAhead(inputMethod) {
95
- var _api$typeAhead2;
96
- return Boolean(api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 ? void 0 : _api$typeAhead2.open({
97
- triggerHandler: typeAhead,
98
- inputMethod: inputMethod
99
- }));
100
- }
101
- },
102
- getSharedState: function getSharedState(editorState) {
103
- if (!editorState) {
104
- return undefined;
105
- }
106
- var mentionPluginState = _key.mentionPluginKey.getState(editorState);
107
- return _objectSpread(_objectSpread({}, mentionPluginState), {}, {
108
- typeAheadHandler: typeAhead
109
- });
110
- },
111
- pluginsOptions: {
112
- quickInsert: function quickInsert(_ref5) {
113
- var formatMessage = _ref5.formatMessage;
114
- return [{
115
- id: 'mention',
116
- title: formatMessage(_messages.toolbarInsertBlockMessages.mention),
117
- description: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
118
- keywords: ['team', 'user'],
119
- priority: 400,
120
- keyshortcut: '@',
121
- icon: function icon() {
122
- return /*#__PURE__*/_react.default.createElement(_quickInsert.IconMention, null);
123
- },
124
- action: function action(insert, state) {
125
- var tr = insert(undefined);
126
- var pluginState = _key.mentionPluginKey.getState(state);
127
- if (pluginState && pluginState.canInsertMention === false) {
128
- return false;
129
- }
130
- api === null || api === void 0 || api.typeAhead.actions.openAtTransaction({
131
- triggerHandler: typeAhead,
132
- inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
133
- })(tr);
134
- return tr;
135
- }
136
- }];
137
- },
138
- typeAhead: typeAhead
139
- }
140
- };
141
- };
142
- var _default = exports.default = mentionsPlugin;
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.messages = void 0;
7
- var _reactIntlNext = require("react-intl-next");
8
- var messages = exports.messages = (0, _reactIntlNext.defineMessages)({
9
- inviteItemTitle: {
10
- id: 'fabric.editor.inviteItem.title',
11
- defaultMessage: '{userRole, select, admin {Invite} trusted {Invite} other {Add}} teammate to {productName}',
12
- description: 'Title of the invite teammate item in typeahead plugin'
13
- },
14
- mentionsAddLabel: {
15
- id: 'fabric.editor.mentionsAddLabel',
16
- defaultMessage: 'add-icon',
17
- description: 'icon label to describe adding a new mention'
18
- },
19
- mentionsIconLabel: {
20
- id: 'fabric.editor.mentionsIconLabel',
21
- defaultMessage: 'Mention',
22
- description: 'icon label to describe the mention icon'
23
- },
24
- mentionsNodeLabel: {
25
- id: 'fabric.editor.mentionNode.label',
26
- defaultMessage: 'Tagged user',
27
- description: 'Label to indicate mention node to Screen reader users, that preceeds with user name ex: "Tagged user @XXX'
28
- }
29
- });
@@ -1,117 +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.MentionNodeView = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _providerFactory = require("@atlaskit/editor-common/provider-factory");
14
- var _Mention = _interopRequireDefault(require("../ui/Mention"));
15
- var _reactIntlNext = require("react-intl-next");
16
- var _messages = require("../messages");
17
- var _mention = require("@atlaskit/mention");
18
- var _types = require("@atlaskit/mention/types");
19
- 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); }
20
- 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; }
21
- var UNKNOWN_USER_ID = '_|unknown|_';
22
- var MentionAssistiveTextComponent = function MentionAssistiveTextComponent(_ref) {
23
- var id = _ref.id,
24
- text = _ref.text,
25
- providers = _ref.providers,
26
- accessLevel = _ref.accessLevel,
27
- mentionProvider = _ref.mentionProvider;
28
- var _useState = (0, _react.useState)(text),
29
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
30
- resolvedName = _useState2[0],
31
- setResolvedName = _useState2[1];
32
- var intl = (0, _reactIntlNext.useIntl)();
33
- var processName = function processName(name) {
34
- if (name.status === _mention.MentionNameStatus.OK) {
35
- return "@".concat(name.name || '');
36
- } else {
37
- return "@".concat(UNKNOWN_USER_ID);
38
- }
39
- };
40
- (0, _react.useEffect)(function () {
41
- if (mentionProvider) {
42
- mentionProvider.then( /*#__PURE__*/function () {
43
- var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(provider) {
44
- var nameDetail;
45
- return _regenerator.default.wrap(function _callee$(_context) {
46
- while (1) switch (_context.prev = _context.next) {
47
- case 0:
48
- if (!(!text && (0, _mention.isResolvingMentionProvider)(provider))) {
49
- _context.next = 13;
50
- break;
51
- }
52
- nameDetail = provider.resolveMentionName(id);
53
- if (!(0, _types.isPromise)(nameDetail)) {
54
- _context.next = 10;
55
- break;
56
- }
57
- _context.t0 = processName;
58
- _context.next = 6;
59
- return nameDetail;
60
- case 6:
61
- _context.t1 = _context.sent;
62
- return _context.abrupt("return", (0, _context.t0)(_context.t1));
63
- case 10:
64
- return _context.abrupt("return", processName(nameDetail));
65
- case 11:
66
- _context.next = 14;
67
- break;
68
- case 13:
69
- return _context.abrupt("return", text);
70
- case 14:
71
- case "end":
72
- return _context.stop();
73
- }
74
- }, _callee);
75
- }));
76
- return function (_x) {
77
- return _ref2.apply(this, arguments);
78
- };
79
- }()).then(function (resolvedName) {
80
- setResolvedName(resolvedName);
81
- });
82
- }
83
- }, [id, text, mentionProvider]);
84
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
85
- className: 'assistive'
86
- }, "".concat(intl.formatMessage(_messages.messages.mentionsNodeLabel), " ").concat(resolvedName)), /*#__PURE__*/_react.default.createElement("span", {
87
- "aria-hidden": "true"
88
- }, /*#__PURE__*/_react.default.createElement(_Mention.default, {
89
- id: id,
90
- text: resolvedName,
91
- accessLevel: accessLevel,
92
- providers: providers
93
- })));
94
- };
95
- var MentionNodeView = exports.MentionNodeView = function MentionNodeView(props) {
96
- var providerFactory = props.providerFactory;
97
- var _props$node$attrs = props.node.attrs,
98
- id = _props$node$attrs.id,
99
- text = _props$node$attrs.text,
100
- accessLevel = _props$node$attrs.accessLevel;
101
- var renderAssistiveTextWithProviders = function renderAssistiveTextWithProviders(providers) {
102
- var _ref3 = providers,
103
- mentionProvider = _ref3.mentionProvider;
104
- return /*#__PURE__*/_react.default.createElement(MentionAssistiveTextComponent, {
105
- mentionProvider: mentionProvider,
106
- id: id,
107
- text: text,
108
- providers: providerFactory,
109
- accessLevel: accessLevel
110
- });
111
- };
112
- return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
113
- providers: ['mentionProvider', 'profilecardProvider'],
114
- providerFactory: providerFactory,
115
- renderNode: renderAssistiveTextWithProviders
116
- });
117
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mentionPluginKey = void 0;
7
- var _state = require("@atlaskit/editor-prosemirror/state");
8
- var mentionPluginKey = exports.mentionPluginKey = new _state.PluginKey('mentionPlugin');
@@ -1,156 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createMentionPlugin = createMentionPlugin;
8
- exports.setContext = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
11
- var _resource = require("@atlaskit/mention/resource");
12
- var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
13
- var _mention = require("../nodeviews/mention");
14
- var _key = require("./key");
15
- var _utils = require("./utils");
16
- 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; }
17
- 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; }
18
- var ACTIONS = {
19
- SET_PROVIDER: 'SET_PROVIDER',
20
- SET_CONTEXT: 'SET_CONTEXT'
21
- };
22
- var setProvider = function setProvider(provider) {
23
- return function (state, dispatch) {
24
- if (dispatch) {
25
- dispatch(state.tr.setMeta(_key.mentionPluginKey, {
26
- action: ACTIONS.SET_PROVIDER,
27
- params: {
28
- provider: provider
29
- }
30
- }));
31
- }
32
- return true;
33
- };
34
- };
35
- var setContext = exports.setContext = function setContext(context) {
36
- return function (state, dispatch) {
37
- if (dispatch) {
38
- dispatch(state.tr.setMeta(_key.mentionPluginKey, {
39
- action: ACTIONS.SET_CONTEXT,
40
- params: {
41
- context: context
42
- }
43
- }));
44
- }
45
- return true;
46
- };
47
- };
48
- function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
49
- var mentionProvider;
50
- var sendAnalytics = function sendAnalytics(event, actionSubject, action, attributes) {
51
- if (event === _resource.SLI_EVENT_TYPE || event === _resource.SMART_EVENT_TYPE) {
52
- fireEvent((0, _resource.buildSliPayload)(actionSubject, action, attributes));
53
- }
54
- };
55
- return new _safePlugin.SafePlugin({
56
- key: _key.mentionPluginKey,
57
- state: {
58
- init: function init(_, state) {
59
- var canInsertMention = (0, _utils.canMentionBeCreatedInRange)(state.selection.from, state.selection.to)(state);
60
- return {
61
- canInsertMention: canInsertMention
62
- };
63
- },
64
- apply: function apply(tr, pluginState, oldState, newState) {
65
- var _ref = tr.getMeta(_key.mentionPluginKey) || {
66
- action: null,
67
- params: null
68
- },
69
- action = _ref.action,
70
- params = _ref.params;
71
- var hasNewPluginState = false;
72
- var newPluginState = pluginState;
73
- var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
74
- if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
75
- newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
76
- canInsertMention: (0, _utils.canMentionBeCreatedInRange)(newState.selection.from, newState.selection.to)(newState)
77
- });
78
- hasNewPluginState = true;
79
- }
80
- switch (action) {
81
- case ACTIONS.SET_PROVIDER:
82
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
83
- mentionProvider: params.provider
84
- });
85
- hasNewPluginState = true;
86
- break;
87
- case ACTIONS.SET_CONTEXT:
88
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
89
- contextIdentifierProvider: params.context
90
- });
91
- hasNewPluginState = true;
92
- break;
93
- }
94
- if (hasNewPluginState) {
95
- pmPluginFactoryParams.dispatch(_key.mentionPluginKey, newPluginState);
96
- }
97
- return newPluginState;
98
- }
99
- },
100
- props: {
101
- nodeViews: {
102
- mention: (0, _reactNodeView.getInlineNodeViewProducer)({
103
- pmPluginFactoryParams: pmPluginFactoryParams,
104
- Component: _mention.MentionNodeView,
105
- extraComponentProps: {
106
- providerFactory: pmPluginFactoryParams.providerFactory,
107
- options: options
108
- }
109
- })
110
- }
111
- },
112
- view: function view(editorView) {
113
- var providerHandler = function providerHandler(name, providerPromise) {
114
- switch (name) {
115
- case 'mentionProvider':
116
- if (!providerPromise) {
117
- return setProvider(undefined)(editorView.state, editorView.dispatch);
118
- }
119
- providerPromise.then(function (provider) {
120
- if (mentionProvider) {
121
- mentionProvider.unsubscribe('mentionPlugin');
122
- }
123
- mentionProvider = provider;
124
- setProvider(provider)(editorView.state, editorView.dispatch);
125
- provider.subscribe('mentionPlugin', undefined, undefined, undefined, undefined, sendAnalytics);
126
- }).catch(function () {
127
- return setProvider(undefined)(editorView.state, editorView.dispatch);
128
- });
129
- break;
130
- case 'contextIdentifierProvider':
131
- if (!providerPromise) {
132
- return setContext(undefined)(editorView.state, editorView.dispatch);
133
- }
134
- providerPromise.then(function (provider) {
135
- setContext(provider)(editorView.state, editorView.dispatch);
136
- });
137
- break;
138
- }
139
- return;
140
- };
141
- pmPluginFactoryParams.providerFactory.subscribe('mentionProvider', providerHandler);
142
- pmPluginFactoryParams.providerFactory.subscribe('contextIdentifierProvider', providerHandler);
143
- return {
144
- destroy: function destroy() {
145
- if (pmPluginFactoryParams.providerFactory) {
146
- pmPluginFactoryParams.providerFactory.unsubscribe('mentionProvider', providerHandler);
147
- pmPluginFactoryParams.providerFactory.unsubscribe('contextIdentifierProvider', providerHandler);
148
- }
149
- if (mentionProvider) {
150
- mentionProvider.unsubscribe('mentionPlugin');
151
- }
152
- }
153
- };
154
- }
155
- });
156
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.canMentionBeCreatedInRange = void 0;
7
- exports.getMentionPluginState = getMentionPluginState;
8
- var _key = require("./key");
9
- var _utils = require("@atlaskit/editor-prosemirror/utils");
10
- function getMentionPluginState(state) {
11
- return _key.mentionPluginKey.getState(state);
12
- }
13
- var canMentionBeCreatedInRange = exports.canMentionBeCreatedInRange = function canMentionBeCreatedInRange(from, to) {
14
- return function (state) {
15
- var $from = state.doc.resolve(from);
16
- var $to = state.doc.resolve(to);
17
- var mention = state.schema.nodes.mention.createChecked();
18
- if ($from.parent === $to.parent && (0, _utils.canInsert)($from, mention)) {
19
- return true;
20
- }
21
- return false;
22
- };
23
- };