@atlaskit/editor-core 187.6.0 → 187.6.1

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 (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/insert-block/index.js +7 -10
  3. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +2 -1
  4. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -32
  5. package/dist/cjs/plugins/mentions/index.js +11 -0
  6. package/dist/cjs/plugins/mentions/pm-plugins/main.js +24 -9
  7. package/dist/cjs/plugins/mentions/pm-plugins/utils.js +15 -1
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/cjs/version.json +1 -1
  10. package/dist/es2019/plugins/insert-block/index.js +4 -7
  11. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +2 -1
  12. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +11 -4
  13. package/dist/es2019/plugins/mentions/index.js +11 -0
  14. package/dist/es2019/plugins/mentions/pm-plugins/main.js +25 -9
  15. package/dist/es2019/plugins/mentions/pm-plugins/utils.js +11 -1
  16. package/dist/es2019/version-wrapper.js +1 -1
  17. package/dist/es2019/version.json +1 -1
  18. package/dist/esm/plugins/insert-block/index.js +5 -8
  19. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +2 -1
  20. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -32
  21. package/dist/esm/plugins/mentions/index.js +11 -0
  22. package/dist/esm/plugins/mentions/pm-plugins/main.js +24 -9
  23. package/dist/esm/plugins/mentions/pm-plugins/utils.js +13 -1
  24. package/dist/esm/version-wrapper.js +1 -1
  25. package/dist/esm/version.json +1 -1
  26. package/dist/types/plugins/insert-block/index.d.ts +5 -3
  27. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +7 -6
  28. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +10 -9
  29. package/dist/types/plugins/mentions/index.d.ts +3 -2
  30. package/dist/types/plugins/mentions/pm-plugins/utils.d.ts +3 -2
  31. package/dist/types/plugins/mentions/types.d.ts +1 -0
  32. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +5 -3
  33. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +7 -6
  34. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +10 -9
  35. package/dist/types-ts4.5/plugins/mentions/index.d.ts +3 -2
  36. package/dist/types-ts4.5/plugins/mentions/pm-plugins/utils.d.ts +3 -2
  37. package/dist/types-ts4.5/plugins/mentions/types.d.ts +1 -0
  38. package/package.json +1 -1
  39. package/report.api.md +1 -0
  40. package/tmp/api-report-tmp.d.ts +1 -0
@@ -3,7 +3,6 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
3
3
  import { pluginKey as blockTypeStateKey } from '../block-type/pm-plugins/main';
4
4
  import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
5
5
  import { isTypeAheadAllowed } from '../type-ahead/utils';
6
- import { mentionPluginKey } from '../mentions/pm-plugins/key';
7
6
  import { pluginKey as layoutStateKey } from '../layout';
8
7
  import { insertMacroFromMacroBrowser } from '../macro';
9
8
  import { emojiPluginKey } from '../emoji';
@@ -65,15 +64,13 @@ var insertBlockPlugin = function insertBlockPlugin() {
65
64
  typeAheadState: typeAheadPluginKey,
66
65
  blockTypeState: blockTypeStateKey,
67
66
  mediaState: mediaStateKey,
68
- mentionState: mentionPluginKey,
69
67
  macroState: macroStateKey,
70
68
  emojiState: emojiPluginKey,
71
69
  placeholderTextState: placeholderTextStateKey,
72
70
  layoutState: layoutStateKey
73
71
  },
74
72
  render: function render(_ref2) {
75
- var mentionState = _ref2.mentionState,
76
- blockTypeState = _ref2.blockTypeState,
73
+ var blockTypeState = _ref2.blockTypeState,
77
74
  mediaState = _ref2.mediaState,
78
75
  _ref2$macroState = _ref2.macroState,
79
76
  macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
@@ -94,7 +91,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
94
91
  isToolbarReducedSpacing: isToolbarReducedSpacing,
95
92
  isLastItem: isLastItem,
96
93
  featureFlags: featureFlags,
97
- mentionState: mentionState,
98
94
  blockTypeState: blockTypeState,
99
95
  mediaState: mediaState,
100
96
  macroState: macroState,
@@ -131,7 +127,6 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
131
127
  providers = _ref3.providers,
132
128
  pluginInjectionApi = _ref3.pluginInjectionApi,
133
129
  options = _ref3.options,
134
- mentionState = _ref3.mentionState,
135
130
  blockTypeState = _ref3.blockTypeState,
136
131
  mediaState = _ref3.mediaState,
137
132
  macroState = _ref3.macroState,
@@ -140,10 +135,11 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
140
135
  layoutState = _ref3.layoutState,
141
136
  featureFlags = _ref3.featureFlags;
142
137
  var buttons = toolbarSizeToButtons(toolbarSize);
143
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload']),
138
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']),
144
139
  dateState = _useSharedPluginState.dateState,
145
140
  hyperlinkState = _useSharedPluginState.hyperlinkState,
146
- imageUploadState = _useSharedPluginState.imageUploadState;
141
+ imageUploadState = _useSharedPluginState.imageUploadState,
142
+ mentionState = _useSharedPluginState.mentionState;
147
143
  return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
148
144
  pluginInjectionApi: pluginInjectionApi,
149
145
  buttons: buttons,
@@ -154,6 +150,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
154
150
  tableSupported: !!editorView.state.schema.nodes.table,
155
151
  actionSupported: !!editorView.state.schema.nodes.taskItem,
156
152
  mentionsSupported: !!(mentionState && mentionState.mentionProvider),
153
+ mentionsDisabled: !!(mentionState && !mentionState.canInsertMention),
157
154
  decisionSupported: !!editorView.state.schema.nodes.decisionItem,
158
155
  dateEnabled: !!dateState,
159
156
  placeholderTextEnabled: placeholderTextState && placeholderTextState.allowInserting,
@@ -37,6 +37,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
37
37
  imageUploadSupported = config.imageUploadSupported,
38
38
  imageUploadEnabled = config.imageUploadEnabled,
39
39
  mentionsSupported = config.mentionsSupported,
40
+ mentionsDisabled = config.mentionsDisabled,
40
41
  availableWrapperBlockTypes = config.availableWrapperBlockTypes,
41
42
  actionSupported = config.actionSupported,
42
43
  decisionSupported = config.decisionSupported,
@@ -89,7 +90,7 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
89
90
  items.push(mention({
90
91
  content: formatMessage(messages.mention),
91
92
  tooltipDescription: formatMessage(messages.mentionDescription),
92
- disabled: !isTypeAheadAllowed,
93
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled,
93
94
  'aria-haspopup': 'listbox'
94
95
  }));
95
96
  }
@@ -176,21 +176,28 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
176
176
  return true;
177
177
  });
178
178
  _defineProperty(_assertThisInitialized(_this), "insertMention", function (inputMethod) {
179
- var editorView = _this.props.editorView;
179
+ var _pluginInjectionApi$d3;
180
+ var _this$props2 = _this.props,
181
+ editorView = _this$props2.editorView,
182
+ pluginInjectionApi = _this$props2.pluginInjectionApi;
180
183
  if (!editorView) {
181
184
  return true;
182
185
  }
186
+ var pluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.mention) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.sharedState.currentState();
187
+ if (pluginState && pluginState.canInsertMention === false) {
188
+ return false;
189
+ }
183
190
  createTypeAheadTools(editorView).openMention(inputMethod);
184
191
  return true;
185
192
  });
186
193
  _defineProperty(_assertThisInitialized(_this), "insertTable", function (inputMethod) {
187
- var _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5, _pluginInjectionApi$d6;
188
- var _this$props2 = _this.props,
189
- pluginInjectionApi = _this$props2.pluginInjectionApi,
190
- editorView = _this$props2.editorView;
194
+ var _pluginInjectionApi$d4, _pluginInjectionApi$d5, _pluginInjectionApi$d6, _pluginInjectionApi$d7;
195
+ var _this$props3 = _this.props,
196
+ pluginInjectionApi = _this$props3.pluginInjectionApi,
197
+ editorView = _this$props3.editorView;
191
198
  var state = editorView.state,
192
199
  dispatch = editorView.dispatch;
193
- return (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.table) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = (_pluginInjectionApi$d6 = _pluginInjectionApi$d4.actions).insertTable) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.call(_pluginInjectionApi$d6, {
200
+ return (_pluginInjectionApi$d4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.table) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : (_pluginInjectionApi$d6 = (_pluginInjectionApi$d7 = _pluginInjectionApi$d5.actions).insertTable) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.call(_pluginInjectionApi$d7, {
194
201
  action: ACTION.INSERTED,
195
202
  actionSubject: ACTION_SUBJECT.DOCUMENT,
196
203
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,
@@ -198,7 +205,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
198
205
  inputMethod: inputMethod
199
206
  },
200
207
  eventType: EVENT_TYPE.TRACK
201
- })(state, dispatch)) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : false;
208
+ })(state, dispatch)) !== null && _pluginInjectionApi$d4 !== void 0 ? _pluginInjectionApi$d4 : false;
202
209
  });
203
210
  _defineProperty(_assertThisInitialized(_this), "createDate", function (inputMethod) {
204
211
  var editorView = _this.props.editorView;
@@ -221,9 +228,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
221
228
  return true;
222
229
  });
223
230
  _defineProperty(_assertThisInitialized(_this), "openMediaPicker", function (inputMethod) {
224
- var _this$props3 = _this.props,
225
- onShowMediaPicker = _this$props3.onShowMediaPicker,
226
- dispatchAnalyticsEvent = _this$props3.dispatchAnalyticsEvent;
231
+ var _this$props4 = _this.props,
232
+ onShowMediaPicker = _this$props4.onShowMediaPicker,
233
+ dispatchAnalyticsEvent = _this$props4.dispatchAnalyticsEvent;
227
234
  if (onShowMediaPicker) {
228
235
  onShowMediaPicker();
229
236
  if (dispatchAnalyticsEvent) {
@@ -250,11 +257,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
250
257
  };
251
258
  });
252
259
  _defineProperty(_assertThisInitialized(_this), "insertHorizontalRule", function (inputMethod) {
253
- var _this$props4 = _this.props,
254
- _this$props4$editorVi = _this$props4.editorView,
255
- state = _this$props4$editorVi.state,
256
- dispatch = _this$props4$editorVi.dispatch,
257
- featureFlags = _this$props4.featureFlags;
260
+ var _this$props5 = _this.props,
261
+ _this$props5$editorVi = _this$props5.editorView,
262
+ state = _this$props5$editorVi.state,
263
+ dispatch = _this$props5$editorVi.dispatch,
264
+ featureFlags = _this$props5.featureFlags;
258
265
  return insertHorizontalRule(inputMethod, featureFlags)(state, dispatch);
259
266
  });
260
267
  _defineProperty(_assertThisInitialized(_this), "insertExpand", function () {
@@ -265,9 +272,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
265
272
  });
266
273
  _defineProperty(_assertThisInitialized(_this), "insertBlockType", function (itemName) {
267
274
  return function () {
268
- var _this$props5 = _this.props,
269
- editorView = _this$props5.editorView,
270
- onInsertBlockType = _this$props5.onInsertBlockType;
275
+ var _this$props6 = _this.props,
276
+ editorView = _this$props6.editorView,
277
+ onInsertBlockType = _this$props6.onInsertBlockType;
271
278
  var state = editorView.state,
272
279
  dispatch = editorView.dispatch;
273
280
  onInsertBlockType(itemName)(state, dispatch);
@@ -286,11 +293,11 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
286
293
  _defineProperty(_assertThisInitialized(_this), "onItemActivated", function (_ref2) {
287
294
  var item = _ref2.item,
288
295
  inputMethod = _ref2.inputMethod;
289
- var _this$props6 = _this.props,
290
- editorView = _this$props6.editorView,
291
- editorActions = _this$props6.editorActions,
292
- handleImageUpload = _this$props6.handleImageUpload,
293
- expandEnabled = _this$props6.expandEnabled;
296
+ var _this$props7 = _this.props,
297
+ editorView = _this$props7.editorView,
298
+ editorActions = _this$props7.editorActions,
299
+ handleImageUpload = _this$props7.handleImageUpload,
300
+ expandEnabled = _this$props7.expandEnabled;
294
301
 
295
302
  // need to do this before inserting nodes so scrollIntoView works properly
296
303
  if (!editorView.hasFocus()) {
@@ -406,12 +413,12 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
406
413
  key: "renderPopup",
407
414
  value: function renderPopup() {
408
415
  var emojiPickerOpen = this.state.emojiPickerOpen;
409
- var _this$props7 = this.props,
410
- popupsMountPoint = _this$props7.popupsMountPoint,
411
- popupsBoundariesElement = _this$props7.popupsBoundariesElement,
412
- popupsScrollableElement = _this$props7.popupsScrollableElement,
413
- emojiProvider = _this$props7.emojiProvider,
414
- replacePlusMenuWithElementBrowser = _this$props7.replacePlusMenuWithElementBrowser;
416
+ var _this$props8 = this.props,
417
+ popupsMountPoint = _this$props8.popupsMountPoint,
418
+ popupsBoundariesElement = _this$props8.popupsBoundariesElement,
419
+ popupsScrollableElement = _this$props8.popupsScrollableElement,
420
+ emojiProvider = _this$props8.emojiProvider,
421
+ replacePlusMenuWithElementBrowser = _this$props8.replacePlusMenuWithElementBrowser;
415
422
  var dropdownEmoji = this.state.dropdownItems.some(function (_ref4) {
416
423
  var name = _ref4.value.name;
417
424
  return name === 'emoji';
@@ -447,9 +454,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
447
454
  buttons = _this$state.buttons,
448
455
  dropdownItems = _this$state.dropdownItems,
449
456
  emojiPickerOpen = _this$state.emojiPickerOpen;
450
- var _this$props8 = this.props,
451
- isDisabled = _this$props8.isDisabled,
452
- isReducedSpacing = _this$props8.isReducedSpacing;
457
+ var _this$props9 = this.props,
458
+ isDisabled = _this$props9.isDisabled,
459
+ isReducedSpacing = _this$props9.isReducedSpacing;
453
460
  if (buttons.length === 0 && dropdownItems.length === 0) {
454
461
  return null;
455
462
  }
@@ -509,6 +516,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
509
516
  imageUploadSupported: props.imageUploadSupported,
510
517
  imageUploadEnabled: props.imageUploadEnabled,
511
518
  mentionsSupported: props.mentionsSupported,
519
+ mentionsDisabled: props.mentionsDisabled,
512
520
  actionSupported: props.actionSupported,
513
521
  decisionSupported: props.decisionSupported,
514
522
  linkSupported: props.linkSupported,
@@ -13,6 +13,12 @@ import { createTypeAheadConfig } from './type-ahead';
13
13
  import { mentionPluginKey } from './pm-plugins/key';
14
14
  import { createMentionPlugin } from './pm-plugins/main';
15
15
  export { mentionPluginKey };
16
+ var getSharedState = function getSharedState(editorState) {
17
+ if (!editorState) {
18
+ return undefined;
19
+ }
20
+ return mentionPluginKey.getState(editorState);
21
+ };
16
22
  var mentionsPlugin = function mentionsPlugin(options, api) {
17
23
  var sessionId = uuid();
18
24
  var fireEvent = function fireEvent(payload) {
@@ -67,6 +73,7 @@ var mentionsPlugin = function mentionsPlugin(options, api) {
67
73
  }
68
74
  });
69
75
  },
76
+ getSharedState: getSharedState,
70
77
  pluginsOptions: {
71
78
  quickInsert: function quickInsert(_ref4) {
72
79
  var formatMessage = _ref4.formatMessage;
@@ -83,6 +90,10 @@ var mentionsPlugin = function mentionsPlugin(options, api) {
83
90
  action: function action(insert, state) {
84
91
  var _api$dependencies$ana3;
85
92
  var tr = insert(undefined);
93
+ var pluginState = getSharedState(state);
94
+ if (pluginState && pluginState.canInsertMention === false) {
95
+ return false;
96
+ }
86
97
  openTypeAheadAtCursor({
87
98
  triggerHandler: typeAhead,
88
99
  inputMethod: INPUT_METHOD.QUICK_INSERT
@@ -6,6 +6,7 @@ import { SLI_EVENT_TYPE, SMART_EVENT_TYPE, buildSliPayload } from '@atlaskit/men
6
6
  import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
7
7
  import { MentionNodeView } from '../nodeviews/mention';
8
8
  import { mentionPluginKey } from './key';
9
+ import { canMentionBeCreatedInRange } from './utils';
9
10
  var ACTIONS = {
10
11
  SET_PROVIDER: 'SET_PROVIDER',
11
12
  SET_CONTEXT: 'SET_CONTEXT'
@@ -46,30 +47,44 @@ export function createMentionPlugin(pmPluginFactoryParams, fireEvent, options) {
46
47
  return new SafePlugin({
47
48
  key: mentionPluginKey,
48
49
  state: {
49
- init: function init() {
50
- return {};
50
+ init: function init(_, state) {
51
+ var canInsertMention = canMentionBeCreatedInRange(state.selection.from, state.selection.to)(state);
52
+ return {
53
+ canInsertMention: canInsertMention
54
+ };
51
55
  },
52
- apply: function apply(tr, pluginState) {
56
+ apply: function apply(tr, pluginState, oldState, newState) {
53
57
  var _ref = tr.getMeta(mentionPluginKey) || {
54
58
  action: null,
55
59
  params: null
56
60
  },
57
61
  action = _ref.action,
58
62
  params = _ref.params;
63
+ var hasNewPluginState = false;
59
64
  var newPluginState = pluginState;
65
+ var hasPositionChanged = oldState.selection.from !== newState.selection.from || oldState.selection.to !== newState.selection.to;
66
+ if (tr.docChanged || tr.selectionSet && hasPositionChanged) {
67
+ newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
68
+ canInsertMention: canMentionBeCreatedInRange(newState.selection.from, newState.selection.to)(newState)
69
+ });
70
+ hasNewPluginState = true;
71
+ }
60
72
  switch (action) {
61
73
  case ACTIONS.SET_PROVIDER:
62
- newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
74
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
63
75
  mentionProvider: params.provider
64
76
  });
65
- pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
66
- return newPluginState;
77
+ hasNewPluginState = true;
78
+ break;
67
79
  case ACTIONS.SET_CONTEXT:
68
- newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
80
+ newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
69
81
  contextIdentifierProvider: params.context
70
82
  });
71
- pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
72
- return newPluginState;
83
+ hasNewPluginState = true;
84
+ break;
85
+ }
86
+ if (hasNewPluginState) {
87
+ pmPluginFactoryParams.dispatch(mentionPluginKey, newPluginState);
73
88
  }
74
89
  return newPluginState;
75
90
  }
@@ -1,4 +1,16 @@
1
1
  import { mentionPluginKey } from './key';
2
+ import { canInsert } from 'prosemirror-utils';
2
3
  export function getMentionPluginState(state) {
3
4
  return mentionPluginKey.getState(state);
4
- }
5
+ }
6
+ export var canMentionBeCreatedInRange = function canMentionBeCreatedInRange(from, to) {
7
+ return function (state) {
8
+ var $from = state.doc.resolve(from);
9
+ var $to = state.doc.resolve(to);
10
+ var mention = state.schema.nodes.mention.createChecked();
11
+ if ($from.parent === $to.parent && canInsert($from, mention)) {
12
+ return true;
13
+ }
14
+ return false;
15
+ };
16
+ };
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.6.0";
2
+ export var version = "187.6.1";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.6.0",
3
+ "version": "187.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,11 @@
1
- import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { ImageUploadPlugin } from '../image-upload';
3
3
  import type datePlugin from '../date';
4
- import { tablesPlugin } from '@atlaskit/editor-plugin-table';
4
+ import type { tablesPlugin } from '@atlaskit/editor-plugin-table';
5
5
  import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
7
7
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
+ import type mentionsPlugin from '../mentions';
8
9
  export interface InsertBlockOptions {
9
10
  allowTables?: boolean;
10
11
  allowExpand?: boolean;
@@ -22,7 +23,8 @@ declare const insertBlockPlugin: NextEditorPlugin<'insertBlock', {
22
23
  OptionalPlugin<typeof hyperlinkPlugin>,
23
24
  OptionalPlugin<typeof datePlugin>,
24
25
  OptionalPlugin<typeof analyticsPlugin>,
25
- OptionalPlugin<ImageUploadPlugin>
26
+ OptionalPlugin<ImageUploadPlugin>,
27
+ OptionalPlugin<typeof mentionsPlugin>
26
28
  ];
27
29
  }>;
28
30
  export default insertBlockPlugin;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { WrappedComponentProps } from 'react-intl-next';
3
- import { Schema } from 'prosemirror-model';
4
- import { EmojiProvider } from '@atlaskit/emoji/resource';
5
- import { BlockType } from '../../../block-type/types';
6
- import { MenuItem } from '../../../../ui/DropdownMenu/types';
7
- import { MacroProvider } from '../../../macro';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { Schema } from 'prosemirror-model';
4
+ import type { EmojiProvider } from '@atlaskit/emoji/resource';
5
+ import type { BlockType } from '../../../block-type/types';
6
+ import type { MenuItem } from '../../../../ui/DropdownMenu/types';
7
+ import type { MacroProvider } from '../../../macro';
8
8
  export interface CreateItemsConfig {
9
9
  isTypeAheadAllowed?: boolean;
10
10
  tableSupported?: boolean;
@@ -13,6 +13,7 @@ export interface CreateItemsConfig {
13
13
  imageUploadSupported?: boolean;
14
14
  imageUploadEnabled?: boolean;
15
15
  mentionsSupported?: boolean;
16
+ mentionsDisabled?: boolean;
16
17
  availableWrapperBlockTypes?: BlockType[];
17
18
  actionSupported?: boolean;
18
19
  decisionSupported?: boolean;
@@ -1,12 +1,12 @@
1
- import { INPUT_METHOD, DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
- import { EditorView } from 'prosemirror-view';
3
- import { EditorActionsOptions as EditorActions, FeatureFlags, ExtractInjectionAPI, ImageUploadPluginReferenceEvent, Command } from '@atlaskit/editor-common/types';
4
- import { EmojiProvider } from '@atlaskit/emoji';
5
- import { BlockType } from '../../../block-type/types';
6
- import { MacroProvider } from '@atlaskit/editor-common/provider-factory';
7
- import { MenuItem } from '../../../../ui/DropdownMenu/types';
8
- import { Node as PMNode } from 'prosemirror-model';
9
- import { BlockMenuItem } from './create-items';
1
+ import type { INPUT_METHOD, DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorView } from 'prosemirror-view';
3
+ import type { EditorActionsOptions as EditorActions, FeatureFlags, ExtractInjectionAPI, ImageUploadPluginReferenceEvent, Command } from '@atlaskit/editor-common/types';
4
+ import type { EmojiProvider } from '@atlaskit/emoji';
5
+ import type { BlockType } from '../../../block-type/types';
6
+ import type { MacroProvider } from '@atlaskit/editor-common/provider-factory';
7
+ import type { MenuItem } from '../../../../ui/DropdownMenu/types';
8
+ import type { Node as PMNode } from 'prosemirror-model';
9
+ import type { BlockMenuItem } from './create-items';
10
10
  import type insertBlockPlugin from '../../index';
11
11
  export interface Props {
12
12
  buttons: number;
@@ -49,6 +49,7 @@ export interface Props {
49
49
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
50
50
  featureFlags: FeatureFlags;
51
51
  pluginInjectionApi?: ExtractInjectionAPI<typeof insertBlockPlugin>;
52
+ mentionsDisabled?: boolean;
52
53
  }
53
54
  export interface State {
54
55
  isPlusMenuOpen: boolean;
@@ -1,10 +1,11 @@
1
- import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import { MentionPluginOptions } from './types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { MentionPluginOptions, MentionPluginState } from './types';
3
3
  import { mentionPluginKey } from './pm-plugins/key';
4
4
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  export { mentionPluginKey };
6
6
  declare const mentionsPlugin: NextEditorPlugin<'mention', {
7
7
  pluginConfiguration: MentionPluginOptions | undefined;
8
8
  dependencies: [OptionalPlugin<typeof analyticsPlugin>];
9
+ sharedState: MentionPluginState | undefined;
9
10
  }>;
10
11
  export default mentionsPlugin;
@@ -1,3 +1,4 @@
1
- import { EditorState } from 'prosemirror-state';
2
- import { MentionPluginState } from '../types';
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { MentionPluginState } from '../types';
3
3
  export declare function getMentionPluginState(state: EditorState): MentionPluginState;
4
+ export declare const canMentionBeCreatedInRange: (from: number, to: number) => (state: EditorState) => boolean;
@@ -19,5 +19,6 @@ export type MentionPluginState = {
19
19
  mentionProvider?: MentionProvider;
20
20
  contextIdentifierProvider?: ContextIdentifierProvider;
21
21
  mentions?: Array<MentionDescription>;
22
+ canInsertMention?: boolean;
22
23
  };
23
24
  export type FireElementsChannelEvent = <T extends AnalyticsEventPayload>(payload: T) => void;
@@ -1,10 +1,11 @@
1
- import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { ImageUploadPlugin } from '../image-upload';
3
3
  import type datePlugin from '../date';
4
- import { tablesPlugin } from '@atlaskit/editor-plugin-table';
4
+ import type { tablesPlugin } from '@atlaskit/editor-plugin-table';
5
5
  import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
6
6
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
7
7
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
8
+ import type mentionsPlugin from '../mentions';
8
9
  export interface InsertBlockOptions {
9
10
  allowTables?: boolean;
10
11
  allowExpand?: boolean;
@@ -22,7 +23,8 @@ declare const insertBlockPlugin: NextEditorPlugin<'insertBlock', {
22
23
  OptionalPlugin<typeof hyperlinkPlugin>,
23
24
  OptionalPlugin<typeof datePlugin>,
24
25
  OptionalPlugin<typeof analyticsPlugin>,
25
- OptionalPlugin<ImageUploadPlugin>
26
+ OptionalPlugin<ImageUploadPlugin>,
27
+ OptionalPlugin<typeof mentionsPlugin>
26
28
  ];
27
29
  }>;
28
30
  export default insertBlockPlugin;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { WrappedComponentProps } from 'react-intl-next';
3
- import { Schema } from 'prosemirror-model';
4
- import { EmojiProvider } from '@atlaskit/emoji/resource';
5
- import { BlockType } from '../../../block-type/types';
6
- import { MenuItem } from '../../../../ui/DropdownMenu/types';
7
- import { MacroProvider } from '../../../macro';
2
+ import type { WrappedComponentProps } from 'react-intl-next';
3
+ import type { Schema } from 'prosemirror-model';
4
+ import type { EmojiProvider } from '@atlaskit/emoji/resource';
5
+ import type { BlockType } from '../../../block-type/types';
6
+ import type { MenuItem } from '../../../../ui/DropdownMenu/types';
7
+ import type { MacroProvider } from '../../../macro';
8
8
  export interface CreateItemsConfig {
9
9
  isTypeAheadAllowed?: boolean;
10
10
  tableSupported?: boolean;
@@ -13,6 +13,7 @@ export interface CreateItemsConfig {
13
13
  imageUploadSupported?: boolean;
14
14
  imageUploadEnabled?: boolean;
15
15
  mentionsSupported?: boolean;
16
+ mentionsDisabled?: boolean;
16
17
  availableWrapperBlockTypes?: BlockType[];
17
18
  actionSupported?: boolean;
18
19
  decisionSupported?: boolean;
@@ -1,12 +1,12 @@
1
- import { INPUT_METHOD, DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
- import { EditorView } from 'prosemirror-view';
3
- import { EditorActionsOptions as EditorActions, FeatureFlags, ExtractInjectionAPI, ImageUploadPluginReferenceEvent, Command } from '@atlaskit/editor-common/types';
4
- import { EmojiProvider } from '@atlaskit/emoji';
5
- import { BlockType } from '../../../block-type/types';
6
- import { MacroProvider } from '@atlaskit/editor-common/provider-factory';
7
- import { MenuItem } from '../../../../ui/DropdownMenu/types';
8
- import { Node as PMNode } from 'prosemirror-model';
9
- import { BlockMenuItem } from './create-items';
1
+ import type { INPUT_METHOD, DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
2
+ import type { EditorView } from 'prosemirror-view';
3
+ import type { EditorActionsOptions as EditorActions, FeatureFlags, ExtractInjectionAPI, ImageUploadPluginReferenceEvent, Command } from '@atlaskit/editor-common/types';
4
+ import type { EmojiProvider } from '@atlaskit/emoji';
5
+ import type { BlockType } from '../../../block-type/types';
6
+ import type { MacroProvider } from '@atlaskit/editor-common/provider-factory';
7
+ import type { MenuItem } from '../../../../ui/DropdownMenu/types';
8
+ import type { Node as PMNode } from 'prosemirror-model';
9
+ import type { BlockMenuItem } from './create-items';
10
10
  import type insertBlockPlugin from '../../index';
11
11
  export interface Props {
12
12
  buttons: number;
@@ -49,6 +49,7 @@ export interface Props {
49
49
  dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
50
50
  featureFlags: FeatureFlags;
51
51
  pluginInjectionApi?: ExtractInjectionAPI<typeof insertBlockPlugin>;
52
+ mentionsDisabled?: boolean;
52
53
  }
53
54
  export interface State {
54
55
  isPlusMenuOpen: boolean;
@@ -1,5 +1,5 @@
1
- import { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
- import { MentionPluginOptions } from './types';
1
+ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { MentionPluginOptions, MentionPluginState } from './types';
3
3
  import { mentionPluginKey } from './pm-plugins/key';
4
4
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
5
5
  export { mentionPluginKey };
@@ -8,5 +8,6 @@ declare const mentionsPlugin: NextEditorPlugin<'mention', {
8
8
  dependencies: [
9
9
  OptionalPlugin<typeof analyticsPlugin>
10
10
  ];
11
+ sharedState: MentionPluginState | undefined;
11
12
  }>;
12
13
  export default mentionsPlugin;
@@ -1,3 +1,4 @@
1
- import { EditorState } from 'prosemirror-state';
2
- import { MentionPluginState } from '../types';
1
+ import type { EditorState } from 'prosemirror-state';
2
+ import type { MentionPluginState } from '../types';
3
3
  export declare function getMentionPluginState(state: EditorState): MentionPluginState;
4
+ export declare const canMentionBeCreatedInRange: (from: number, to: number) => (state: EditorState) => boolean;
@@ -19,5 +19,6 @@ export type MentionPluginState = {
19
19
  mentionProvider?: MentionProvider;
20
20
  contextIdentifierProvider?: ContextIdentifierProvider;
21
21
  mentions?: Array<MentionDescription>;
22
+ canInsertMention?: boolean;
22
23
  };
23
24
  export type FireElementsChannelEvent = <T extends AnalyticsEventPayload>(payload: T) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.6.0",
3
+ "version": "187.6.1",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/report.api.md CHANGED
@@ -1635,6 +1635,7 @@ export type MentionPluginState = {
1635
1635
  mentionProvider?: MentionProvider_2;
1636
1636
  contextIdentifierProvider?: ContextIdentifierProvider;
1637
1637
  mentions?: Array<MentionDescription>;
1638
+ canInsertMention?: boolean;
1638
1639
  };
1639
1640
 
1640
1641
  export { MentionProvider };
@@ -1467,6 +1467,7 @@ export type MentionPluginState = {
1467
1467
  mentionProvider?: MentionProvider_2;
1468
1468
  contextIdentifierProvider?: ContextIdentifierProvider;
1469
1469
  mentions?: Array<MentionDescription>;
1470
+ canInsertMention?: boolean;
1470
1471
  };
1471
1472
 
1472
1473
  export { MentionProvider }