@atlaskit/editor-plugin-insert-block 11.0.7 → 11.2.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 +65 -0
- package/dist/cjs/insertBlockPlugin.js +1 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +0 -2
- package/dist/cjs/ui/ToolbarInsertBlock/create-items.js +10 -4
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +1 -0
- package/dist/cjs/ui/toolbar-components/InsertButton.js +2 -0
- package/dist/cjs/ui/toolbar-components/hooks/useInsertButtonState.js +2 -0
- package/dist/cjs/ui/toolbar-components.js +1 -0
- package/dist/es2019/insertBlockPlugin.js +1 -0
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +0 -2
- package/dist/es2019/ui/ToolbarInsertBlock/create-items.js +10 -4
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +1 -0
- package/dist/es2019/ui/toolbar-components/InsertButton.js +2 -0
- package/dist/es2019/ui/toolbar-components/hooks/useInsertButtonState.js +2 -0
- package/dist/es2019/ui/toolbar-components.js +1 -0
- package/dist/esm/insertBlockPlugin.js +1 -0
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +0 -2
- package/dist/esm/ui/ToolbarInsertBlock/create-items.js +10 -4
- package/dist/esm/ui/ToolbarInsertBlock/index.js +1 -0
- package/dist/esm/ui/toolbar-components/InsertButton.js +2 -0
- package/dist/esm/ui/toolbar-components/hooks/useInsertButtonState.js +2 -0
- package/dist/esm/ui/toolbar-components.js +1 -0
- package/dist/types/types/index.d.ts +15 -0
- package/dist/types/ui/ToolbarInsertBlock/create-items.d.ts +2 -0
- package/dist/types/ui/ToolbarInsertBlock/types.d.ts +2 -0
- package/dist/types/ui/toolbar-components/InsertButton.d.ts +3 -1
- package/dist/types/ui/toolbar-components/hooks/useInsertButtonState.d.ts +3 -1
- package/dist/types-ts4.5/types/index.d.ts +15 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/create-items.d.ts +2 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/types.d.ts +2 -0
- package/dist/types-ts4.5/ui/toolbar-components/InsertButton.d.ts +3 -1
- package/dist/types-ts4.5/ui/toolbar-components/hooks/useInsertButtonState.d.ts +3 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-insert-block
|
|
2
2
|
|
|
3
|
+
## 11.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ef22af532ebfd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef22af532ebfd) -
|
|
8
|
+
EDITOR-6558: Introduce a reusable Markdown Mode editor plugin and two consumer-supplied
|
|
9
|
+
insert-filter hooks.
|
|
10
|
+
|
|
11
|
+
### `@atlassian/editor-plugin-markdown-mode` (new package — major)
|
|
12
|
+
|
|
13
|
+
A reusable editor plugin that owns the full Markdown Mode lifecycle: ProseMirror plugin state for
|
|
14
|
+
the active view, a 3-button view toggle (`MarkdownModeViewToggleBase`), a CodeMirror 6 source view
|
|
15
|
+
(`MarkdownSourceView`), ADF↔markdown conversion (`adfToMarkdown` / `markdownToAdf`), and the
|
|
16
|
+
snapshot/writeback orchestration (`MarkdownModeContentComponent`). The plugin is product-agnostic
|
|
17
|
+
— Confluence wraps it for the `cc-markdown-mode` experiment, but any consumer can adopt it.
|
|
18
|
+
|
|
19
|
+
The package also exports two allowlists used by the new insert-filter hooks below:
|
|
20
|
+
- `MARKDOWN_COMPATIBLE_QUICK_INSERT_ITEM_IDS` + `isMarkdownCompatibleQuickInsertItem` — items
|
|
21
|
+
whose underlying node has a clean GFM round-trip via `@atlassian/mdast-util-from-pm`.
|
|
22
|
+
- `MARKDOWN_COMPATIBLE_TOOLBAR_ITEM_NAMES` + `isMarkdownCompatibleToolbarItem` — same idea for the
|
|
23
|
+
main toolbar's `+` insert block.
|
|
24
|
+
|
|
25
|
+
### `@atlaskit/editor-plugin-quick-insert` (minor)
|
|
26
|
+
|
|
27
|
+
Added an optional `itemFilter?: (item: QuickInsertItem) => boolean` to `QuickInsertOptions`. When
|
|
28
|
+
set, the filter is applied in both `getQuickInsertSuggestions` (the typeahead path) and the
|
|
29
|
+
`getSuggestions` action path before items are categorised or returned. Composes additively with
|
|
30
|
+
any caller-supplied filter via `&&`. No behavioural change for callers that don't set it.
|
|
31
|
+
|
|
32
|
+
### `@atlaskit/editor-plugin-insert-block` (minor)
|
|
33
|
+
|
|
34
|
+
Added an optional `itemFilter?: (item: { value: { name: string } }) => boolean` to
|
|
35
|
+
`InsertBlockPluginOptions`. The filter is applied to the items list inside `createItems` before
|
|
36
|
+
it's split into toolbar buttons / overflow dropdown entries, so item counts stay correct
|
|
37
|
+
downstream. Wired through both legacy (`ToolbarInsertBlock`) and new (`useInsertButtonState`)
|
|
38
|
+
toolbar code paths. No behavioural change for callers that don't set it.
|
|
39
|
+
|
|
40
|
+
### `@atlaskit/editor-common` (patch)
|
|
41
|
+
|
|
42
|
+
`UseSharedPluginStateWithSelector`-friendly types are unchanged; the only public change is a new
|
|
43
|
+
optional field on `QuickInsertOptions` and a corresponding plumbing field on the internal
|
|
44
|
+
`QuickInsertSearchOptions`.
|
|
45
|
+
|
|
46
|
+
### `@atlassian/mdast-util-from-pm` (patch)
|
|
47
|
+
|
|
48
|
+
Added `undoEdgeWhitespaceEncoding()` post-processor that replaces the leading/trailing-edge entity
|
|
49
|
+
escapes ` ` and `	` produced by the upstream encoder with literal space and tab
|
|
50
|
+
characters. This is a readability + round-trip identity fix that benefits all consumers, not just
|
|
51
|
+
Markdown Mode.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies
|
|
56
|
+
|
|
57
|
+
## 11.1.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- [`d1bd1354e626f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d1bd1354e626f) -
|
|
62
|
+
Remove A/A for Create with Rovo via Slash Command experiment
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies
|
|
67
|
+
|
|
3
68
|
## 11.0.7
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
@@ -357,6 +357,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
357
357
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
358
358
|
popupsScrollableElement: popupsScrollableElement,
|
|
359
359
|
insertMenuItems: options.insertMenuItems,
|
|
360
|
+
itemFilter: options.itemFilter,
|
|
360
361
|
editorActions: editorActions,
|
|
361
362
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
362
363
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
@@ -36,8 +36,6 @@ var DEFAULT_HEIGHT = exports.DEFAULT_HEIGHT = 560;
|
|
|
36
36
|
* This newer implementation matches how the quick insert menu sorts elements.
|
|
37
37
|
*/
|
|
38
38
|
var sortFeaturedItems = exports.sortFeaturedItems = function sortFeaturedItems(featuredItems, formatMessage) {
|
|
39
|
-
// temporary for A/A test
|
|
40
|
-
['slot-two', 'slot-four'].includes((0, _expVal.expValNoExposure)('cc_fd_cwr_quick_insert_aa', 'cohort', 'control'));
|
|
41
39
|
if (['new-description', 'orig-description'].includes((0, _expVal.expVal)('cc_fd_db_top_editor_toolbar', 'cohort', 'control')) || (0, _expVal.expValNoExposure)('cc_fd_wb_jira_quick_insert_experiment', 'isEnabled', false) || ['slot-two', 'slot-four'].includes((0, _expVal.expValNoExposure)('cc_fd_cwr_quick_insert', 'cohort', 'control'))) {
|
|
42
40
|
// Sort by priority (lower first) on the concatenated list so items
|
|
43
41
|
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
@@ -66,7 +66,8 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
66
66
|
numberOfButtons = config.numberOfButtons,
|
|
67
67
|
schema = config.schema,
|
|
68
68
|
formatMessage = config.formatMessage,
|
|
69
|
-
isEditorOffline = config.isEditorOffline
|
|
69
|
+
isEditorOffline = config.isEditorOffline,
|
|
70
|
+
itemFilter = config.itemFilter;
|
|
70
71
|
var items = [];
|
|
71
72
|
var isOffline = isEditorOffline === true;
|
|
72
73
|
if (actionSupported) {
|
|
@@ -245,9 +246,14 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
245
246
|
if (insertMenuItems) {
|
|
246
247
|
items.push.apply(items, (0, _toConsumableArray2.default)(insertMenuItems));
|
|
247
248
|
}
|
|
249
|
+
|
|
250
|
+
// EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
251
|
+
// before computing toolbar button / dropdown splits so item counts are
|
|
252
|
+
// correct downstream.
|
|
253
|
+
var filteredItems = itemFilter ? items.filter(itemFilter) : items;
|
|
248
254
|
var numButtonsAdjusted = numberOfButtons;
|
|
249
255
|
if ((0, _platformFeatureFlags.fg)('platform_editor_toolbar_responsive_fixes')) {
|
|
250
|
-
if (
|
|
256
|
+
if (filteredItems.slice(0, numButtonsAdjusted).some(function (item) {
|
|
251
257
|
return item.value.name === 'table selector';
|
|
252
258
|
})) {
|
|
253
259
|
numButtonsAdjusted++;
|
|
@@ -255,8 +261,8 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
255
261
|
} else {
|
|
256
262
|
numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
257
263
|
}
|
|
258
|
-
var buttonItems =
|
|
259
|
-
var remainingItems =
|
|
264
|
+
var buttonItems = filteredItems.slice(0, numButtonsAdjusted).map(buttonToItem);
|
|
265
|
+
var remainingItems = filteredItems.slice(numButtonsAdjusted).filter(function (_ref) {
|
|
260
266
|
var name = _ref.value.name;
|
|
261
267
|
return name !== 'table selector';
|
|
262
268
|
});
|
|
@@ -835,6 +835,7 @@ var ToolbarInsertBlock = exports.ToolbarInsertBlock = /*#__PURE__*/function (_Re
|
|
|
835
835
|
emojiProvider: props.emojiProvider,
|
|
836
836
|
availableWrapperBlockTypes: props.availableWrapperBlockTypes,
|
|
837
837
|
insertMenuItems: props.insertMenuItems,
|
|
838
|
+
itemFilter: props.itemFilter,
|
|
838
839
|
schema: props.editorView.state.schema,
|
|
839
840
|
numberOfButtons: props.buttons,
|
|
840
841
|
formatMessage: props.intl.formatMessage
|
|
@@ -40,6 +40,7 @@ var InsertButton = exports.InsertButton = function InsertButton(_ref) {
|
|
|
40
40
|
horizontalRuleEnabled = _ref.horizontalRuleEnabled,
|
|
41
41
|
expandEnabled = _ref.expandEnabled,
|
|
42
42
|
insertMenuItems = _ref.insertMenuItems,
|
|
43
|
+
itemFilter = _ref.itemFilter,
|
|
43
44
|
numberOfButtons = _ref.numberOfButtons,
|
|
44
45
|
onInsertBlockType = _ref.onInsertBlockType,
|
|
45
46
|
toolbarConfig = _ref.toolbarConfig;
|
|
@@ -72,6 +73,7 @@ var InsertButton = exports.InsertButton = function InsertButton(_ref) {
|
|
|
72
73
|
editorView: editorView || undefined,
|
|
73
74
|
horizontalRuleEnabled: horizontalRuleEnabled,
|
|
74
75
|
insertMenuItems: insertMenuItems,
|
|
76
|
+
itemFilter: itemFilter,
|
|
75
77
|
nativeStatusSupported: nativeStatusSupported,
|
|
76
78
|
numberOfButtons: numberOfButtons,
|
|
77
79
|
tableSelectorSupported: tableSelectorSupported,
|
|
@@ -18,6 +18,7 @@ var useInsertButtonState = exports.useInsertButtonState = function useInsertButt
|
|
|
18
18
|
editorView = _ref.editorView,
|
|
19
19
|
horizontalRuleEnabled = _ref.horizontalRuleEnabled,
|
|
20
20
|
insertMenuItems = _ref.insertMenuItems,
|
|
21
|
+
itemFilter = _ref.itemFilter,
|
|
21
22
|
nativeStatusSupported = _ref.nativeStatusSupported,
|
|
22
23
|
numberOfButtons = _ref.numberOfButtons,
|
|
23
24
|
tableSelectorSupported = _ref.tableSelectorSupported,
|
|
@@ -80,6 +81,7 @@ var useInsertButtonState = exports.useInsertButtonState = function useInsertButt
|
|
|
80
81
|
emojiProvider: emojiProvider,
|
|
81
82
|
availableWrapperBlockTypes: availableWrapperBlockTypes,
|
|
82
83
|
insertMenuItems: insertMenuItems,
|
|
84
|
+
itemFilter: itemFilter,
|
|
83
85
|
schema: editorView === null || editorView === void 0 ? void 0 : editorView.state.schema,
|
|
84
86
|
numberOfButtons: numberOfButtons || 0,
|
|
85
87
|
formatMessage: formatMessage
|
|
@@ -274,6 +274,7 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
274
274
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
275
275
|
expandEnabled: options.allowExpand,
|
|
276
276
|
insertMenuItems: options.insertMenuItems,
|
|
277
|
+
itemFilter: options.itemFilter,
|
|
277
278
|
numberOfButtons: 0
|
|
278
279
|
});
|
|
279
280
|
};
|
|
@@ -341,6 +341,7 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
341
341
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
342
342
|
popupsScrollableElement: popupsScrollableElement,
|
|
343
343
|
insertMenuItems: options.insertMenuItems,
|
|
344
|
+
itemFilter: options.itemFilter,
|
|
344
345
|
editorActions: editorActions,
|
|
345
346
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
346
347
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
@@ -26,8 +26,6 @@ export const DEFAULT_HEIGHT = 560;
|
|
|
26
26
|
* This newer implementation matches how the quick insert menu sorts elements.
|
|
27
27
|
*/
|
|
28
28
|
export const sortFeaturedItems = (featuredItems, formatMessage) => {
|
|
29
|
-
// temporary for A/A test
|
|
30
|
-
['slot-two', 'slot-four'].includes(expValNoExposure('cc_fd_cwr_quick_insert_aa', 'cohort', 'control'));
|
|
31
29
|
if (['new-description', 'orig-description'].includes(expVal('cc_fd_db_top_editor_toolbar', 'cohort', 'control')) || expValNoExposure('cc_fd_wb_jira_quick_insert_experiment', 'isEnabled', false) || ['slot-two', 'slot-four'].includes(expValNoExposure('cc_fd_cwr_quick_insert', 'cohort', 'control'))) {
|
|
32
30
|
// Sort by priority (lower first) on the concatenated list so items
|
|
33
31
|
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
@@ -52,7 +52,8 @@ const createInsertBlockItems = config => {
|
|
|
52
52
|
numberOfButtons,
|
|
53
53
|
schema,
|
|
54
54
|
formatMessage,
|
|
55
|
-
isEditorOffline
|
|
55
|
+
isEditorOffline,
|
|
56
|
+
itemFilter
|
|
56
57
|
} = config;
|
|
57
58
|
const items = [];
|
|
58
59
|
const isOffline = isEditorOffline === true;
|
|
@@ -226,16 +227,21 @@ const createInsertBlockItems = config => {
|
|
|
226
227
|
if (insertMenuItems) {
|
|
227
228
|
items.push(...insertMenuItems);
|
|
228
229
|
}
|
|
230
|
+
|
|
231
|
+
// EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
232
|
+
// before computing toolbar button / dropdown splits so item counts are
|
|
233
|
+
// correct downstream.
|
|
234
|
+
const filteredItems = itemFilter ? items.filter(itemFilter) : items;
|
|
229
235
|
let numButtonsAdjusted = numberOfButtons;
|
|
230
236
|
if (fg('platform_editor_toolbar_responsive_fixes')) {
|
|
231
|
-
if (
|
|
237
|
+
if (filteredItems.slice(0, numButtonsAdjusted).some(item => item.value.name === 'table selector')) {
|
|
232
238
|
numButtonsAdjusted++;
|
|
233
239
|
}
|
|
234
240
|
} else {
|
|
235
241
|
numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
236
242
|
}
|
|
237
|
-
const buttonItems =
|
|
238
|
-
const remainingItems =
|
|
243
|
+
const buttonItems = filteredItems.slice(0, numButtonsAdjusted).map(buttonToItem);
|
|
244
|
+
const remainingItems = filteredItems.slice(numButtonsAdjusted).filter(({
|
|
239
245
|
value: {
|
|
240
246
|
name
|
|
241
247
|
}
|
|
@@ -588,6 +588,7 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
588
588
|
emojiProvider: props.emojiProvider,
|
|
589
589
|
availableWrapperBlockTypes: props.availableWrapperBlockTypes,
|
|
590
590
|
insertMenuItems: props.insertMenuItems,
|
|
591
|
+
itemFilter: props.itemFilter,
|
|
591
592
|
schema: props.editorView.state.schema,
|
|
592
593
|
numberOfButtons: props.buttons,
|
|
593
594
|
formatMessage: props.intl.formatMessage
|
|
@@ -29,6 +29,7 @@ export const InsertButton = ({
|
|
|
29
29
|
horizontalRuleEnabled,
|
|
30
30
|
expandEnabled,
|
|
31
31
|
insertMenuItems,
|
|
32
|
+
itemFilter,
|
|
32
33
|
numberOfButtons,
|
|
33
34
|
onInsertBlockType,
|
|
34
35
|
toolbarConfig
|
|
@@ -66,6 +67,7 @@ export const InsertButton = ({
|
|
|
66
67
|
editorView: editorView || undefined,
|
|
67
68
|
horizontalRuleEnabled,
|
|
68
69
|
insertMenuItems,
|
|
70
|
+
itemFilter,
|
|
69
71
|
nativeStatusSupported,
|
|
70
72
|
numberOfButtons,
|
|
71
73
|
tableSelectorSupported,
|
|
@@ -10,6 +10,7 @@ export const useInsertButtonState = ({
|
|
|
10
10
|
editorView,
|
|
11
11
|
horizontalRuleEnabled,
|
|
12
12
|
insertMenuItems,
|
|
13
|
+
itemFilter,
|
|
13
14
|
nativeStatusSupported,
|
|
14
15
|
numberOfButtons,
|
|
15
16
|
tableSelectorSupported,
|
|
@@ -74,6 +75,7 @@ export const useInsertButtonState = ({
|
|
|
74
75
|
emojiProvider,
|
|
75
76
|
availableWrapperBlockTypes,
|
|
76
77
|
insertMenuItems,
|
|
78
|
+
itemFilter,
|
|
77
79
|
schema: editorView === null || editorView === void 0 ? void 0 : editorView.state.schema,
|
|
78
80
|
numberOfButtons: numberOfButtons || 0,
|
|
79
81
|
formatMessage
|
|
@@ -250,6 +250,7 @@ export const getToolbarComponents = ({
|
|
|
250
250
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
251
251
|
expandEnabled: options.allowExpand,
|
|
252
252
|
insertMenuItems: options.insertMenuItems,
|
|
253
|
+
itemFilter: options.itemFilter,
|
|
253
254
|
numberOfButtons: 0
|
|
254
255
|
});
|
|
255
256
|
};
|
|
@@ -347,6 +347,7 @@ function ToolbarInsertBlockWithInjectionApi(_ref4) {
|
|
|
347
347
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
348
348
|
popupsScrollableElement: popupsScrollableElement,
|
|
349
349
|
insertMenuItems: options.insertMenuItems,
|
|
350
|
+
itemFilter: options.itemFilter,
|
|
350
351
|
editorActions: editorActions,
|
|
351
352
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
352
353
|
showElementBrowserLink: options.showElementBrowserLink,
|
|
@@ -33,8 +33,6 @@ export var DEFAULT_HEIGHT = 560;
|
|
|
33
33
|
* This newer implementation matches how the quick insert menu sorts elements.
|
|
34
34
|
*/
|
|
35
35
|
export var sortFeaturedItems = function sortFeaturedItems(featuredItems, formatMessage) {
|
|
36
|
-
// temporary for A/A test
|
|
37
|
-
['slot-two', 'slot-four'].includes(expValNoExposure('cc_fd_cwr_quick_insert_aa', 'cohort', 'control'));
|
|
38
36
|
if (['new-description', 'orig-description'].includes(expVal('cc_fd_db_top_editor_toolbar', 'cohort', 'control')) || expValNoExposure('cc_fd_wb_jira_quick_insert_experiment', 'isEnabled', false) || ['slot-two', 'slot-four'].includes(expValNoExposure('cc_fd_cwr_quick_insert', 'cohort', 'control'))) {
|
|
39
37
|
// Sort by priority (lower first) on the concatenated list so items
|
|
40
38
|
// with "priority" are at the top (e.g. Whiteboard before Database)
|
|
@@ -59,7 +59,8 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
59
59
|
numberOfButtons = config.numberOfButtons,
|
|
60
60
|
schema = config.schema,
|
|
61
61
|
formatMessage = config.formatMessage,
|
|
62
|
-
isEditorOffline = config.isEditorOffline
|
|
62
|
+
isEditorOffline = config.isEditorOffline,
|
|
63
|
+
itemFilter = config.itemFilter;
|
|
63
64
|
var items = [];
|
|
64
65
|
var isOffline = isEditorOffline === true;
|
|
65
66
|
if (actionSupported) {
|
|
@@ -238,9 +239,14 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
238
239
|
if (insertMenuItems) {
|
|
239
240
|
items.push.apply(items, _toConsumableArray(insertMenuItems));
|
|
240
241
|
}
|
|
242
|
+
|
|
243
|
+
// EDITOR-6558: apply consumer-supplied filter (e.g. Markdown Mode allowlist)
|
|
244
|
+
// before computing toolbar button / dropdown splits so item counts are
|
|
245
|
+
// correct downstream.
|
|
246
|
+
var filteredItems = itemFilter ? items.filter(itemFilter) : items;
|
|
241
247
|
var numButtonsAdjusted = numberOfButtons;
|
|
242
248
|
if (fg('platform_editor_toolbar_responsive_fixes')) {
|
|
243
|
-
if (
|
|
249
|
+
if (filteredItems.slice(0, numButtonsAdjusted).some(function (item) {
|
|
244
250
|
return item.value.name === 'table selector';
|
|
245
251
|
})) {
|
|
246
252
|
numButtonsAdjusted++;
|
|
@@ -248,8 +254,8 @@ var createInsertBlockItems = function createInsertBlockItems(config) {
|
|
|
248
254
|
} else {
|
|
249
255
|
numButtonsAdjusted = tableSupported && tableSelectorSupported ? numberOfButtons + 1 : numberOfButtons;
|
|
250
256
|
}
|
|
251
|
-
var buttonItems =
|
|
252
|
-
var remainingItems =
|
|
257
|
+
var buttonItems = filteredItems.slice(0, numButtonsAdjusted).map(buttonToItem);
|
|
258
|
+
var remainingItems = filteredItems.slice(numButtonsAdjusted).filter(function (_ref) {
|
|
253
259
|
var name = _ref.value.name;
|
|
254
260
|
return name !== 'table selector';
|
|
255
261
|
});
|
|
@@ -829,6 +829,7 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
829
829
|
emojiProvider: props.emojiProvider,
|
|
830
830
|
availableWrapperBlockTypes: props.availableWrapperBlockTypes,
|
|
831
831
|
insertMenuItems: props.insertMenuItems,
|
|
832
|
+
itemFilter: props.itemFilter,
|
|
832
833
|
schema: props.editorView.state.schema,
|
|
833
834
|
numberOfButtons: props.buttons,
|
|
834
835
|
formatMessage: props.intl.formatMessage
|
|
@@ -32,6 +32,7 @@ export var InsertButton = function InsertButton(_ref) {
|
|
|
32
32
|
horizontalRuleEnabled = _ref.horizontalRuleEnabled,
|
|
33
33
|
expandEnabled = _ref.expandEnabled,
|
|
34
34
|
insertMenuItems = _ref.insertMenuItems,
|
|
35
|
+
itemFilter = _ref.itemFilter,
|
|
35
36
|
numberOfButtons = _ref.numberOfButtons,
|
|
36
37
|
onInsertBlockType = _ref.onInsertBlockType,
|
|
37
38
|
toolbarConfig = _ref.toolbarConfig;
|
|
@@ -64,6 +65,7 @@ export var InsertButton = function InsertButton(_ref) {
|
|
|
64
65
|
editorView: editorView || undefined,
|
|
65
66
|
horizontalRuleEnabled: horizontalRuleEnabled,
|
|
66
67
|
insertMenuItems: insertMenuItems,
|
|
68
|
+
itemFilter: itemFilter,
|
|
67
69
|
nativeStatusSupported: nativeStatusSupported,
|
|
68
70
|
numberOfButtons: numberOfButtons,
|
|
69
71
|
tableSelectorSupported: tableSelectorSupported,
|
|
@@ -11,6 +11,7 @@ export var useInsertButtonState = function useInsertButtonState(_ref) {
|
|
|
11
11
|
editorView = _ref.editorView,
|
|
12
12
|
horizontalRuleEnabled = _ref.horizontalRuleEnabled,
|
|
13
13
|
insertMenuItems = _ref.insertMenuItems,
|
|
14
|
+
itemFilter = _ref.itemFilter,
|
|
14
15
|
nativeStatusSupported = _ref.nativeStatusSupported,
|
|
15
16
|
numberOfButtons = _ref.numberOfButtons,
|
|
16
17
|
tableSelectorSupported = _ref.tableSelectorSupported,
|
|
@@ -73,6 +74,7 @@ export var useInsertButtonState = function useInsertButtonState(_ref) {
|
|
|
73
74
|
emojiProvider: emojiProvider,
|
|
74
75
|
availableWrapperBlockTypes: availableWrapperBlockTypes,
|
|
75
76
|
insertMenuItems: insertMenuItems,
|
|
77
|
+
itemFilter: itemFilter,
|
|
76
78
|
schema: editorView === null || editorView === void 0 ? void 0 : editorView.state.schema,
|
|
77
79
|
numberOfButtons: numberOfButtons || 0,
|
|
78
80
|
formatMessage: formatMessage
|
|
@@ -267,6 +267,7 @@ export var getToolbarComponents = function getToolbarComponents(_ref) {
|
|
|
267
267
|
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
268
268
|
expandEnabled: options.allowExpand,
|
|
269
269
|
insertMenuItems: options.insertMenuItems,
|
|
270
|
+
itemFilter: options.itemFilter,
|
|
270
271
|
numberOfButtons: 0
|
|
271
272
|
});
|
|
272
273
|
};
|
|
@@ -66,6 +66,21 @@ export interface InsertBlockPluginOptions {
|
|
|
66
66
|
appearance?: EditorAppearance;
|
|
67
67
|
horizontalRuleEnabled?: boolean;
|
|
68
68
|
insertMenuItems?: any;
|
|
69
|
+
/**
|
|
70
|
+
* EDITOR-6558: Optional predicate for filtering insert-block items by
|
|
71
|
+
* `value.name` before they're rendered in the toolbar / dropdown /
|
|
72
|
+
* element browser. Items returning `false` are hidden.
|
|
73
|
+
*
|
|
74
|
+
* Used by Markdown Mode (gated by the `cc-markdown-mode` experiment in
|
|
75
|
+
* Confluence) to allowlist only items whose corresponding node/mark
|
|
76
|
+
* types have a clean GFM round-trip. Currently applied to the main
|
|
77
|
+
* toolbar insert surfaces (`ToolbarInsertBlock`, `useInsertButtonState`).
|
|
78
|
+
*/
|
|
79
|
+
itemFilter?: (item: {
|
|
80
|
+
value: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
}) => boolean;
|
|
69
84
|
nativeStatusSupported?: boolean;
|
|
70
85
|
/**
|
|
71
86
|
* To hide the element browser "view more" button in the
|
|
@@ -23,6 +23,8 @@ export interface CreateItemsConfig {
|
|
|
23
23
|
isEditorOffline?: boolean;
|
|
24
24
|
isNewMenuEnabled?: boolean;
|
|
25
25
|
isTypeAheadAllowed?: boolean;
|
|
26
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
27
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
26
28
|
layoutSectionEnabled?: boolean;
|
|
27
29
|
linkDisabled?: boolean;
|
|
28
30
|
linkSupported?: boolean;
|
|
@@ -30,6 +30,8 @@ export interface Props {
|
|
|
30
30
|
isEditorOffline?: boolean;
|
|
31
31
|
isReducedSpacing: boolean;
|
|
32
32
|
isTypeAheadAllowed?: boolean;
|
|
33
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
34
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
33
35
|
layoutSectionEnabled?: boolean;
|
|
34
36
|
linkDisabled?: boolean;
|
|
35
37
|
linkSupported?: boolean;
|
|
@@ -11,6 +11,8 @@ type InsertButtonProps = {
|
|
|
11
11
|
horizontalRuleEnabled?: boolean;
|
|
12
12
|
insertMenuItems?: MenuItem[];
|
|
13
13
|
isFullPageAppearance?: boolean;
|
|
14
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
15
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
14
16
|
nativeStatusSupported?: boolean;
|
|
15
17
|
numberOfButtons?: number;
|
|
16
18
|
onInsertBlockType?: (name: string) => Command;
|
|
@@ -18,5 +20,5 @@ type InsertButtonProps = {
|
|
|
18
20
|
tableSelectorSupported?: boolean;
|
|
19
21
|
toolbarConfig?: ToolbarInsertBlockButtonsConfig;
|
|
20
22
|
};
|
|
21
|
-
export declare const InsertButton: ({ api, breakpoint, showElementBrowserLink, isFullPageAppearance, tableSelectorSupported, nativeStatusSupported, horizontalRuleEnabled, expandEnabled, insertMenuItems, numberOfButtons, onInsertBlockType, toolbarConfig, }: InsertButtonProps) => React.JSX.Element | null;
|
|
23
|
+
export declare const InsertButton: ({ api, breakpoint, showElementBrowserLink, isFullPageAppearance, tableSelectorSupported, nativeStatusSupported, horizontalRuleEnabled, expandEnabled, insertMenuItems, itemFilter, numberOfButtons, onInsertBlockType, toolbarConfig, }: InsertButtonProps) => React.JSX.Element | null;
|
|
22
24
|
export {};
|
|
@@ -13,6 +13,8 @@ interface UseInsertButtonStateProps {
|
|
|
13
13
|
expandEnabled?: boolean;
|
|
14
14
|
horizontalRuleEnabled?: boolean;
|
|
15
15
|
insertMenuItems?: MenuItem[];
|
|
16
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
17
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
16
18
|
nativeStatusSupported?: boolean;
|
|
17
19
|
numberOfButtons?: number;
|
|
18
20
|
showElementBrowserLink?: boolean;
|
|
@@ -24,5 +26,5 @@ export interface InsertButtonState {
|
|
|
24
26
|
emojiProvider?: EmojiProvider;
|
|
25
27
|
isTypeAheadAllowed?: boolean;
|
|
26
28
|
}
|
|
27
|
-
export declare const useInsertButtonState: ({ api, breakpoint, editorView, horizontalRuleEnabled, insertMenuItems, nativeStatusSupported, numberOfButtons, tableSelectorSupported, expandEnabled, showElementBrowserLink, toolbarConfig, }: UseInsertButtonStateProps) => InsertButtonState;
|
|
29
|
+
export declare const useInsertButtonState: ({ api, breakpoint, editorView, horizontalRuleEnabled, insertMenuItems, itemFilter, nativeStatusSupported, numberOfButtons, tableSelectorSupported, expandEnabled, showElementBrowserLink, toolbarConfig, }: UseInsertButtonStateProps) => InsertButtonState;
|
|
28
30
|
export {};
|
|
@@ -66,6 +66,21 @@ export interface InsertBlockPluginOptions {
|
|
|
66
66
|
appearance?: EditorAppearance;
|
|
67
67
|
horizontalRuleEnabled?: boolean;
|
|
68
68
|
insertMenuItems?: any;
|
|
69
|
+
/**
|
|
70
|
+
* EDITOR-6558: Optional predicate for filtering insert-block items by
|
|
71
|
+
* `value.name` before they're rendered in the toolbar / dropdown /
|
|
72
|
+
* element browser. Items returning `false` are hidden.
|
|
73
|
+
*
|
|
74
|
+
* Used by Markdown Mode (gated by the `cc-markdown-mode` experiment in
|
|
75
|
+
* Confluence) to allowlist only items whose corresponding node/mark
|
|
76
|
+
* types have a clean GFM round-trip. Currently applied to the main
|
|
77
|
+
* toolbar insert surfaces (`ToolbarInsertBlock`, `useInsertButtonState`).
|
|
78
|
+
*/
|
|
79
|
+
itemFilter?: (item: {
|
|
80
|
+
value: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
}) => boolean;
|
|
69
84
|
nativeStatusSupported?: boolean;
|
|
70
85
|
/**
|
|
71
86
|
* To hide the element browser "view more" button in the
|
|
@@ -23,6 +23,8 @@ export interface CreateItemsConfig {
|
|
|
23
23
|
isEditorOffline?: boolean;
|
|
24
24
|
isNewMenuEnabled?: boolean;
|
|
25
25
|
isTypeAheadAllowed?: boolean;
|
|
26
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
27
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
26
28
|
layoutSectionEnabled?: boolean;
|
|
27
29
|
linkDisabled?: boolean;
|
|
28
30
|
linkSupported?: boolean;
|
|
@@ -30,6 +30,8 @@ export interface Props {
|
|
|
30
30
|
isEditorOffline?: boolean;
|
|
31
31
|
isReducedSpacing: boolean;
|
|
32
32
|
isTypeAheadAllowed?: boolean;
|
|
33
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
34
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
33
35
|
layoutSectionEnabled?: boolean;
|
|
34
36
|
linkDisabled?: boolean;
|
|
35
37
|
linkSupported?: boolean;
|
|
@@ -11,6 +11,8 @@ type InsertButtonProps = {
|
|
|
11
11
|
horizontalRuleEnabled?: boolean;
|
|
12
12
|
insertMenuItems?: MenuItem[];
|
|
13
13
|
isFullPageAppearance?: boolean;
|
|
14
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
15
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
14
16
|
nativeStatusSupported?: boolean;
|
|
15
17
|
numberOfButtons?: number;
|
|
16
18
|
onInsertBlockType?: (name: string) => Command;
|
|
@@ -18,5 +20,5 @@ type InsertButtonProps = {
|
|
|
18
20
|
tableSelectorSupported?: boolean;
|
|
19
21
|
toolbarConfig?: ToolbarInsertBlockButtonsConfig;
|
|
20
22
|
};
|
|
21
|
-
export declare const InsertButton: ({ api, breakpoint, showElementBrowserLink, isFullPageAppearance, tableSelectorSupported, nativeStatusSupported, horizontalRuleEnabled, expandEnabled, insertMenuItems, numberOfButtons, onInsertBlockType, toolbarConfig, }: InsertButtonProps) => React.JSX.Element | null;
|
|
23
|
+
export declare const InsertButton: ({ api, breakpoint, showElementBrowserLink, isFullPageAppearance, tableSelectorSupported, nativeStatusSupported, horizontalRuleEnabled, expandEnabled, insertMenuItems, itemFilter, numberOfButtons, onInsertBlockType, toolbarConfig, }: InsertButtonProps) => React.JSX.Element | null;
|
|
22
24
|
export {};
|
|
@@ -13,6 +13,8 @@ interface UseInsertButtonStateProps {
|
|
|
13
13
|
expandEnabled?: boolean;
|
|
14
14
|
horizontalRuleEnabled?: boolean;
|
|
15
15
|
insertMenuItems?: MenuItem[];
|
|
16
|
+
/** @see InsertBlockPluginOptions.itemFilter */
|
|
17
|
+
itemFilter?: (item: MenuItem) => boolean;
|
|
16
18
|
nativeStatusSupported?: boolean;
|
|
17
19
|
numberOfButtons?: number;
|
|
18
20
|
showElementBrowserLink?: boolean;
|
|
@@ -24,5 +26,5 @@ export interface InsertButtonState {
|
|
|
24
26
|
emojiProvider?: EmojiProvider;
|
|
25
27
|
isTypeAheadAllowed?: boolean;
|
|
26
28
|
}
|
|
27
|
-
export declare const useInsertButtonState: ({ api, breakpoint, editorView, horizontalRuleEnabled, insertMenuItems, nativeStatusSupported, numberOfButtons, tableSelectorSupported, expandEnabled, showElementBrowserLink, toolbarConfig, }: UseInsertButtonStateProps) => InsertButtonState;
|
|
29
|
+
export declare const useInsertButtonState: ({ api, breakpoint, editorView, horizontalRuleEnabled, insertMenuItems, itemFilter, nativeStatusSupported, numberOfButtons, tableSelectorSupported, expandEnabled, showElementBrowserLink, toolbarConfig, }: UseInsertButtonStateProps) => InsertButtonState;
|
|
28
30
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-insert-block",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Insert block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@atlaskit/editor-plugin-panel": "^12.0.0",
|
|
50
50
|
"@atlaskit/editor-plugin-placeholder-text": "^11.0.0",
|
|
51
51
|
"@atlaskit/editor-plugin-primary-toolbar": "^11.0.0",
|
|
52
|
-
"@atlaskit/editor-plugin-quick-insert": "^10.
|
|
52
|
+
"@atlaskit/editor-plugin-quick-insert": "^10.2.0",
|
|
53
53
|
"@atlaskit/editor-plugin-rule": "^10.0.0",
|
|
54
54
|
"@atlaskit/editor-plugin-status": "^11.0.0",
|
|
55
55
|
"@atlaskit/editor-plugin-table": "^22.2.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@atlaskit/icon": "^34.3.0",
|
|
65
65
|
"@atlaskit/icon-lab": "^6.6.0",
|
|
66
66
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
67
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
67
|
+
"@atlaskit/tmp-editor-statsig": "^70.2.0",
|
|
68
68
|
"@atlaskit/tokens": "^13.0.0",
|
|
69
69
|
"@babel/runtime": "^7.0.0",
|
|
70
70
|
"@emotion/react": "^11.7.1",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"react-virtualized": "^9.22.6"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@atlaskit/editor-common": "^114.
|
|
77
|
+
"@atlaskit/editor-common": "^114.11.0",
|
|
78
78
|
"react": "^18.2.0",
|
|
79
79
|
"react-dom": "^18.2.0",
|
|
80
80
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|