@atlaskit/editor-plugin-insert-block 0.1.0 → 0.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/.eslintrc.js +26 -0
- package/CHANGELOG.md +32 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/plugin.js +164 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +166 -0
- package/dist/cjs/ui/ElementBrowser/types.js +5 -0
- package/dist/cjs/ui/ToolbarInsertBlock/block-insert-element-browser.js +42 -0
- package/dist/cjs/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +42 -0
- package/dist/cjs/ui/ToolbarInsertBlock/block-insert-menu.js +66 -0
- package/dist/cjs/ui/ToolbarInsertBlock/create-items.js +217 -0
- package/dist/cjs/ui/ToolbarInsertBlock/dropdown-button.js +52 -0
- package/dist/cjs/ui/ToolbarInsertBlock/index.js +570 -0
- package/dist/cjs/ui/ToolbarInsertBlock/item.js +252 -0
- package/dist/cjs/ui/ToolbarInsertBlock/messages.js +12 -0
- package/dist/cjs/ui/ToolbarInsertBlock/shallow-equals.js +20 -0
- package/dist/cjs/ui/ToolbarInsertBlock/sort-items.js +30 -0
- package/dist/cjs/ui/ToolbarInsertBlock/styles.js +11 -0
- package/dist/cjs/ui/ToolbarInsertBlock/types.js +5 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugin.js +158 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +153 -0
- package/dist/es2019/ui/ElementBrowser/types.js +1 -0
- package/dist/es2019/ui/ToolbarInsertBlock/block-insert-element-browser.js +35 -0
- package/dist/es2019/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +35 -0
- package/dist/es2019/ui/ToolbarInsertBlock/block-insert-menu.js +59 -0
- package/dist/es2019/ui/ToolbarInsertBlock/create-items.js +198 -0
- package/dist/es2019/ui/ToolbarInsertBlock/dropdown-button.js +39 -0
- package/dist/es2019/ui/ToolbarInsertBlock/index.js +562 -0
- package/dist/es2019/ui/ToolbarInsertBlock/item.js +202 -0
- package/dist/es2019/ui/ToolbarInsertBlock/messages.js +1 -0
- package/dist/es2019/ui/ToolbarInsertBlock/shallow-equals.js +8 -0
- package/dist/es2019/ui/ToolbarInsertBlock/sort-items.js +22 -0
- package/dist/es2019/ui/ToolbarInsertBlock/styles.js +16 -0
- package/dist/es2019/ui/ToolbarInsertBlock/types.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugin.js +157 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +160 -0
- package/dist/esm/ui/ElementBrowser/types.js +1 -0
- package/dist/esm/ui/ToolbarInsertBlock/block-insert-element-browser.js +35 -0
- package/dist/esm/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +35 -0
- package/dist/esm/ui/ToolbarInsertBlock/block-insert-menu.js +59 -0
- package/dist/esm/ui/ToolbarInsertBlock/create-items.js +210 -0
- package/dist/esm/ui/ToolbarInsertBlock/dropdown-button.js +44 -0
- package/dist/esm/ui/ToolbarInsertBlock/index.js +564 -0
- package/dist/esm/ui/ToolbarInsertBlock/item.js +244 -0
- package/dist/esm/ui/ToolbarInsertBlock/messages.js +1 -0
- package/dist/esm/ui/ToolbarInsertBlock/shallow-equals.js +13 -0
- package/dist/esm/ui/ToolbarInsertBlock/sort-items.js +24 -0
- package/dist/esm/ui/ToolbarInsertBlock/styles.js +4 -0
- package/dist/esm/ui/ToolbarInsertBlock/types.js +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/plugin.d.ts +16 -0
- package/dist/types/types.d.ts +45 -0
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +4 -0
- package/dist/types/ui/ElementBrowser/types.d.ts +22 -0
- package/dist/types/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +28 -0
- package/dist/types/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +21 -0
- package/dist/types/ui/ToolbarInsertBlock/block-insert-menu.d.ts +33 -0
- package/dist/types/ui/ToolbarInsertBlock/create-items.d.ts +39 -0
- package/dist/types/ui/ToolbarInsertBlock/dropdown-button.d.ts +16 -0
- package/dist/types/ui/ToolbarInsertBlock/index.d.ts +46 -0
- package/dist/types/ui/ToolbarInsertBlock/item.d.ts +35 -0
- package/dist/types/ui/ToolbarInsertBlock/messages.d.ts +1 -0
- package/dist/types/ui/ToolbarInsertBlock/shallow-equals.d.ts +1 -0
- package/dist/types/ui/ToolbarInsertBlock/sort-items.d.ts +2 -0
- package/dist/types/ui/ToolbarInsertBlock/styles.d.ts +1 -0
- package/dist/types/ui/ToolbarInsertBlock/types.d.ts +59 -0
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/plugin.d.ts +16 -0
- package/dist/types-ts4.5/types.d.ts +45 -0
- package/dist/types-ts4.5/ui/ElementBrowser/InsertMenu.d.ts +4 -0
- package/dist/types-ts4.5/ui/ElementBrowser/types.d.ts +22 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +28 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +21 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/block-insert-menu.d.ts +33 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/create-items.d.ts +42 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/dropdown-button.d.ts +16 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/index.d.ts +46 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/item.d.ts +35 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/messages.d.ts +1 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/shallow-equals.d.ts +1 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/sort-items.d.ts +2 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/styles.d.ts +1 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/types.d.ts +59 -0
- package/package.json +37 -9
- package/report.api.md +82 -1
- package/tmp/api-report-tmp.d.ts +76 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popup } from '@atlaskit/editor-common/ui';
|
|
3
|
+
import InsertMenu from '../ElementBrowser/InsertMenu';
|
|
4
|
+
import { DropDownButton } from './dropdown-button';
|
|
5
|
+
export const BlockInsertElementBrowser = props => {
|
|
6
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.open && /*#__PURE__*/React.createElement(Popup, {
|
|
7
|
+
target: props.plusButtonRef,
|
|
8
|
+
fitHeight: 500,
|
|
9
|
+
fitWidth: 350,
|
|
10
|
+
offset: [0, 3],
|
|
11
|
+
mountTo: props.popupsMountPoint,
|
|
12
|
+
boundariesElement: props.popupsBoundariesElement,
|
|
13
|
+
scrollableElement: props.popupsScrollableElement,
|
|
14
|
+
preventOverflow: true,
|
|
15
|
+
alignX: "right"
|
|
16
|
+
}, /*#__PURE__*/React.createElement(InsertMenu, {
|
|
17
|
+
editorView: props.editorView,
|
|
18
|
+
dropdownItems: props.items,
|
|
19
|
+
onInsert: props.onInsert,
|
|
20
|
+
toggleVisiblity: props.togglePlusMenuVisibility,
|
|
21
|
+
showElementBrowserLink: props.showElementBrowserLink,
|
|
22
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
23
|
+
})), /*#__PURE__*/React.createElement(DropDownButton, {
|
|
24
|
+
"aria-expanded": props.open,
|
|
25
|
+
"aria-haspopup": true,
|
|
26
|
+
handleRef: props.onRef,
|
|
27
|
+
selected: props.open,
|
|
28
|
+
disabled: props.disabled,
|
|
29
|
+
onClick: props.onClick,
|
|
30
|
+
onKeyDown: props.onKeyDown,
|
|
31
|
+
spacing: props.spacing,
|
|
32
|
+
label: props.label,
|
|
33
|
+
"aria-keyshortcuts": "/"
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
3
|
+
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { DropDownButton } from './dropdown-button';
|
|
5
|
+
export const BlockInsertMenuLegacy = props => {
|
|
6
|
+
const {
|
|
7
|
+
items
|
|
8
|
+
} = props;
|
|
9
|
+
const dropdownItems = React.useMemo(() => [{
|
|
10
|
+
items
|
|
11
|
+
}], [items]);
|
|
12
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
13
|
+
items: dropdownItems,
|
|
14
|
+
onItemActivated: props.onItemActivated,
|
|
15
|
+
onOpenChange: props.onOpenChange,
|
|
16
|
+
mountTo: props.popupsMountPoint,
|
|
17
|
+
boundariesElement: props.popupsBoundariesElement,
|
|
18
|
+
scrollableElement: props.popupsScrollableElement,
|
|
19
|
+
isOpen: props.open,
|
|
20
|
+
fitHeight: 188,
|
|
21
|
+
fitWidth: 175,
|
|
22
|
+
zIndex: akEditorMenuZIndex
|
|
23
|
+
}, /*#__PURE__*/React.createElement(DropDownButton, {
|
|
24
|
+
"aria-expanded": props.open,
|
|
25
|
+
"aria-haspopup": true,
|
|
26
|
+
handleRef: props.onRef,
|
|
27
|
+
selected: props.open,
|
|
28
|
+
disabled: props.disabled,
|
|
29
|
+
onClick: props.onClick,
|
|
30
|
+
onKeyDown: props.onKeyDown,
|
|
31
|
+
spacing: props.spacing,
|
|
32
|
+
label: props.label,
|
|
33
|
+
"aria-keyshortcuts": "/"
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BlockInsertElementBrowser } from './block-insert-element-browser';
|
|
3
|
+
import { BlockInsertMenuLegacy } from './block-insert-menu-legacy';
|
|
4
|
+
import { DropDownButton } from './dropdown-button';
|
|
5
|
+
export const BlockInsertMenu = props => {
|
|
6
|
+
if (props.items.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (props.disabled) {
|
|
10
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DropDownButton, {
|
|
11
|
+
"aria-expanded": props.open,
|
|
12
|
+
"aria-haspopup": true,
|
|
13
|
+
handleRef: props.onRef,
|
|
14
|
+
selected: props.open,
|
|
15
|
+
disabled: props.disabled,
|
|
16
|
+
onClick: props.onClick,
|
|
17
|
+
onKeyDown: props.onKeyDown,
|
|
18
|
+
spacing: props.spacing,
|
|
19
|
+
label: props.label,
|
|
20
|
+
"aria-keyshortcuts": "/"
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
if (props.replacePlusMenuWithElementBrowser) {
|
|
24
|
+
return /*#__PURE__*/React.createElement(BlockInsertElementBrowser, {
|
|
25
|
+
disabled: props.disabled,
|
|
26
|
+
editorView: props.editorView,
|
|
27
|
+
items: props.items,
|
|
28
|
+
label: props.label,
|
|
29
|
+
onClick: props.onClick,
|
|
30
|
+
onKeyDown: props.onKeyDown,
|
|
31
|
+
onInsert: props.onInsert,
|
|
32
|
+
onRef: props.onPlusButtonRef,
|
|
33
|
+
open: props.open,
|
|
34
|
+
plusButtonRef: props.plusButtonRef,
|
|
35
|
+
popupsBoundariesElement: props.popupsBoundariesElement,
|
|
36
|
+
popupsMountPoint: props.popupsMountPoint,
|
|
37
|
+
popupsScrollableElement: props.popupsScrollableElement,
|
|
38
|
+
spacing: props.spacing,
|
|
39
|
+
togglePlusMenuVisibility: props.togglePlusMenuVisibility,
|
|
40
|
+
showElementBrowserLink: props.showElementBrowserLink,
|
|
41
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return /*#__PURE__*/React.createElement(BlockInsertMenuLegacy, {
|
|
45
|
+
disabled: props.disabled,
|
|
46
|
+
items: props.items,
|
|
47
|
+
label: props.label,
|
|
48
|
+
onClick: props.onClick,
|
|
49
|
+
onKeyDown: props.onKeyDown,
|
|
50
|
+
onItemActivated: props.onItemActivated,
|
|
51
|
+
onOpenChange: props.onOpenChange,
|
|
52
|
+
onRef: props.onRef,
|
|
53
|
+
open: props.open,
|
|
54
|
+
popupsBoundariesElement: props.popupsBoundariesElement,
|
|
55
|
+
popupsMountPoint: props.popupsMountPoint,
|
|
56
|
+
popupsScrollableElement: props.popupsScrollableElement,
|
|
57
|
+
spacing: props.spacing
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import memoize from 'lodash/memoize';
|
|
3
|
+
import memoizeOne from 'memoize-one';
|
|
4
|
+
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { action, blockquote, codeblock, date, decision, emoji, expand, horizontalrule, imageUpload, layout, link, media, mention, more, panel, placeholder, status, table } from './item';
|
|
7
|
+
import { messages } from './messages';
|
|
8
|
+
import { shallowEquals } from './shallow-equals';
|
|
9
|
+
import { sortItems } from './sort-items';
|
|
10
|
+
const buttonToItem = memoize(button => ({
|
|
11
|
+
...button,
|
|
12
|
+
title: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
13
|
+
description: button.content,
|
|
14
|
+
shortcutOverride: button.shortcut
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
17
|
+
const buttonToDropdownItem = memoizeOne(title => memoize(button => ({
|
|
18
|
+
...button,
|
|
19
|
+
title: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
20
|
+
description: title,
|
|
21
|
+
shortcutOverride: "/"
|
|
22
|
+
})
|
|
23
|
+
})));
|
|
24
|
+
const createInsertBlockItems = config => {
|
|
25
|
+
const {
|
|
26
|
+
isTypeAheadAllowed,
|
|
27
|
+
tableSupported,
|
|
28
|
+
mediaUploadsEnabled,
|
|
29
|
+
mediaSupported,
|
|
30
|
+
imageUploadSupported,
|
|
31
|
+
imageUploadEnabled,
|
|
32
|
+
mentionsSupported,
|
|
33
|
+
mentionsDisabled,
|
|
34
|
+
availableWrapperBlockTypes,
|
|
35
|
+
actionSupported,
|
|
36
|
+
decisionSupported,
|
|
37
|
+
showElementBrowserLink,
|
|
38
|
+
linkSupported,
|
|
39
|
+
linkDisabled,
|
|
40
|
+
emojiDisabled,
|
|
41
|
+
emojiProvider,
|
|
42
|
+
nativeStatusSupported,
|
|
43
|
+
insertMenuItems,
|
|
44
|
+
dateEnabled,
|
|
45
|
+
placeholderTextEnabled,
|
|
46
|
+
horizontalRuleEnabled,
|
|
47
|
+
layoutSectionEnabled,
|
|
48
|
+
expandEnabled,
|
|
49
|
+
numberOfButtons,
|
|
50
|
+
schema,
|
|
51
|
+
formatMessage,
|
|
52
|
+
isNewMenuEnabled
|
|
53
|
+
} = config;
|
|
54
|
+
const items = [];
|
|
55
|
+
if (actionSupported) {
|
|
56
|
+
items.push(action({
|
|
57
|
+
content: formatMessage(messages.action),
|
|
58
|
+
tooltipDescription: formatMessage(messages.actionDescription),
|
|
59
|
+
disabled: false
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
if (linkSupported) {
|
|
63
|
+
items.push(link({
|
|
64
|
+
content: formatMessage(messages.link),
|
|
65
|
+
tooltipDescription: formatMessage(messages.linkDescription),
|
|
66
|
+
disabled: !!linkDisabled,
|
|
67
|
+
'aria-haspopup': 'dialog'
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
if (mediaSupported && mediaUploadsEnabled) {
|
|
71
|
+
items.push(media({
|
|
72
|
+
content: formatMessage(messages.addMediaFiles),
|
|
73
|
+
tooltipDescription: formatMessage(messages.mediaFilesDescription),
|
|
74
|
+
disabled: false
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
if (imageUploadSupported) {
|
|
78
|
+
items.push(imageUpload({
|
|
79
|
+
content: formatMessage(messages.image),
|
|
80
|
+
disabled: !imageUploadEnabled
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
if (mentionsSupported) {
|
|
84
|
+
items.push(mention({
|
|
85
|
+
content: formatMessage(messages.mention),
|
|
86
|
+
tooltipDescription: formatMessage(messages.mentionDescription),
|
|
87
|
+
disabled: !isTypeAheadAllowed || !!mentionsDisabled,
|
|
88
|
+
'aria-haspopup': 'listbox'
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
if (emojiProvider) {
|
|
92
|
+
items.push(emoji({
|
|
93
|
+
content: formatMessage(messages.emoji),
|
|
94
|
+
tooltipDescription: formatMessage(messages.emojiDescription),
|
|
95
|
+
disabled: emojiDisabled || !isTypeAheadAllowed,
|
|
96
|
+
'aria-haspopup': 'dialog'
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
if (tableSupported) {
|
|
100
|
+
items.push(table({
|
|
101
|
+
content: formatMessage(messages.table),
|
|
102
|
+
tooltipDescription: formatMessage(messages.tableDescription),
|
|
103
|
+
disabled: false
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
if (layoutSectionEnabled) {
|
|
107
|
+
const labelColumns = formatMessage(messages.columns);
|
|
108
|
+
items.push(layout({
|
|
109
|
+
content: labelColumns,
|
|
110
|
+
tooltipDescription: formatMessage(messages.columnsDescription),
|
|
111
|
+
disabled: false
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
const blockTypes = availableWrapperBlockTypes || [];
|
|
115
|
+
const codeblockData = blockTypes.find(type => type.name === 'codeblock');
|
|
116
|
+
const panelData = blockTypes.find(type => type.name === 'panel');
|
|
117
|
+
const blockquoteData = blockTypes.find(type => type.name === 'blockquote');
|
|
118
|
+
if (codeblockData) {
|
|
119
|
+
items.push(codeblock({
|
|
120
|
+
content: formatMessage(codeblockData.title),
|
|
121
|
+
tooltipDescription: formatMessage(blockTypeMessages.codeblockDescription),
|
|
122
|
+
disabled: false,
|
|
123
|
+
shortcut: '```'
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
if (panelData) {
|
|
127
|
+
items.push(panel({
|
|
128
|
+
content: formatMessage(panelData.title),
|
|
129
|
+
tooltipDescription: formatMessage(blockTypeMessages.infoPanelDescription),
|
|
130
|
+
disabled: false
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
if (blockquoteData) {
|
|
134
|
+
items.push(blockquote({
|
|
135
|
+
content: formatMessage(blockquoteData.title),
|
|
136
|
+
tooltipDescription: formatMessage(blockTypeMessages.blockquoteDescription),
|
|
137
|
+
disabled: false,
|
|
138
|
+
shortcut: '>'
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
if (decisionSupported) {
|
|
142
|
+
items.push(decision({
|
|
143
|
+
content: formatMessage(messages.decision),
|
|
144
|
+
tooltipDescription: formatMessage(messages.decisionDescription),
|
|
145
|
+
disabled: false
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
if (horizontalRuleEnabled && schema.nodes.rule) {
|
|
149
|
+
items.push(horizontalrule({
|
|
150
|
+
content: formatMessage(messages.horizontalRule),
|
|
151
|
+
tooltipDescription: formatMessage(messages.horizontalRuleDescription),
|
|
152
|
+
disabled: false
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
if (expandEnabled && schema.nodes.expand) {
|
|
156
|
+
items.push(expand({
|
|
157
|
+
content: formatMessage(messages.expand),
|
|
158
|
+
tooltipDescription: formatMessage(messages.expandDescription),
|
|
159
|
+
disabled: false
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
if (dateEnabled) {
|
|
163
|
+
const labelDate = formatMessage(messages.date);
|
|
164
|
+
items.push(date({
|
|
165
|
+
content: labelDate,
|
|
166
|
+
tooltipDescription: formatMessage(messages.dateDescription),
|
|
167
|
+
disabled: false
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
if (placeholderTextEnabled) {
|
|
171
|
+
items.push(placeholder({
|
|
172
|
+
content: formatMessage(messages.placeholderText),
|
|
173
|
+
disabled: false
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
if (nativeStatusSupported) {
|
|
177
|
+
const labelStatus = formatMessage(messages.status);
|
|
178
|
+
items.push(status({
|
|
179
|
+
content: labelStatus,
|
|
180
|
+
tooltipDescription: formatMessage(messages.statusDescription),
|
|
181
|
+
disabled: false
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
if (insertMenuItems) {
|
|
185
|
+
items.push(...insertMenuItems);
|
|
186
|
+
}
|
|
187
|
+
if (showElementBrowserLink) {
|
|
188
|
+
items.push(more({
|
|
189
|
+
content: formatMessage(messages.viewMore),
|
|
190
|
+
disabled: false
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
const buttonItems = items.slice(0, numberOfButtons).map(buttonToItem);
|
|
194
|
+
const remainingItems = items.slice(numberOfButtons);
|
|
195
|
+
const dropdownItems = (!isNewMenuEnabled ? sortItems(remainingItems) : remainingItems).map(buttonToDropdownItem(formatMessage(messages.insertMenu)));
|
|
196
|
+
return [buttonItems, dropdownItems];
|
|
197
|
+
};
|
|
198
|
+
export const createItems = memoizeOne(createInsertBlockItems, shallowEquals);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
7
|
+
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
8
|
+
import AddIcon from '@atlaskit/icon/glyph/editor/add';
|
|
9
|
+
import { triggerWrapper } from './styles';
|
|
10
|
+
const DropDownButtonIcon = /*#__PURE__*/React.memo(props =>
|
|
11
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
12
|
+
jsx("span", {
|
|
13
|
+
css: triggerWrapper
|
|
14
|
+
}, jsx(AddIcon, {
|
|
15
|
+
label: props.label
|
|
16
|
+
}), jsx("span", {
|
|
17
|
+
css: expandIconWrapperStyle
|
|
18
|
+
}, jsx(ExpandIcon, {
|
|
19
|
+
label: ""
|
|
20
|
+
}))));
|
|
21
|
+
export const DropDownButton = /*#__PURE__*/React.memo(props => jsx(ToolbarButton, {
|
|
22
|
+
ref: props.handleRef,
|
|
23
|
+
selected: props.selected,
|
|
24
|
+
disabled: props.disabled,
|
|
25
|
+
onClick: props.onClick,
|
|
26
|
+
onKeyDown: props.onKeyDown,
|
|
27
|
+
spacing: props.spacing,
|
|
28
|
+
"aria-expanded": props['aria-expanded'],
|
|
29
|
+
"aria-haspopup": props['aria-haspopup'],
|
|
30
|
+
"aria-keyshortcuts": props['aria-keyshortcuts'],
|
|
31
|
+
"aria-label": `${props.label} /`,
|
|
32
|
+
iconBefore: jsx(DropDownButtonIcon, {
|
|
33
|
+
label: ""
|
|
34
|
+
}),
|
|
35
|
+
title: jsx(ToolTipContent, {
|
|
36
|
+
description: props.label,
|
|
37
|
+
shortcutOverride: "/"
|
|
38
|
+
})
|
|
39
|
+
}));
|