@atlaskit/editor-plugin-insert-block 8.3.2 → 8.4.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.
@@ -254,159 +254,126 @@ export const getToolbarComponents = ({
254
254
  numberOfButtons: 0
255
255
  });
256
256
  };
257
- if (fg('platform_editor_toolbar_aifc_ga_blockers')) {
258
- components.push({
257
+ components.push({
258
+ type: INSERT_GROUP.type,
259
+ key: `${INSERT_GROUP.key}-none`,
260
+ parents: [{
261
+ type: INSERT_BLOCK_SECTION.type,
262
+ key: INSERT_BLOCK_SECTION.key,
263
+ rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
264
+ }],
265
+ component: ({
266
+ children
267
+ }) => /*#__PURE__*/React.createElement(Show, {
268
+ below: "sm"
269
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
270
+ });
271
+ components.push({
272
+ type: INSERT_BUTTON.type,
273
+ key: INSERT_BUTTON.key,
274
+ parents: [{
259
275
  type: INSERT_GROUP.type,
260
276
  key: `${INSERT_GROUP.key}-none`,
261
- parents: [{
262
- type: INSERT_BLOCK_SECTION.type,
263
- key: INSERT_BLOCK_SECTION.key,
264
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
265
- }],
266
- component: ({
267
- children
268
- }) => /*#__PURE__*/React.createElement(Show, {
269
- below: "sm"
270
- }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
271
- });
272
- components.push({
273
- type: INSERT_BUTTON.type,
274
- key: INSERT_BUTTON.key,
275
- parents: [{
276
- type: INSERT_GROUP.type,
277
- key: `${INSERT_GROUP.key}-none`,
278
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
279
- }],
280
- component: createInsertButtonComponent(null)
281
- });
282
- components.push({
277
+ rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
278
+ }],
279
+ component: createInsertButtonComponent(null)
280
+ });
281
+ components.push({
282
+ type: INSERT_GROUP.type,
283
+ key: `${INSERT_GROUP.key}-sm`,
284
+ parents: [{
285
+ type: INSERT_BLOCK_SECTION.type,
286
+ key: INSERT_BLOCK_SECTION.key,
287
+ rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
288
+ }],
289
+ component: ({
290
+ children
291
+ }) => /*#__PURE__*/React.createElement(Show, {
292
+ only: "sm"
293
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
294
+ });
295
+ components.push({
296
+ type: INSERT_BUTTON.type,
297
+ key: INSERT_BUTTON.key,
298
+ parents: [{
283
299
  type: INSERT_GROUP.type,
284
300
  key: `${INSERT_GROUP.key}-sm`,
285
- parents: [{
286
- type: INSERT_BLOCK_SECTION.type,
287
- key: INSERT_BLOCK_SECTION.key,
288
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
289
- }],
290
- component: ({
291
- children
292
- }) => /*#__PURE__*/React.createElement(Show, {
293
- only: "sm"
294
- }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
295
- });
296
- components.push({
297
- type: INSERT_BUTTON.type,
298
- key: INSERT_BUTTON.key,
299
- parents: [{
300
- type: INSERT_GROUP.type,
301
- key: `${INSERT_GROUP.key}-sm`,
302
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
303
- }],
304
- component: createInsertButtonComponent('sm')
305
- });
306
- components.push({
301
+ rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
302
+ }],
303
+ component: createInsertButtonComponent('sm')
304
+ });
305
+ components.push({
306
+ type: INSERT_GROUP.type,
307
+ key: `${INSERT_GROUP.key}-md`,
308
+ parents: [{
309
+ type: INSERT_BLOCK_SECTION.type,
310
+ key: INSERT_BLOCK_SECTION.key,
311
+ rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
312
+ }],
313
+ component: ({
314
+ children
315
+ }) => /*#__PURE__*/React.createElement(Show, {
316
+ only: "md"
317
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
318
+ });
319
+ components.push({
320
+ type: INSERT_BUTTON.type,
321
+ key: INSERT_BUTTON.key,
322
+ parents: [{
307
323
  type: INSERT_GROUP.type,
308
324
  key: `${INSERT_GROUP.key}-md`,
309
- parents: [{
310
- type: INSERT_BLOCK_SECTION.type,
311
- key: INSERT_BLOCK_SECTION.key,
312
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
313
- }],
314
- component: ({
315
- children
316
- }) => /*#__PURE__*/React.createElement(Show, {
317
- only: "md"
318
- }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
319
- });
320
- components.push({
321
- type: INSERT_BUTTON.type,
322
- key: INSERT_BUTTON.key,
323
- parents: [{
324
- type: INSERT_GROUP.type,
325
- key: `${INSERT_GROUP.key}-md`,
326
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
327
- }],
328
- component: createInsertButtonComponent('md')
329
- });
330
- components.push({
325
+ rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
326
+ }],
327
+ component: createInsertButtonComponent('md')
328
+ });
329
+ components.push({
330
+ type: INSERT_GROUP.type,
331
+ key: `${INSERT_GROUP.key}-lg`,
332
+ parents: [{
333
+ type: INSERT_BLOCK_SECTION.type,
334
+ key: INSERT_BLOCK_SECTION.key,
335
+ rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
336
+ }],
337
+ component: ({
338
+ children
339
+ }) => /*#__PURE__*/React.createElement(Show, {
340
+ only: "lg"
341
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
342
+ });
343
+ components.push({
344
+ type: INSERT_BUTTON.type,
345
+ key: INSERT_BUTTON.key,
346
+ parents: [{
331
347
  type: INSERT_GROUP.type,
332
348
  key: `${INSERT_GROUP.key}-lg`,
333
- parents: [{
334
- type: INSERT_BLOCK_SECTION.type,
335
- key: INSERT_BLOCK_SECTION.key,
336
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
337
- }],
338
- component: ({
339
- children
340
- }) => /*#__PURE__*/React.createElement(Show, {
341
- only: "lg"
342
- }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
343
- });
344
- components.push({
345
- type: INSERT_BUTTON.type,
346
- key: INSERT_BUTTON.key,
347
- parents: [{
348
- type: INSERT_GROUP.type,
349
- key: `${INSERT_GROUP.key}-lg`,
350
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
351
- }],
352
- component: createInsertButtonComponent('lg')
353
- });
354
- components.push({
349
+ rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
350
+ }],
351
+ component: createInsertButtonComponent('lg')
352
+ });
353
+ components.push({
354
+ type: INSERT_GROUP.type,
355
+ key: `${INSERT_GROUP.key}-xl`,
356
+ parents: [{
357
+ type: INSERT_BLOCK_SECTION.type,
358
+ key: INSERT_BLOCK_SECTION.key,
359
+ rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
360
+ }],
361
+ component: ({
362
+ children
363
+ }) => /*#__PURE__*/React.createElement(Show, {
364
+ only: "xl"
365
+ }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
366
+ });
367
+ components.push({
368
+ type: INSERT_BUTTON.type,
369
+ key: INSERT_BUTTON.key,
370
+ parents: [{
355
371
  type: INSERT_GROUP.type,
356
372
  key: `${INSERT_GROUP.key}-xl`,
357
- parents: [{
358
- type: INSERT_BLOCK_SECTION.type,
359
- key: INSERT_BLOCK_SECTION.key,
360
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
361
- }],
362
- component: ({
363
- children
364
- }) => /*#__PURE__*/React.createElement(Show, {
365
- only: "xl"
366
- }, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children))
367
- });
368
- components.push({
369
- type: INSERT_BUTTON.type,
370
- key: INSERT_BUTTON.key,
371
- parents: [{
372
- type: INSERT_GROUP.type,
373
- key: `${INSERT_GROUP.key}-xl`,
374
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
375
- }],
376
- component: createInsertButtonComponent('xl')
377
- });
378
- } else {
379
- components.push({
380
- type: INSERT_GROUP.type,
381
- key: INSERT_GROUP.key,
382
- parents: [{
383
- type: INSERT_BLOCK_SECTION.type,
384
- key: INSERT_BLOCK_SECTION.key,
385
- rank: INSERT_BLOCK_SECTION_RANK[INSERT_GROUP.key]
386
- }]
387
- });
388
- components.push({
389
- type: INSERT_BUTTON.type,
390
- key: INSERT_BUTTON.key,
391
- parents: [{
392
- type: INSERT_GROUP.type,
393
- key: INSERT_GROUP.key,
394
- rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
395
- }],
396
- component: () => /*#__PURE__*/React.createElement(InsertButton, {
397
- api: api,
398
- toolbarConfig: config,
399
- showElementBrowserLink: options.showElementBrowserLink,
400
- tableSelectorSupported: options.tableSelectorSupported,
401
- onInsertBlockType: onInsertBlockType,
402
- nativeStatusSupported: options.nativeStatusSupported,
403
- horizontalRuleEnabled: options.horizontalRuleEnabled,
404
- expandEnabled: options.allowExpand,
405
- insertMenuItems: options.insertMenuItems,
406
- numberOfButtons: 7 // TODO: ED-28759 - Default to 7 buttons - Remove this once we have a proper way to do toolbar responsiveness
407
- })
408
- });
409
- }
373
+ rank: INSERT_GROUP_RANK[INSERT_BUTTON.key]
374
+ }],
375
+ component: createInsertButtonComponent('xl')
376
+ });
410
377
  }
411
378
  return components;
412
379
  };
@@ -23,10 +23,7 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
23
23
  import { messages, IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, IconQuote, IconStatus } from '@atlaskit/editor-common/quick-insert';
24
24
  import { OutsideClickTargetRefContext, withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
25
25
  import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
26
- import { fg } from '@atlaskit/platform-feature-flags';
27
26
  import { N0, N30A, N60A } from '@atlaskit/theme/colors';
28
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
29
- import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
30
27
  export var DEFAULT_HEIGHT = 560;
31
28
 
32
29
  /**
@@ -35,98 +32,29 @@ export var DEFAULT_HEIGHT = 560;
35
32
  method that can be used to get suggestions -> once all experiments are cleaned up,
36
33
  they should be unified through `pluginInjectionApi?.quickInsert?.actions.getSuggestions`
37
34
  */
38
- export var filterForPinWhiteboardsExperiment = function filterForPinWhiteboardsExperiment(featuredItems, formatMessage) {
39
- // Legacy path fallback -- prior comments as follows:
40
- /**
41
- * // Part of ATLAS-95399 to pin whiteboards to the top of the InsertMenu
42
- // Need to check if whiteboard options are available, and filter for the cohort
43
- // Takes the original featuredItems list and returns one with the right whiteboard option at the top
44
- */
45
- if (fg('confluence-whiteboards-quick-insert-eligible')) {
46
- var DIAGRAM_TITLE = 'Create diagram',
47
- BLANK_TITLE = 'Create whiteboard';
48
- var featuredWhiteboardsPresent = featuredItems.filter(function (item) {
49
- return [DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
50
- }).length === 2;
51
- if (featuredWhiteboardsPresent) {
52
- var pinWhiteboardActionToTop = function pinWhiteboardActionToTop(items, title) {
53
- // find the requested item by title, give it the appropriate description, and bring it to the top of the list
54
- var index = items.findIndex(function (item) {
55
- return item.title === title;
56
- });
57
- var filteredList = items.filter(function (item) {
58
- return ![DIAGRAM_TITLE, BLANK_TITLE].includes(item.title);
59
- });
60
- if (index === -1) {
61
- return filteredList;
62
- }
63
- var featuredItem = _objectSpread({}, items[index]);
64
- featuredItem.description = formatMessage(messages.featuredWhiteboardDescription);
65
- return [featuredItem].concat(_toConsumableArray(filteredList));
66
- };
67
- return pinWhiteboardActionToTop(featuredItems, DIAGRAM_TITLE);
68
- } else {
69
- if (fg('confluence-whiteboards-quick-insert-l10n-eligible')) {
70
- // Fire exposure for confluence_whiteboards_quick_insert_localised_aa
71
- // https://switcheroo.atlassian.com/ui/gates/ccd80d32-28a1-4dcf-b3f9-dbdc02a046ff/key/confluence_whiteboards_quick_insert_localised_aa
72
- expVal('confluence_whiteboards_quick_insert_localised_aa', 'cohort', 'test_diagram');
73
-
74
- /** BEGIN locale agnostic path */
75
-
76
- /**
77
- * EXTREMELY IMPORTANT: we must not drop diagram for those who already receive
78
- * the 'insert diagram to the top' treatment.
79
- *
80
- * Our heuristic to check that this is only targeting users where they haven't
81
- * gotten the experience, is if we _cannot_ find the blank board experience in
82
- * the list, matching purely on title.
83
- *
84
- * e.g. `featuredWhiteboardsPresent` = false, given it matches on title.
85
- *
86
- * The side-effect of this, is that there's a small chance/edge case of users
87
- * who toggle between locales, and receive different experiences.
88
- *
89
- * Hopefully we can make a call early on this experiment, and eliminate this
90
- * code path.
91
- */
92
- var WHITEBOARD_KEY = 'whiteboard-extension:create-whiteboard';
93
- var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
94
- var isBlank = function isBlank(item) {
95
- return item.key === WHITEBOARD_KEY;
96
- };
97
- var isDiagram = function isDiagram(item) {
98
- return item.key === DIAGRAM_KEY;
99
- };
100
- var hasBoth = featuredItems.some(isBlank) && featuredItems.some(isDiagram);
101
- if (hasBoth) {
102
- var pin = function pin(key) {
103
- var idx = featuredItems.findIndex(function (item) {
104
- return item.key === key;
105
- });
106
- var filtered = featuredItems.filter(function (item) {
107
- return !isBlank(item) && !isDiagram(item);
108
- });
109
- if (idx === -1) {
110
- return filtered;
111
- }
112
- var picked = _objectSpread(_objectSpread({}, featuredItems[idx]), {}, {
113
- description: formatMessage(messages.featuredWhiteboardDescription)
114
- });
115
- return [picked].concat(_toConsumableArray(filtered));
116
- };
117
- if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_blank')) {
118
- return pin(WHITEBOARD_KEY);
119
- }
120
- if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'test_diagram')) {
121
- return pin(DIAGRAM_KEY);
122
- }
123
- if (expValEquals('confluence_whiteboards_quick_insert_localised', 'cohort', 'control')) {
124
- return featuredItems;
125
- }
126
- }
35
+ export var filterForPinWhiteboards = function filterForPinWhiteboards(featuredItems, formatMessage) {
36
+ var DIAGRAM_KEY = 'whiteboard-extension:create-diagram';
37
+ var isDiagram = function isDiagram(item) {
38
+ return item.key === DIAGRAM_KEY;
39
+ };
40
+ var featuredWhiteboardsPresent = featuredItems.some(isDiagram);
41
+ if (featuredWhiteboardsPresent) {
42
+ var pin = function pin(key) {
43
+ var idx = featuredItems.findIndex(function (item) {
44
+ return item.key === key;
45
+ });
46
+ var filtered = featuredItems.filter(function (item) {
47
+ return !isDiagram(item);
48
+ });
49
+ if (idx === -1) {
50
+ return filtered;
127
51
  }
128
- /** END locale agnostic path */
129
- }
52
+ var picked = _objectSpread(_objectSpread({}, featuredItems[idx]), {}, {
53
+ description: formatMessage(messages.featuredWhiteboardDescription)
54
+ });
55
+ return [picked].concat(_toConsumableArray(filtered));
56
+ };
57
+ return pin(DIAGRAM_KEY);
130
58
  }
131
59
  return featuredItems;
132
60
  };
@@ -240,7 +168,7 @@ var InsertMenu = function InsertMenu(_ref) {
240
168
  })) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
241
169
  var unfilteredResult = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
242
170
  // need to filter on the concatenated list so whiteboards are at the top
243
- result = filterForPinWhiteboardsExperiment(unfilteredResult, formatMessage);
171
+ result = filterForPinWhiteboards(unfilteredResult, formatMessage);
244
172
  }
245
173
  setItemCount(result.length);
246
174
  return result;