@atlaskit/editor-toolbar 0.3.0 → 0.3.2
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 +22 -0
- package/dist/cjs/index.js +42 -7
- package/dist/cjs/ui/ToolbarButton.compiled.css +1 -13
- package/dist/cjs/ui/ToolbarButton.js +2 -6
- package/dist/cjs/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/cjs/ui/ToolbarButtonGroup.js +17 -5
- package/dist/cjs/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/cjs/ui/ToolbarDropdownItem.js +1 -1
- package/dist/cjs/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/cjs/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/cjs/ui/ToolbarDropdownMenu.js +12 -6
- package/dist/cjs/ui/icons/EmojiIcon.js +13 -0
- package/dist/cjs/ui/icons/ImageIcon.js +13 -0
- package/dist/cjs/ui/icons/LayoutIcon.js +13 -0
- package/dist/cjs/ui/icons/MentionIcon.js +13 -0
- package/dist/cjs/ui/icons/TableIcon.js +13 -0
- package/dist/cjs/ui/icons/TaskIcon.js +13 -0
- package/dist/es2019/index.js +6 -1
- package/dist/es2019/ui/ToolbarButton.compiled.css +1 -13
- package/dist/es2019/ui/ToolbarButton.js +2 -6
- package/dist/es2019/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/es2019/ui/ToolbarButtonGroup.js +14 -3
- package/dist/es2019/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/es2019/ui/ToolbarDropdownItem.js +1 -1
- package/dist/es2019/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/es2019/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/es2019/ui/ToolbarDropdownMenu.js +11 -6
- package/dist/es2019/ui/icons/EmojiIcon.js +2 -0
- package/dist/es2019/ui/icons/ImageIcon.js +2 -0
- package/dist/es2019/ui/icons/LayoutIcon.js +2 -0
- package/dist/es2019/ui/icons/MentionIcon.js +2 -0
- package/dist/es2019/ui/icons/TableIcon.js +2 -0
- package/dist/es2019/ui/icons/TaskIcon.js +2 -0
- package/dist/esm/index.js +6 -1
- package/dist/esm/ui/ToolbarButton.compiled.css +1 -13
- package/dist/esm/ui/ToolbarButton.js +2 -6
- package/dist/esm/ui/ToolbarButtonGroup.compiled.css +7 -1
- package/dist/esm/ui/ToolbarButtonGroup.js +14 -3
- package/dist/esm/ui/ToolbarDropdownItem.compiled.css +4 -2
- package/dist/esm/ui/ToolbarDropdownItem.js +1 -1
- package/dist/esm/ui/ToolbarDropdownItemSection.js +7 -10
- package/dist/esm/ui/ToolbarDropdownMenu.compiled.css +1 -0
- package/dist/esm/ui/ToolbarDropdownMenu.js +12 -6
- package/dist/esm/ui/icons/EmojiIcon.js +2 -0
- package/dist/esm/ui/icons/ImageIcon.js +2 -0
- package/dist/esm/ui/icons/LayoutIcon.js +2 -0
- package/dist/esm/ui/icons/MentionIcon.js +2 -0
- package/dist/esm/ui/icons/TableIcon.js +2 -0
- package/dist/esm/ui/icons/TaskIcon.js +2 -0
- package/dist/types/index.d.ts +7 -2
- package/dist/types/types.d.ts +0 -1
- package/dist/types/ui/ToolbarButton.d.ts +0 -2
- package/dist/types/ui/ToolbarButtonGroup.d.ts +6 -2
- package/dist/types/ui/ToolbarDropdownItemSection.d.ts +3 -1
- package/dist/types/ui/ToolbarDropdownMenu.d.ts +9 -6
- package/dist/types/ui/ToolbarDropdownMenuContext.d.ts +1 -1
- package/dist/types/ui/ToolbarTooltip.d.ts +1 -1
- package/dist/types/ui/icons/EmojiIcon.d.ts +1 -0
- package/dist/types/ui/icons/ImageIcon.d.ts +1 -0
- package/dist/types/ui/icons/LayoutIcon.d.ts +1 -0
- package/dist/types/ui/icons/MentionIcon.d.ts +1 -0
- package/dist/types/ui/icons/TableIcon.d.ts +1 -0
- package/dist/types/ui/icons/TaskIcon.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +7 -2
- package/dist/types-ts4.5/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarButton.d.ts +0 -2
- package/dist/types-ts4.5/ui/ToolbarButtonGroup.d.ts +6 -2
- package/dist/types-ts4.5/ui/ToolbarDropdownItemSection.d.ts +3 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownMenu.d.ts +9 -6
- package/dist/types-ts4.5/ui/ToolbarDropdownMenuContext.d.ts +1 -1
- package/dist/types-ts4.5/ui/ToolbarTooltip.d.ts +1 -1
- package/dist/types-ts4.5/ui/icons/EmojiIcon.d.ts +1 -0
- package/dist/types-ts4.5/ui/icons/ImageIcon.d.ts +1 -0
- package/dist/types-ts4.5/ui/icons/LayoutIcon.d.ts +1 -0
- package/dist/types-ts4.5/ui/icons/MentionIcon.d.ts +1 -0
- package/dist/types-ts4.5/ui/icons/TableIcon.d.ts +1 -0
- package/dist/types-ts4.5/ui/icons/TaskIcon.d.ts +1 -0
- package/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +2 -12
- package/package.json +3 -3
- package/src/index.ts +7 -2
- package/src/types.ts +0 -1
- package/src/ui/ColorPalette/Color.tsx +64 -56
- package/src/ui/ToolbarButton.tsx +0 -28
- package/src/ui/ToolbarButtonGroup.tsx +42 -3
- package/src/ui/ToolbarDropdownItem.tsx +4 -2
- package/src/ui/ToolbarDropdownItemSection.tsx +13 -11
- package/src/ui/ToolbarDropdownMenu.tsx +28 -15
- package/src/ui/ToolbarDropdownMenuContext.tsx +4 -4
- package/src/ui/ToolbarTooltip.tsx +1 -1
- package/src/ui/icons/EmojiIcon.tsx +2 -0
- package/src/ui/icons/ImageIcon.tsx +2 -0
- package/src/ui/icons/LayoutIcon.tsx +2 -0
- package/src/ui/icons/MentionIcon.tsx +2 -0
- package/src/ui/icons/TableIcon.tsx +2 -0
- package/src/ui/icons/TaskIcon.tsx +2 -0
- package/dist/cjs/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/cjs/ui/ToolbarDropdownDivider.js +0 -20
- package/dist/cjs/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/es2019/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/es2019/ui/ToolbarDropdownDivider.js +0 -12
- package/dist/es2019/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/esm/ui/ToolbarDropdownDivider.compiled.css +0 -3
- package/dist/esm/ui/ToolbarDropdownDivider.js +0 -12
- package/dist/esm/ui/ToolbarDropdownItemSection.compiled.css +0 -2
- package/dist/types/ui/ToolbarDropdownDivider.d.ts +0 -1
- package/dist/types-ts4.5/ui/ToolbarDropdownDivider.d.ts +0 -1
- package/src/ui/ToolbarDropdownDivider.tsx +0 -20
|
@@ -162,16 +162,12 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
162
162
|
<ToolbarButton
|
|
163
163
|
iconBefore={<AIChatIcon label="Ask Rovo" />}
|
|
164
164
|
onClick={onClick('Ask Rovo')}
|
|
165
|
-
groupLocation="start"
|
|
166
165
|
isDisabled={isRovoDisabled}
|
|
167
166
|
>
|
|
168
167
|
Ask Rovo
|
|
169
168
|
</ToolbarButton>
|
|
170
169
|
</ToolbarTooltip>
|
|
171
|
-
<ToolbarDropdownMenu
|
|
172
|
-
iconBefore={<MoreItemsIcon label="More formatting" />}
|
|
173
|
-
groupLocation="end"
|
|
174
|
-
>
|
|
170
|
+
<ToolbarDropdownMenu iconBefore={<MoreItemsIcon label="More formatting" />}>
|
|
175
171
|
<ToolbarDropdownItemSection>
|
|
176
172
|
<ToolbarNestedDropdownMenu
|
|
177
173
|
elemBefore={<AIAdjustLengthIcon label="Adjust length" />}
|
|
@@ -380,16 +376,12 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
380
376
|
formatting.italic && !formatting.bold ? 'Italic' : 'Bold',
|
|
381
377
|
onToggleFormatting(formatting.italic && !formatting.bold ? 'italic' : 'bold'),
|
|
382
378
|
)}
|
|
383
|
-
groupLocation="start"
|
|
384
379
|
isSelected={formatting.bold || formatting.italic}
|
|
385
380
|
isDisabled={formatting.italic ? isItalicDisabled : isBoldDisabled}
|
|
386
381
|
ariaKeyshortcuts={formatting.italic && !formatting.bold ? '⌘I' : '⌘B'}
|
|
387
382
|
/>
|
|
388
383
|
</ToolbarTooltip>
|
|
389
|
-
<ToolbarDropdownMenu
|
|
390
|
-
iconBefore={<MoreItemsIcon label="More formatting" />}
|
|
391
|
-
groupLocation="end"
|
|
392
|
-
>
|
|
384
|
+
<ToolbarDropdownMenu iconBefore={<MoreItemsIcon label="More formatting" />}>
|
|
393
385
|
<ToolbarDropdownItemSection>
|
|
394
386
|
<ToolbarDropdownItem
|
|
395
387
|
elemBefore={<BoldIcon label="Bold" />}
|
|
@@ -471,7 +463,6 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
471
463
|
listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list',
|
|
472
464
|
onToggleListOrAlignment(listOrAlignment === 'numbered' ? 'numbered' : 'bulleted'),
|
|
473
465
|
)}
|
|
474
|
-
groupLocation="start"
|
|
475
466
|
isSelected={listOrAlignment !== 'none'}
|
|
476
467
|
isDisabled={
|
|
477
468
|
listOrAlignment === 'numbered' ? isNumberedListDisabled : isBulletedListDisabled
|
|
@@ -480,7 +471,6 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
480
471
|
</ToolbarTooltip>
|
|
481
472
|
<ToolbarDropdownMenu
|
|
482
473
|
iconBefore={<MoreItemsIcon label="Lists, indentation and alignment" />}
|
|
483
|
-
groupLocation="end"
|
|
484
474
|
>
|
|
485
475
|
<ToolbarDropdownItemSection>
|
|
486
476
|
<ToolbarDropdownItem
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"registry": "https://registry.npmjs.org/"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.2",
|
|
7
7
|
"description": "Common UI for Toolbars across the platform",
|
|
8
8
|
"atlassian": {
|
|
9
9
|
"team": "Editor: Jenga",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaskit/badge": "^18.1.0",
|
|
28
|
-
"@atlaskit/button": "^23.
|
|
28
|
+
"@atlaskit/button": "^23.4.0",
|
|
29
29
|
"@atlaskit/css": "^0.12.0",
|
|
30
30
|
"@atlaskit/dropdown-menu": "^16.3.0",
|
|
31
31
|
"@atlaskit/icon": "^27.12.0",
|
|
32
32
|
"@atlaskit/icon-lab": "^5.6.0",
|
|
33
|
-
"@atlaskit/logo": "^19.
|
|
33
|
+
"@atlaskit/logo": "^19.7.0",
|
|
34
34
|
"@atlaskit/popup": "^4.3.0",
|
|
35
35
|
"@atlaskit/primitives": "^14.11.0",
|
|
36
36
|
"@atlaskit/tokens": "^6.0.0",
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,6 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
|
|
|
9
9
|
export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
10
10
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
11
11
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
12
|
-
export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
|
|
13
12
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
14
13
|
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
15
14
|
|
|
@@ -58,9 +57,15 @@ export { AlignTextCenterIcon } from './ui/icons/AlignTextCenterIcon';
|
|
|
58
57
|
export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
|
|
59
58
|
export { IndentIcon } from './ui/icons/IndentIcon';
|
|
60
59
|
export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
60
|
+
export { EmojiIcon } from './ui/icons/EmojiIcon';
|
|
61
|
+
export { LayoutIcon } from './ui/icons/LayoutIcon';
|
|
62
|
+
export { ImageIcon } from './ui/icons/ImageIcon';
|
|
63
|
+
export { MentionIcon } from './ui/icons/MentionIcon';
|
|
64
|
+
export { TableIcon } from './ui/icons/TableIcon';
|
|
65
|
+
export { TaskIcon } from './ui/icons/TaskIcon';
|
|
61
66
|
|
|
62
67
|
export { default as ColorPalette } from './ui/ColorPalette';
|
|
63
68
|
|
|
64
|
-
export type { IconComponent
|
|
69
|
+
export type { IconComponent } from './types';
|
|
65
70
|
|
|
66
71
|
export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
|
package/src/types.ts
CHANGED
|
@@ -48,63 +48,71 @@ const buttonStyles = css({
|
|
|
48
48
|
* Individual color palette item component
|
|
49
49
|
* Displays a single color swatch with tooltip and selection state
|
|
50
50
|
*/
|
|
51
|
-
export const Color = memo<ColorProps>(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
export const Color = memo<ColorProps>(
|
|
52
|
+
({
|
|
53
|
+
autoFocus,
|
|
54
|
+
tabIndex,
|
|
55
|
+
value,
|
|
56
|
+
label,
|
|
57
|
+
isSelected,
|
|
58
|
+
borderColor,
|
|
59
|
+
checkMarkColor = token('color.icon.inverse', '#FFFFFF'),
|
|
60
|
+
hexToPaletteColor,
|
|
61
|
+
decorator,
|
|
62
|
+
onClick,
|
|
63
|
+
onKeyDown,
|
|
64
|
+
}) => {
|
|
65
|
+
const colorStyle = hexToPaletteColor ? hexToPaletteColor(value) : value;
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
const handleMouseDown = useCallback((e: React.MouseEvent) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
}, []);
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const handleClick = useCallback(
|
|
72
|
+
(e: React.MouseEvent) => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
onClick(value, label);
|
|
75
|
+
},
|
|
76
|
+
[onClick, value, label],
|
|
77
|
+
);
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const handleKeyDown = useCallback(
|
|
80
|
+
(e: React.KeyboardEvent) => {
|
|
81
|
+
if (!onKeyDown) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
onKeyDown(value, label, e);
|
|
86
|
+
},
|
|
87
|
+
[onKeyDown, value, label],
|
|
88
|
+
);
|
|
82
89
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
90
|
+
return (
|
|
91
|
+
<Tooltip content={label}>
|
|
92
|
+
<span css={buttonWrapperStyles}>
|
|
93
|
+
<button
|
|
94
|
+
type="button"
|
|
95
|
+
css={buttonStyles}
|
|
96
|
+
aria-label={label}
|
|
97
|
+
role="radio"
|
|
98
|
+
aria-checked={isSelected}
|
|
99
|
+
onClick={handleClick}
|
|
100
|
+
onKeyDown={handleKeyDown}
|
|
101
|
+
onMouseDown={handleMouseDown}
|
|
102
|
+
tabIndex={tabIndex}
|
|
103
|
+
style={{
|
|
104
|
+
backgroundColor: colorStyle || token('color.background.input', '#FFFFFF'),
|
|
105
|
+
border: `1px solid ${borderColor}`,
|
|
106
|
+
}}
|
|
107
|
+
autoFocus={autoFocus}
|
|
108
|
+
>
|
|
109
|
+
{!decorator && isSelected && (
|
|
110
|
+
<EditorDoneIcon LEGACY_primaryColor={checkMarkColor} label="" />
|
|
111
|
+
)}
|
|
112
|
+
{decorator}
|
|
113
|
+
</button>
|
|
114
|
+
</span>
|
|
115
|
+
</Tooltip>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
118
|
+
);
|
package/src/ui/ToolbarButton.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import { Pressable } from '@atlaskit/primitives/compiled';
|
|
|
6
6
|
import { token } from '@atlaskit/tokens';
|
|
7
7
|
|
|
8
8
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
9
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
10
9
|
|
|
11
10
|
const styles = cssMap({
|
|
12
11
|
button: {
|
|
@@ -50,28 +49,6 @@ const styles = cssMap({
|
|
|
50
49
|
backgroundColor: token('color.background.selected.pressed'),
|
|
51
50
|
},
|
|
52
51
|
},
|
|
53
|
-
groupStart: {
|
|
54
|
-
borderTopRightRadius: '0px',
|
|
55
|
-
borderBottomRightRadius: '0px',
|
|
56
|
-
justifyContent: 'flex-end',
|
|
57
|
-
paddingLeft: token('space.075'),
|
|
58
|
-
paddingRight: token('space.025'),
|
|
59
|
-
},
|
|
60
|
-
groupMiddle: {
|
|
61
|
-
borderTopLeftRadius: '0px',
|
|
62
|
-
borderBottomLeftRadius: '0px',
|
|
63
|
-
borderTopRightRadius: '0px',
|
|
64
|
-
borderBottomRightRadius: '0px',
|
|
65
|
-
paddingLeft: token('space.050'),
|
|
66
|
-
paddingRight: token('space.050'),
|
|
67
|
-
},
|
|
68
|
-
groupEnd: {
|
|
69
|
-
borderTopLeftRadius: '0px',
|
|
70
|
-
borderBottomLeftRadius: '0px',
|
|
71
|
-
justifyContent: 'flex-start',
|
|
72
|
-
paddingLeft: token('space.025'),
|
|
73
|
-
paddingRight: token('space.075'),
|
|
74
|
-
},
|
|
75
52
|
});
|
|
76
53
|
|
|
77
54
|
type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
@@ -82,7 +59,6 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
82
59
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
83
60
|
testId?: string;
|
|
84
61
|
iconBefore: React.ReactNode;
|
|
85
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
86
62
|
isDisabled?: boolean;
|
|
87
63
|
ariaKeyshortcuts?: string;
|
|
88
64
|
label?: string;
|
|
@@ -102,7 +78,6 @@ export const ToolbarButton = forwardRef(
|
|
|
102
78
|
onBlur,
|
|
103
79
|
onFocus,
|
|
104
80
|
testId,
|
|
105
|
-
groupLocation,
|
|
106
81
|
isDisabled,
|
|
107
82
|
ariaKeyshortcuts,
|
|
108
83
|
label,
|
|
@@ -117,9 +92,6 @@ export const ToolbarButton = forwardRef(
|
|
|
117
92
|
xcss={cx(
|
|
118
93
|
styles.button,
|
|
119
94
|
isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled,
|
|
120
|
-
groupLocation === 'start' && styles.groupStart,
|
|
121
|
-
groupLocation === 'middle' && styles.groupMiddle,
|
|
122
|
-
groupLocation === 'end' && styles.groupEnd,
|
|
123
95
|
)}
|
|
124
96
|
aria-pressed={isSelected}
|
|
125
97
|
aria-expanded={ariaExpanded}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { Children, Fragment, type ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
import { cssMap, jsx } from '@compiled/react';
|
|
2
8
|
|
|
3
|
-
import { cssMap } from '@atlaskit/css';
|
|
4
9
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
10
|
+
import { token } from '@atlaskit/tokens';
|
|
5
11
|
|
|
6
12
|
const styles = cssMap({
|
|
7
13
|
container: {
|
|
8
14
|
display: 'flex',
|
|
9
15
|
},
|
|
16
|
+
firstChild: {
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
18
|
+
button: {
|
|
19
|
+
borderTopRightRadius: 0,
|
|
20
|
+
borderBottomRightRadius: 0,
|
|
21
|
+
paddingInline: token('space.050'),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
lastChild: {
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
26
|
+
button: {
|
|
27
|
+
borderTopLeftRadius: 0,
|
|
28
|
+
borderBottomLeftRadius: 0,
|
|
29
|
+
paddingInline: token('space.075'),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
10
32
|
});
|
|
11
33
|
|
|
12
34
|
type ToolbarButtonGroupProps = {
|
|
@@ -14,5 +36,22 @@ type ToolbarButtonGroupProps = {
|
|
|
14
36
|
};
|
|
15
37
|
|
|
16
38
|
export const ToolbarButtonGroup = ({ children }: ToolbarButtonGroupProps) => {
|
|
17
|
-
|
|
39
|
+
const items = Children.toArray(children);
|
|
40
|
+
const FirstChild = items.at(0);
|
|
41
|
+
const LastChild = items.at(-1);
|
|
42
|
+
const middleChildren = items.slice(1, -1);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Box xcss={styles.container}>
|
|
46
|
+
{items.length <= 1 ? (
|
|
47
|
+
children
|
|
48
|
+
) : (
|
|
49
|
+
<Fragment>
|
|
50
|
+
<div css={styles.firstChild}>{FirstChild}</div>
|
|
51
|
+
{middleChildren}
|
|
52
|
+
<div css={styles.lastChild}>{LastChild}</div>
|
|
53
|
+
</Fragment>
|
|
54
|
+
)}
|
|
55
|
+
</Box>
|
|
56
|
+
);
|
|
18
57
|
};
|
|
@@ -17,12 +17,14 @@ type TextStyle =
|
|
|
17
17
|
|
|
18
18
|
const styles = cssMap({
|
|
19
19
|
toolbarDropdownItem: {
|
|
20
|
+
display: 'flex',
|
|
20
21
|
position: 'relative',
|
|
21
22
|
backgroundColor: token('color.background.neutral.subtle'),
|
|
22
23
|
width: '100%',
|
|
23
24
|
minHeight: '36px',
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
minWidth: '230px',
|
|
26
|
+
paddingInline: token('space.200'),
|
|
27
|
+
paddingBlock: token('space.100'),
|
|
26
28
|
'&:focus-visible': {
|
|
27
29
|
outlineOffset: token('space.negative.025'),
|
|
28
30
|
borderRadius: token('border.radius'),
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { Box } from '@atlaskit/primitives/compiled';
|
|
5
|
-
|
|
6
|
-
const styles = cssMap({
|
|
7
|
-
container: {
|
|
8
|
-
display: 'flex',
|
|
9
|
-
flexDirection: 'column',
|
|
10
|
-
},
|
|
11
|
-
});
|
|
3
|
+
import { DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
12
4
|
|
|
13
5
|
type ToolbarDropdownItemSectionProps = {
|
|
14
6
|
children?: ReactNode;
|
|
7
|
+
hasSeparator?: boolean;
|
|
8
|
+
title?: string;
|
|
15
9
|
};
|
|
16
10
|
|
|
17
|
-
export const ToolbarDropdownItemSection = ({
|
|
18
|
-
|
|
11
|
+
export const ToolbarDropdownItemSection = ({
|
|
12
|
+
children,
|
|
13
|
+
hasSeparator,
|
|
14
|
+
title,
|
|
15
|
+
}: ToolbarDropdownItemSectionProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<DropdownItemGroup hasSeparator={hasSeparator} title={title}>
|
|
18
|
+
{children}
|
|
19
|
+
</DropdownItemGroup>
|
|
20
|
+
);
|
|
19
21
|
};
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
1
5
|
import React, { type ReactNode, useCallback } from 'react';
|
|
2
6
|
|
|
7
|
+
import { jsx, cssMap } from '@compiled/react';
|
|
8
|
+
|
|
3
9
|
import DropdownMenu, { type OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
|
|
10
|
+
import { token } from '@atlaskit/tokens';
|
|
4
11
|
|
|
5
12
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
6
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
7
13
|
|
|
8
14
|
import { ToolbarButton } from './ToolbarButton';
|
|
9
15
|
import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
|
|
10
16
|
|
|
17
|
+
const styles = cssMap({
|
|
18
|
+
sectionMargin: {
|
|
19
|
+
marginBlock: token('space.050'),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
11
23
|
type ToolbarDropdownMenuProps = {
|
|
12
24
|
iconBefore: React.ReactNode;
|
|
13
25
|
children?: ReactNode;
|
|
14
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
15
26
|
isDisabled?: boolean;
|
|
16
27
|
testId?: string;
|
|
17
28
|
label?: string;
|
|
18
|
-
|
|
19
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Whether to add margin around sections to align with 4px block padding existing in current editor dropdown
|
|
31
|
+
*/
|
|
32
|
+
hasSectionMargin?: boolean;
|
|
20
33
|
};
|
|
21
34
|
|
|
22
35
|
const ToolbarDropdownMenuContent = ({
|
|
23
36
|
iconBefore,
|
|
24
|
-
groupLocation,
|
|
25
37
|
children,
|
|
26
38
|
isDisabled,
|
|
27
39
|
testId,
|
|
@@ -30,12 +42,15 @@ const ToolbarDropdownMenuContent = ({
|
|
|
30
42
|
const { onDropdownOpenChanged } = useToolbarUI();
|
|
31
43
|
const { closeMenu, isOpen, openMenu } = useToolbarDropdownMenu();
|
|
32
44
|
|
|
33
|
-
const handleOpenChange = useCallback(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
const handleOpenChange = useCallback(
|
|
46
|
+
(args: OnOpenChangeArgs) => {
|
|
47
|
+
onDropdownOpenChanged(args);
|
|
48
|
+
if (!args.isOpen) {
|
|
49
|
+
closeMenu();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
[closeMenu, onDropdownOpenChanged],
|
|
53
|
+
);
|
|
39
54
|
|
|
40
55
|
const handleClick = useCallback(() => {
|
|
41
56
|
if (!isOpen) {
|
|
@@ -62,7 +77,6 @@ const ToolbarDropdownMenuContent = ({
|
|
|
62
77
|
onFocus={triggerProps.onFocus}
|
|
63
78
|
testId={testId}
|
|
64
79
|
iconBefore={iconBefore}
|
|
65
|
-
groupLocation={groupLocation}
|
|
66
80
|
isDisabled={isDisabled}
|
|
67
81
|
label={label}
|
|
68
82
|
/>
|
|
@@ -77,22 +91,21 @@ const ToolbarDropdownMenuContent = ({
|
|
|
77
91
|
|
|
78
92
|
export const ToolbarDropdownMenu = ({
|
|
79
93
|
iconBefore,
|
|
80
|
-
groupLocation,
|
|
81
94
|
children,
|
|
82
95
|
isDisabled,
|
|
83
96
|
testId,
|
|
84
97
|
label,
|
|
98
|
+
hasSectionMargin = true,
|
|
85
99
|
}: ToolbarDropdownMenuProps) => {
|
|
86
100
|
return (
|
|
87
101
|
<ToolbarDropdownMenuProvider>
|
|
88
102
|
<ToolbarDropdownMenuContent
|
|
89
103
|
iconBefore={iconBefore}
|
|
90
|
-
groupLocation={groupLocation}
|
|
91
104
|
isDisabled={isDisabled}
|
|
92
105
|
testId={testId}
|
|
93
106
|
label={label}
|
|
94
107
|
>
|
|
95
|
-
{children}
|
|
108
|
+
<div css={hasSectionMargin && styles.sectionMargin}>{children}</div>
|
|
96
109
|
</ToolbarDropdownMenuContent>
|
|
97
110
|
</ToolbarDropdownMenuProvider>
|
|
98
111
|
);
|
|
@@ -6,7 +6,9 @@ interface ToolbarDropdownMenuContextValue {
|
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const ToolbarDropdownMenuContext = createContext<ToolbarDropdownMenuContextValue | undefined>(
|
|
9
|
+
const ToolbarDropdownMenuContext = createContext<ToolbarDropdownMenuContextValue | undefined>(
|
|
10
|
+
undefined,
|
|
11
|
+
);
|
|
10
12
|
|
|
11
13
|
export const useToolbarDropdownMenu = () => {
|
|
12
14
|
const context = useContext(ToolbarDropdownMenuContext);
|
|
@@ -20,9 +22,7 @@ interface ToolbarDropdownMenuProviderProps {
|
|
|
20
22
|
children: React.ReactNode;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
export const ToolbarDropdownMenuProvider = ({
|
|
24
|
-
children,
|
|
25
|
-
}: ToolbarDropdownMenuProviderProps) => {
|
|
25
|
+
export const ToolbarDropdownMenuProvider = ({ children }: ToolbarDropdownMenuProviderProps) => {
|
|
26
26
|
const [isOpen, setIsOpen] = useState(false);
|
|
27
27
|
|
|
28
28
|
const openMenu = () => setIsOpen(true);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* ToolbarDropdownDivider.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ToolbarDropdownDivider = void 0;
|
|
9
|
-
require("./ToolbarDropdownDivider.compiled.css");
|
|
10
|
-
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _runtime = require("@compiled/react/runtime");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
|
-
var styles = {
|
|
14
|
-
divider: "_1o3imuej _1il9nqa1 _1doce4h9"
|
|
15
|
-
};
|
|
16
|
-
var ToolbarDropdownDivider = exports.ToolbarDropdownDivider = function ToolbarDropdownDivider() {
|
|
17
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
18
|
-
className: (0, _runtime.ax)([styles.divider])
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* ToolbarDropdownDivider.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
-
import "./ToolbarDropdownDivider.compiled.css";
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
const styles = {
|
|
6
|
-
divider: "_1o3imuej _1il9nqa1 _1doce4h9"
|
|
7
|
-
};
|
|
8
|
-
export const ToolbarDropdownDivider = () => {
|
|
9
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
-
className: ax([styles.divider])
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* ToolbarDropdownDivider.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
-
import "./ToolbarDropdownDivider.compiled.css";
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
-
var styles = {
|
|
6
|
-
divider: "_1o3imuej _1il9nqa1 _1doce4h9"
|
|
7
|
-
};
|
|
8
|
-
export var ToolbarDropdownDivider = function ToolbarDropdownDivider() {
|
|
9
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
-
className: ax([styles.divider])
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ToolbarDropdownDivider: () => JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ToolbarDropdownDivider: () => JSX.Element;
|