@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.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +24 -96
- package/dist/cjs/ui/toolbar-components.js +115 -150
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +18 -83
- package/dist/es2019/ui/toolbar-components.js +110 -143
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +23 -95
- package/dist/esm/ui/toolbar-components.js +115 -150
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/package.json +3 -12
|
@@ -254,159 +254,126 @@ export const getToolbarComponents = ({
|
|
|
254
254
|
numberOfButtons: 0
|
|
255
255
|
});
|
|
256
256
|
};
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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 =
|
|
171
|
+
result = filterForPinWhiteboards(unfilteredResult, formatMessage);
|
|
244
172
|
}
|
|
245
173
|
setItemCount(result.length);
|
|
246
174
|
return result;
|