@atlaskit/editor-plugin-insert-block 3.2.8 → 3.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-insert-block
2
2
 
3
+ ## 3.2.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.2.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [#160575](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/160575)
14
+ [`c340cf0e2d6c2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c340cf0e2d6c2) -
15
+ Expose emoji provider promise to initialise in the toolbar earlier.
16
+ - Updated dependencies
17
+
3
18
  ## 3.2.8
4
19
 
5
20
  ### Patch Changes
@@ -15,6 +15,7 @@ var _types = require("@atlaskit/editor-common/types");
15
15
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
16
16
  var _consts = require("@atlaskit/editor-plugin-block-type/consts");
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
18
19
  var _toggleInsertBlock = require("./pm-plugins/toggleInsertBlock");
19
20
  var _ToolbarInsertBlock = _interopRequireDefault(require("./ui/ToolbarInsertBlock"));
20
21
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -137,6 +138,24 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
137
138
  appearance: options.appearance
138
139
  });
139
140
  };
141
+ if ((0, _experiments.editorExperiment)('platform_editor_prevent_toolbar_layout_shifts', true)) {
142
+ return /*#__PURE__*/_react.default.createElement(ToolbarInsertBlockWithInjectionApi, {
143
+ pluginInjectionApi: api,
144
+ editorView: editorView,
145
+ editorActions: editorActions,
146
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
147
+ providerFactory: providerFactory,
148
+ popupsMountPoint: popupsMountPoint,
149
+ popupsBoundariesElement: popupsBoundariesElement,
150
+ popupsScrollableElement: popupsScrollableElement,
151
+ toolbarSize: toolbarSize,
152
+ disabled: disabled,
153
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
154
+ isLastItem: isLastItem,
155
+ options: options,
156
+ appearance: options.appearance
157
+ });
158
+ }
140
159
  return /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
141
160
  providerFactory: providerFactory,
142
161
  providers: ['emojiProvider'],
@@ -198,7 +217,9 @@ var insertBlockPlugin = exports.insertBlockPlugin = function insertBlockPlugin(_
198
217
  return plugin;
199
218
  };
200
219
  var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (api) {
201
- var emojiProviderSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'emoji.emojiProvider');
220
+ var emojiProviderSelector = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'emoji.emojiProvider', {
221
+ disabled: (0, _experiments.editorExperiment)('platform_editor_prevent_toolbar_layout_shifts', true)
222
+ });
202
223
  var showMediaPicker = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'media.showMediaPicker');
203
224
  var mediaAllowsUploads = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'media.allowsUploads');
204
225
  var showElementBrowser = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'insertBlock.showElementBrowser');
@@ -290,12 +311,17 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
290
311
  availableWrapperBlockTypes = _useSharedState.availableWrapperBlockTypes,
291
312
  canInsertLink = _useSharedState.canInsertLink,
292
313
  activeLinkMark = _useSharedState.activeLinkMark;
314
+ var emojiProviderPromise = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'emoji.emojiProviderPromise', {
315
+ disabled: !(0, _experiments.editorExperiment)('platform_editor_prevent_toolbar_layout_shifts', true)
316
+ });
293
317
  var getEmojiProvider = function getEmojiProvider() {
294
318
  if (emojiProviderSelector) {
295
319
  return Promise.resolve(emojiProviderSelector);
296
320
  }
297
321
  };
298
- var emojiProvider = getEmojiProvider();
322
+ var emojiProvider = (0, _experiments.editorExperiment)('platform_editor_prevent_toolbar_layout_shifts', true, {
323
+ exposure: true
324
+ }) ? emojiProviderPromise : getEmojiProvider();
299
325
  var onShowMediaPicker = function onShowMediaPicker(mountInfo) {
300
326
  if (!showMediaPicker) {
301
327
  return;
@@ -13,6 +13,7 @@ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
13
13
  var _keymaps = require("@atlaskit/editor-common/keymaps");
14
14
  var _messages = require("@atlaskit/editor-common/messages");
15
15
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
17
  var _item = require("./item");
17
18
  var _shallowEquals = require("./shallow-equals");
18
19
  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; }
@@ -53,6 +54,9 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
53
54
  linkDisabled = config.linkDisabled,
54
55
  emojiDisabled = config.emojiDisabled,
55
56
  emojiProvider = config.emojiProvider,
57
+ hasEmojiPlugin = config.hasEmojiPlugin,
58
+ hasMentionsPlugin = config.hasMentionsPlugin,
59
+ hasMediaPlugin = config.hasMediaPlugin,
56
60
  nativeStatusSupported = config.nativeStatusSupported,
57
61
  insertMenuItems = config.insertMenuItems,
58
62
  dateEnabled = config.dateEnabled,
@@ -81,34 +85,65 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
81
85
  'aria-haspopup': 'dialog'
82
86
  }));
83
87
  }
84
- if (mediaSupported && mediaUploadsEnabled) {
85
- items.push((0, _item.media)({
86
- content: formatMessage(_messages.toolbarInsertBlockMessages.addMediaFiles),
87
- tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mediaFilesDescription),
88
- disabled: isOffline
89
- }));
90
- }
91
- if (imageUploadSupported) {
92
- items.push((0, _item.imageUpload)({
93
- content: formatMessage(_messages.toolbarInsertBlockMessages.image),
94
- disabled: !imageUploadEnabled || isOffline
95
- }));
96
- }
97
- if (mentionsSupported) {
98
- items.push((0, _item.mention)({
99
- content: formatMessage(_messages.toolbarInsertBlockMessages.mention),
100
- tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
101
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
102
- 'aria-haspopup': 'listbox'
103
- }));
104
- }
105
- if (emojiProvider) {
106
- items.push((0, _item.emoji)({
107
- content: formatMessage(_messages.toolbarInsertBlockMessages.emoji),
108
- tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.emojiDescription),
109
- disabled: emojiDisabled || !isTypeAheadAllowed,
110
- 'aria-haspopup': 'dialog'
111
- }));
88
+ if ((0, _experiments.editorExperiment)('platform_editor_prevent_toolbar_layout_shifts', true)) {
89
+ if (imageUploadSupported) {
90
+ items.push((0, _item.imageUpload)({
91
+ content: formatMessage(_messages.toolbarInsertBlockMessages.image),
92
+ disabled: !imageUploadEnabled || isOffline
93
+ }));
94
+ } else if (hasMediaPlugin) {
95
+ items.push((0, _item.media)({
96
+ content: formatMessage(_messages.toolbarInsertBlockMessages.addMediaFiles),
97
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mediaFilesDescription),
98
+ disabled: isOffline || !mediaSupported || !mediaUploadsEnabled
99
+ }));
100
+ }
101
+ if (hasMentionsPlugin) {
102
+ items.push((0, _item.mention)({
103
+ content: formatMessage(_messages.toolbarInsertBlockMessages.mention),
104
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
105
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || !mentionsSupported,
106
+ 'aria-haspopup': 'listbox'
107
+ }));
108
+ }
109
+ if (hasEmojiPlugin) {
110
+ items.push((0, _item.emoji)({
111
+ content: formatMessage(_messages.toolbarInsertBlockMessages.emoji),
112
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.emojiDescription),
113
+ disabled: emojiDisabled || !isTypeAheadAllowed || !emojiProvider,
114
+ 'aria-haspopup': 'dialog'
115
+ }));
116
+ }
117
+ } else {
118
+ if (mediaSupported && mediaUploadsEnabled) {
119
+ items.push((0, _item.media)({
120
+ content: formatMessage(_messages.toolbarInsertBlockMessages.addMediaFiles),
121
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mediaFilesDescription),
122
+ disabled: isOffline
123
+ }));
124
+ }
125
+ if (imageUploadSupported) {
126
+ items.push((0, _item.imageUpload)({
127
+ content: formatMessage(_messages.toolbarInsertBlockMessages.image),
128
+ disabled: !imageUploadEnabled || isOffline
129
+ }));
130
+ }
131
+ if (mentionsSupported) {
132
+ items.push((0, _item.mention)({
133
+ content: formatMessage(_messages.toolbarInsertBlockMessages.mention),
134
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.mentionDescription),
135
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled,
136
+ 'aria-haspopup': 'listbox'
137
+ }));
138
+ }
139
+ if (emojiProvider) {
140
+ items.push((0, _item.emoji)({
141
+ content: formatMessage(_messages.toolbarInsertBlockMessages.emoji),
142
+ tooltipDescription: formatMessage(_messages.toolbarInsertBlockMessages.emojiDescription),
143
+ disabled: emojiDisabled || !isTypeAheadAllowed,
144
+ 'aria-haspopup': 'dialog'
145
+ }));
146
+ }
112
147
  }
113
148
  if (tableSupported) {
114
149
  items.push((0, _item.table)({
@@ -814,6 +814,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
814
814
  }], [{
815
815
  key: "getDerivedStateFromProps",
816
816
  value: function getDerivedStateFromProps(props, state) {
817
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3;
817
818
  var _createItems = (0, _createItems3.createItems)({
818
819
  isTypeAheadAllowed: props.isTypeAheadAllowed,
819
820
  tableSupported: props.tableSupported,
@@ -830,6 +831,9 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
830
831
  linkSupported: props.linkSupported,
831
832
  linkDisabled: props.linkDisabled,
832
833
  emojiDisabled: props.emojiDisabled,
834
+ hasEmojiPlugin: !!((_props$pluginInjectio = props.pluginInjectionApi) !== null && _props$pluginInjectio !== void 0 && _props$pluginInjectio.emoji),
835
+ hasMentionsPlugin: !!((_props$pluginInjectio2 = props.pluginInjectionApi) !== null && _props$pluginInjectio2 !== void 0 && _props$pluginInjectio2.mention),
836
+ hasMediaPlugin: !!((_props$pluginInjectio3 = props.pluginInjectionApi) !== null && _props$pluginInjectio3 !== void 0 && _props$pluginInjectio3.media),
833
837
  nativeStatusSupported: props.nativeStatusSupported,
834
838
  dateEnabled: props.dateEnabled,
835
839
  placeholderTextEnabled: props.placeholderTextEnabled,
@@ -7,6 +7,7 @@ import { ToolbarSize } from '@atlaskit/editor-common/types';
7
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
8
  import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
11
12
  // Ignored via go/ees005
12
13
  // eslint-disable-next-line import/no-named-as-default
@@ -121,6 +122,24 @@ export const insertBlockPlugin = ({
121
122
  appearance: options.appearance
122
123
  });
123
124
  };
125
+ if (editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)) {
126
+ return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
127
+ pluginInjectionApi: api,
128
+ editorView: editorView,
129
+ editorActions: editorActions,
130
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
131
+ providerFactory: providerFactory,
132
+ popupsMountPoint: popupsMountPoint,
133
+ popupsBoundariesElement: popupsBoundariesElement,
134
+ popupsScrollableElement: popupsScrollableElement,
135
+ toolbarSize: toolbarSize,
136
+ disabled: disabled,
137
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
138
+ isLastItem: isLastItem,
139
+ options: options,
140
+ appearance: options.appearance
141
+ });
142
+ }
124
143
  return /*#__PURE__*/React.createElement(WithProviders, {
125
144
  providerFactory: providerFactory,
126
145
  providers: ['emojiProvider'],
@@ -181,7 +200,9 @@ export const insertBlockPlugin = ({
181
200
  return plugin;
182
201
  };
183
202
  const useSharedState = sharedPluginStateHookMigratorFactory(api => {
184
- const emojiProviderSelector = useSharedPluginStateSelector(api, 'emoji.emojiProvider');
203
+ const emojiProviderSelector = useSharedPluginStateSelector(api, 'emoji.emojiProvider', {
204
+ disabled: editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)
205
+ });
185
206
  const showMediaPicker = useSharedPluginStateSelector(api, 'media.showMediaPicker');
186
207
  const mediaAllowsUploads = useSharedPluginStateSelector(api, 'media.allowsUploads');
187
208
  const showElementBrowser = useSharedPluginStateSelector(api, 'insertBlock.showElementBrowser');
@@ -276,12 +297,17 @@ function ToolbarInsertBlockWithInjectionApi({
276
297
  canInsertLink,
277
298
  activeLinkMark
278
299
  } = useSharedState(pluginInjectionApi);
300
+ const emojiProviderPromise = useSharedPluginStateSelector(pluginInjectionApi, 'emoji.emojiProviderPromise', {
301
+ disabled: !editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)
302
+ });
279
303
  const getEmojiProvider = () => {
280
304
  if (emojiProviderSelector) {
281
305
  return Promise.resolve(emojiProviderSelector);
282
306
  }
283
307
  };
284
- const emojiProvider = getEmojiProvider();
308
+ const emojiProvider = editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true, {
309
+ exposure: true
310
+ }) ? emojiProviderPromise : getEmojiProvider();
285
311
  const onShowMediaPicker = mountInfo => {
286
312
  if (!showMediaPicker) {
287
313
  return;
@@ -4,6 +4,7 @@ import memoizeOne from 'memoize-one';
4
4
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
5
  import { blockTypeMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
7
8
  import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
8
9
  import { shallowEquals } from './shallow-equals';
9
10
  const buttonToItem = memoize(button => ({
@@ -39,6 +40,9 @@ const createInsertBlockItems = config => {
39
40
  linkDisabled,
40
41
  emojiDisabled,
41
42
  emojiProvider,
43
+ hasEmojiPlugin,
44
+ hasMentionsPlugin,
45
+ hasMediaPlugin,
42
46
  nativeStatusSupported,
43
47
  insertMenuItems,
44
48
  dateEnabled,
@@ -68,34 +72,65 @@ const createInsertBlockItems = config => {
68
72
  'aria-haspopup': 'dialog'
69
73
  }));
70
74
  }
71
- if (mediaSupported && mediaUploadsEnabled) {
72
- items.push(media({
73
- content: formatMessage(messages.addMediaFiles),
74
- tooltipDescription: formatMessage(messages.mediaFilesDescription),
75
- disabled: isOffline
76
- }));
77
- }
78
- if (imageUploadSupported) {
79
- items.push(imageUpload({
80
- content: formatMessage(messages.image),
81
- disabled: !imageUploadEnabled || isOffline
82
- }));
83
- }
84
- if (mentionsSupported) {
85
- items.push(mention({
86
- content: formatMessage(messages.mention),
87
- tooltipDescription: formatMessage(messages.mentionDescription),
88
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
89
- 'aria-haspopup': 'listbox'
90
- }));
91
- }
92
- if (emojiProvider) {
93
- items.push(emoji({
94
- content: formatMessage(messages.emoji),
95
- tooltipDescription: formatMessage(messages.emojiDescription),
96
- disabled: emojiDisabled || !isTypeAheadAllowed,
97
- 'aria-haspopup': 'dialog'
98
- }));
75
+ if (editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)) {
76
+ if (imageUploadSupported) {
77
+ items.push(imageUpload({
78
+ content: formatMessage(messages.image),
79
+ disabled: !imageUploadEnabled || isOffline
80
+ }));
81
+ } else if (hasMediaPlugin) {
82
+ items.push(media({
83
+ content: formatMessage(messages.addMediaFiles),
84
+ tooltipDescription: formatMessage(messages.mediaFilesDescription),
85
+ disabled: isOffline || !mediaSupported || !mediaUploadsEnabled
86
+ }));
87
+ }
88
+ if (hasMentionsPlugin) {
89
+ items.push(mention({
90
+ content: formatMessage(messages.mention),
91
+ tooltipDescription: formatMessage(messages.mentionDescription),
92
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || !mentionsSupported,
93
+ 'aria-haspopup': 'listbox'
94
+ }));
95
+ }
96
+ if (hasEmojiPlugin) {
97
+ items.push(emoji({
98
+ content: formatMessage(messages.emoji),
99
+ tooltipDescription: formatMessage(messages.emojiDescription),
100
+ disabled: emojiDisabled || !isTypeAheadAllowed || !emojiProvider,
101
+ 'aria-haspopup': 'dialog'
102
+ }));
103
+ }
104
+ } else {
105
+ if (mediaSupported && mediaUploadsEnabled) {
106
+ items.push(media({
107
+ content: formatMessage(messages.addMediaFiles),
108
+ tooltipDescription: formatMessage(messages.mediaFilesDescription),
109
+ disabled: isOffline
110
+ }));
111
+ }
112
+ if (imageUploadSupported) {
113
+ items.push(imageUpload({
114
+ content: formatMessage(messages.image),
115
+ disabled: !imageUploadEnabled || isOffline
116
+ }));
117
+ }
118
+ if (mentionsSupported) {
119
+ items.push(mention({
120
+ content: formatMessage(messages.mention),
121
+ tooltipDescription: formatMessage(messages.mentionDescription),
122
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled,
123
+ 'aria-haspopup': 'listbox'
124
+ }));
125
+ }
126
+ if (emojiProvider) {
127
+ items.push(emoji({
128
+ content: formatMessage(messages.emoji),
129
+ tooltipDescription: formatMessage(messages.emojiDescription),
130
+ disabled: emojiDisabled || !isTypeAheadAllowed,
131
+ 'aria-haspopup': 'dialog'
132
+ }));
133
+ }
99
134
  }
100
135
  if (tableSupported) {
101
136
  items.push(table({
@@ -565,6 +565,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
565
565
  }));
566
566
  }
567
567
  static getDerivedStateFromProps(props, state) {
568
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3;
568
569
  const [buttons, dropdownItems] = createItems({
569
570
  isTypeAheadAllowed: props.isTypeAheadAllowed,
570
571
  tableSupported: props.tableSupported,
@@ -581,6 +582,9 @@ export class ToolbarInsertBlock extends React.PureComponent {
581
582
  linkSupported: props.linkSupported,
582
583
  linkDisabled: props.linkDisabled,
583
584
  emojiDisabled: props.emojiDisabled,
585
+ hasEmojiPlugin: !!((_props$pluginInjectio = props.pluginInjectionApi) !== null && _props$pluginInjectio !== void 0 && _props$pluginInjectio.emoji),
586
+ hasMentionsPlugin: !!((_props$pluginInjectio2 = props.pluginInjectionApi) !== null && _props$pluginInjectio2 !== void 0 && _props$pluginInjectio2.mention),
587
+ hasMediaPlugin: !!((_props$pluginInjectio3 = props.pluginInjectionApi) !== null && _props$pluginInjectio3 !== void 0 && _props$pluginInjectio3.media),
584
588
  nativeStatusSupported: props.nativeStatusSupported,
585
589
  dateEnabled: props.dateEnabled,
586
590
  placeholderTextEnabled: props.placeholderTextEnabled,
@@ -7,6 +7,7 @@ import { ToolbarSize } from '@atlaskit/editor-common/types';
7
7
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
8
8
  import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
9
9
  import { fg } from '@atlaskit/platform-feature-flags';
10
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
10
11
  import { toggleInsertBlockPmKey, toggleInsertBlockPmPlugin } from './pm-plugins/toggleInsertBlock';
11
12
  // Ignored via go/ees005
12
13
  // eslint-disable-next-line import/no-named-as-default
@@ -126,6 +127,24 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
126
127
  appearance: options.appearance
127
128
  });
128
129
  };
130
+ if (editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)) {
131
+ return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
132
+ pluginInjectionApi: api,
133
+ editorView: editorView,
134
+ editorActions: editorActions,
135
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
136
+ providerFactory: providerFactory,
137
+ popupsMountPoint: popupsMountPoint,
138
+ popupsBoundariesElement: popupsBoundariesElement,
139
+ popupsScrollableElement: popupsScrollableElement,
140
+ toolbarSize: toolbarSize,
141
+ disabled: disabled,
142
+ isToolbarReducedSpacing: isToolbarReducedSpacing,
143
+ isLastItem: isLastItem,
144
+ options: options,
145
+ appearance: options.appearance
146
+ });
147
+ }
129
148
  return /*#__PURE__*/React.createElement(WithProviders, {
130
149
  providerFactory: providerFactory,
131
150
  providers: ['emojiProvider'],
@@ -187,7 +206,9 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
187
206
  return plugin;
188
207
  };
189
208
  var useSharedState = sharedPluginStateHookMigratorFactory(function (api) {
190
- var emojiProviderSelector = useSharedPluginStateSelector(api, 'emoji.emojiProvider');
209
+ var emojiProviderSelector = useSharedPluginStateSelector(api, 'emoji.emojiProvider', {
210
+ disabled: editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)
211
+ });
191
212
  var showMediaPicker = useSharedPluginStateSelector(api, 'media.showMediaPicker');
192
213
  var mediaAllowsUploads = useSharedPluginStateSelector(api, 'media.allowsUploads');
193
214
  var showElementBrowser = useSharedPluginStateSelector(api, 'insertBlock.showElementBrowser');
@@ -279,12 +300,17 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
279
300
  availableWrapperBlockTypes = _useSharedState.availableWrapperBlockTypes,
280
301
  canInsertLink = _useSharedState.canInsertLink,
281
302
  activeLinkMark = _useSharedState.activeLinkMark;
303
+ var emojiProviderPromise = useSharedPluginStateSelector(pluginInjectionApi, 'emoji.emojiProviderPromise', {
304
+ disabled: !editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)
305
+ });
282
306
  var getEmojiProvider = function getEmojiProvider() {
283
307
  if (emojiProviderSelector) {
284
308
  return Promise.resolve(emojiProviderSelector);
285
309
  }
286
310
  };
287
- var emojiProvider = getEmojiProvider();
311
+ var emojiProvider = editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true, {
312
+ exposure: true
313
+ }) ? emojiProviderPromise : getEmojiProvider();
288
314
  var onShowMediaPicker = function onShowMediaPicker(mountInfo) {
289
315
  if (!showMediaPicker) {
290
316
  return;
@@ -8,6 +8,7 @@ import memoizeOne from 'memoize-one';
8
8
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
9
9
  import { blockTypeMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
12
  import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table, tableSelector } from './item';
12
13
  import { shallowEquals } from './shallow-equals';
13
14
  var buttonToItem = memoize(function (button) {
@@ -46,6 +47,9 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
46
47
  linkDisabled = config.linkDisabled,
47
48
  emojiDisabled = config.emojiDisabled,
48
49
  emojiProvider = config.emojiProvider,
50
+ hasEmojiPlugin = config.hasEmojiPlugin,
51
+ hasMentionsPlugin = config.hasMentionsPlugin,
52
+ hasMediaPlugin = config.hasMediaPlugin,
49
53
  nativeStatusSupported = config.nativeStatusSupported,
50
54
  insertMenuItems = config.insertMenuItems,
51
55
  dateEnabled = config.dateEnabled,
@@ -74,34 +78,65 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
74
78
  'aria-haspopup': 'dialog'
75
79
  }));
76
80
  }
77
- if (mediaSupported && mediaUploadsEnabled) {
78
- items.push(media({
79
- content: formatMessage(messages.addMediaFiles),
80
- tooltipDescription: formatMessage(messages.mediaFilesDescription),
81
- disabled: isOffline
82
- }));
83
- }
84
- if (imageUploadSupported) {
85
- items.push(imageUpload({
86
- content: formatMessage(messages.image),
87
- disabled: !imageUploadEnabled || isOffline
88
- }));
89
- }
90
- if (mentionsSupported) {
91
- items.push(mention({
92
- content: formatMessage(messages.mention),
93
- tooltipDescription: formatMessage(messages.mentionDescription),
94
- disabled: !isTypeAheadAllowed || !!mentionsDisabled,
95
- 'aria-haspopup': 'listbox'
96
- }));
97
- }
98
- if (emojiProvider) {
99
- items.push(emoji({
100
- content: formatMessage(messages.emoji),
101
- tooltipDescription: formatMessage(messages.emojiDescription),
102
- disabled: emojiDisabled || !isTypeAheadAllowed,
103
- 'aria-haspopup': 'dialog'
104
- }));
81
+ if (editorExperiment('platform_editor_prevent_toolbar_layout_shifts', true)) {
82
+ if (imageUploadSupported) {
83
+ items.push(imageUpload({
84
+ content: formatMessage(messages.image),
85
+ disabled: !imageUploadEnabled || isOffline
86
+ }));
87
+ } else if (hasMediaPlugin) {
88
+ items.push(media({
89
+ content: formatMessage(messages.addMediaFiles),
90
+ tooltipDescription: formatMessage(messages.mediaFilesDescription),
91
+ disabled: isOffline || !mediaSupported || !mediaUploadsEnabled
92
+ }));
93
+ }
94
+ if (hasMentionsPlugin) {
95
+ items.push(mention({
96
+ content: formatMessage(messages.mention),
97
+ tooltipDescription: formatMessage(messages.mentionDescription),
98
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled || !mentionsSupported,
99
+ 'aria-haspopup': 'listbox'
100
+ }));
101
+ }
102
+ if (hasEmojiPlugin) {
103
+ items.push(emoji({
104
+ content: formatMessage(messages.emoji),
105
+ tooltipDescription: formatMessage(messages.emojiDescription),
106
+ disabled: emojiDisabled || !isTypeAheadAllowed || !emojiProvider,
107
+ 'aria-haspopup': 'dialog'
108
+ }));
109
+ }
110
+ } else {
111
+ if (mediaSupported && mediaUploadsEnabled) {
112
+ items.push(media({
113
+ content: formatMessage(messages.addMediaFiles),
114
+ tooltipDescription: formatMessage(messages.mediaFilesDescription),
115
+ disabled: isOffline
116
+ }));
117
+ }
118
+ if (imageUploadSupported) {
119
+ items.push(imageUpload({
120
+ content: formatMessage(messages.image),
121
+ disabled: !imageUploadEnabled || isOffline
122
+ }));
123
+ }
124
+ if (mentionsSupported) {
125
+ items.push(mention({
126
+ content: formatMessage(messages.mention),
127
+ tooltipDescription: formatMessage(messages.mentionDescription),
128
+ disabled: !isTypeAheadAllowed || !!mentionsDisabled,
129
+ 'aria-haspopup': 'listbox'
130
+ }));
131
+ }
132
+ if (emojiProvider) {
133
+ items.push(emoji({
134
+ content: formatMessage(messages.emoji),
135
+ tooltipDescription: formatMessage(messages.emojiDescription),
136
+ disabled: emojiDisabled || !isTypeAheadAllowed,
137
+ 'aria-haspopup': 'dialog'
138
+ }));
139
+ }
105
140
  }
106
141
  if (tableSupported) {
107
142
  items.push(table({
@@ -808,6 +808,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
808
808
  }], [{
809
809
  key: "getDerivedStateFromProps",
810
810
  value: function getDerivedStateFromProps(props, state) {
811
+ var _props$pluginInjectio, _props$pluginInjectio2, _props$pluginInjectio3;
811
812
  var _createItems = createItems({
812
813
  isTypeAheadAllowed: props.isTypeAheadAllowed,
813
814
  tableSupported: props.tableSupported,
@@ -824,6 +825,9 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
824
825
  linkSupported: props.linkSupported,
825
826
  linkDisabled: props.linkDisabled,
826
827
  emojiDisabled: props.emojiDisabled,
828
+ hasEmojiPlugin: !!((_props$pluginInjectio = props.pluginInjectionApi) !== null && _props$pluginInjectio !== void 0 && _props$pluginInjectio.emoji),
829
+ hasMentionsPlugin: !!((_props$pluginInjectio2 = props.pluginInjectionApi) !== null && _props$pluginInjectio2 !== void 0 && _props$pluginInjectio2.mention),
830
+ hasMediaPlugin: !!((_props$pluginInjectio3 = props.pluginInjectionApi) !== null && _props$pluginInjectio3 !== void 0 && _props$pluginInjectio3.media),
827
831
  nativeStatusSupported: props.nativeStatusSupported,
828
832
  dateEnabled: props.dateEnabled,
829
833
  placeholderTextEnabled: props.placeholderTextEnabled,
@@ -20,6 +20,9 @@ export interface CreateItemsConfig {
20
20
  linkSupported?: boolean;
21
21
  linkDisabled?: boolean;
22
22
  emojiDisabled?: boolean;
23
+ hasEmojiPlugin?: boolean;
24
+ hasMentionsPlugin?: boolean;
25
+ hasMediaPlugin?: boolean;
23
26
  nativeStatusSupported?: boolean;
24
27
  dateEnabled?: boolean;
25
28
  placeholderTextEnabled?: boolean;
@@ -20,6 +20,9 @@ export interface CreateItemsConfig {
20
20
  linkSupported?: boolean;
21
21
  linkDisabled?: boolean;
22
22
  emojiDisabled?: boolean;
23
+ hasEmojiPlugin?: boolean;
24
+ hasMentionsPlugin?: boolean;
25
+ hasMediaPlugin?: boolean;
23
26
  nativeStatusSupported?: boolean;
24
27
  dateEnabled?: boolean;
25
28
  placeholderTextEnabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-insert-block",
3
- "version": "3.2.8",
3
+ "version": "3.2.10",
4
4
  "description": "Insert block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,23 +33,23 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/button": "^23.0.0",
37
- "@atlaskit/editor-common": "^105.3.0",
36
+ "@atlaskit/button": "^23.2.0",
37
+ "@atlaskit/editor-common": "^106.0.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.3.0",
39
39
  "@atlaskit/editor-plugin-block-type": "^5.1.0",
40
40
  "@atlaskit/editor-plugin-code-block": "^4.4.0",
41
41
  "@atlaskit/editor-plugin-connectivity": "^2.0.0",
42
42
  "@atlaskit/editor-plugin-date": "^4.3.0",
43
- "@atlaskit/editor-plugin-emoji": "^3.6.0",
43
+ "@atlaskit/editor-plugin-emoji": "^3.7.0",
44
44
  "@atlaskit/editor-plugin-expand": "^3.2.0",
45
- "@atlaskit/editor-plugin-extension": "^5.3.0",
45
+ "@atlaskit/editor-plugin-extension": "^5.4.0",
46
46
  "@atlaskit/editor-plugin-feature-flags": "^1.4.0",
47
47
  "@atlaskit/editor-plugin-hyperlink": "^4.4.0",
48
48
  "@atlaskit/editor-plugin-image-upload": "^2.0.0",
49
- "@atlaskit/editor-plugin-layout": "^2.7.0",
49
+ "@atlaskit/editor-plugin-layout": "^2.8.0",
50
50
  "@atlaskit/editor-plugin-media": "^3.0.0",
51
51
  "@atlaskit/editor-plugin-media-insert": "^6.3.0",
52
- "@atlaskit/editor-plugin-mentions": "^4.6.0",
52
+ "@atlaskit/editor-plugin-mentions": "^4.7.0",
53
53
  "@atlaskit/editor-plugin-metrics": "^3.4.0",
54
54
  "@atlaskit/editor-plugin-panel": "^4.4.0",
55
55
  "@atlaskit/editor-plugin-placeholder-text": "^2.3.0",
@@ -57,21 +57,21 @@
57
57
  "@atlaskit/editor-plugin-quick-insert": "^2.5.0",
58
58
  "@atlaskit/editor-plugin-rule": "^2.1.0",
59
59
  "@atlaskit/editor-plugin-status": "^3.1.0",
60
- "@atlaskit/editor-plugin-table": "^10.9.0",
60
+ "@atlaskit/editor-plugin-table": "^10.11.0",
61
61
  "@atlaskit/editor-plugin-tasks-and-decisions": "^5.1.0",
62
62
  "@atlaskit/editor-plugin-type-ahead": "^2.7.0",
63
63
  "@atlaskit/editor-prosemirror": "7.0.0",
64
64
  "@atlaskit/editor-shared-styles": "^3.4.0",
65
65
  "@atlaskit/emoji": "^69.2.0",
66
66
  "@atlaskit/heading": "^5.2.0",
67
- "@atlaskit/icon": "^26.0.0",
68
- "@atlaskit/icon-lab": "^4.12.0",
67
+ "@atlaskit/icon": "^26.4.0",
68
+ "@atlaskit/icon-lab": "^4.17.0",
69
69
  "@atlaskit/platform-feature-flags": "^1.1.0",
70
- "@atlaskit/primitives": "^14.7.0",
70
+ "@atlaskit/primitives": "^14.8.0",
71
71
  "@atlaskit/theme": "^18.0.0",
72
- "@atlaskit/tmp-editor-statsig": "^4.22.0",
73
- "@atlaskit/tokens": "^4.8.0",
74
- "@atlaskit/tooltip": "^20.0.0",
72
+ "@atlaskit/tmp-editor-statsig": "^5.2.0",
73
+ "@atlaskit/tokens": "^4.9.0",
74
+ "@atlaskit/tooltip": "^20.2.0",
75
75
  "@babel/runtime": "^7.0.0",
76
76
  "@emotion/react": "^11.7.1",
77
77
  "bind-event-listener": "^3.0.0",