@atlaskit/editor-toolbar 0.3.0 → 0.3.1
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 +15 -0
- package/dist/cjs/index.js +0 -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/es2019/index.js +0 -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/esm/index.js +0 -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/types/index.d.ts +1 -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-ts4.5/index.d.ts +1 -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/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +2 -12
- package/package.json +1 -1
- package/src/index.ts +1 -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/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
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
/* ToolbarDropdownItemSection.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
-
import "./ToolbarDropdownItemSection.compiled.css";
|
|
3
|
-
import { ax, ix } from "@compiled/react/runtime";
|
|
4
1
|
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
var styles = {
|
|
7
|
-
container: "_1e0c1txw _2lx21bp4"
|
|
8
|
-
};
|
|
2
|
+
import { DropdownItemGroup } from '@atlaskit/dropdown-menu';
|
|
9
3
|
export var ToolbarDropdownItemSection = function ToolbarDropdownItemSection(_ref) {
|
|
10
|
-
var children = _ref.children
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
var children = _ref.children,
|
|
5
|
+
hasSeparator = _ref.hasSeparator,
|
|
6
|
+
title = _ref.title;
|
|
7
|
+
return /*#__PURE__*/React.createElement(DropdownItemGroup, {
|
|
8
|
+
hasSeparator: hasSeparator,
|
|
9
|
+
title: title
|
|
13
10
|
}, children);
|
|
14
11
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._1mou1b66{margin-block:var(--ds-space-050,4px)}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
/* ToolbarDropdownMenu.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./ToolbarDropdownMenu.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
1
4
|
import React, { useCallback } from 'react';
|
|
2
5
|
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
3
6
|
import { useToolbarUI } from '../hooks/ui-context';
|
|
4
7
|
import { ToolbarButton } from './ToolbarButton';
|
|
5
8
|
import { ToolbarDropdownMenuProvider, useToolbarDropdownMenu } from './ToolbarDropdownMenuContext';
|
|
9
|
+
var styles = {
|
|
10
|
+
sectionMargin: "_1mou1b66"
|
|
11
|
+
};
|
|
6
12
|
var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
7
13
|
var iconBefore = _ref.iconBefore,
|
|
8
|
-
groupLocation = _ref.groupLocation,
|
|
9
14
|
children = _ref.children,
|
|
10
15
|
isDisabled = _ref.isDisabled,
|
|
11
16
|
testId = _ref.testId,
|
|
@@ -45,7 +50,6 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
45
50
|
onFocus: triggerProps.onFocus,
|
|
46
51
|
testId: testId,
|
|
47
52
|
iconBefore: iconBefore,
|
|
48
|
-
groupLocation: groupLocation,
|
|
49
53
|
isDisabled: isDisabled,
|
|
50
54
|
label: label
|
|
51
55
|
});
|
|
@@ -56,16 +60,18 @@ var ToolbarDropdownMenuContent = function ToolbarDropdownMenuContent(_ref) {
|
|
|
56
60
|
};
|
|
57
61
|
export var ToolbarDropdownMenu = function ToolbarDropdownMenu(_ref2) {
|
|
58
62
|
var iconBefore = _ref2.iconBefore,
|
|
59
|
-
groupLocation = _ref2.groupLocation,
|
|
60
63
|
children = _ref2.children,
|
|
61
64
|
isDisabled = _ref2.isDisabled,
|
|
62
65
|
testId = _ref2.testId,
|
|
63
|
-
label = _ref2.label
|
|
66
|
+
label = _ref2.label,
|
|
67
|
+
_ref2$hasSectionMargi = _ref2.hasSectionMargin,
|
|
68
|
+
hasSectionMargin = _ref2$hasSectionMargi === void 0 ? true : _ref2$hasSectionMargi;
|
|
64
69
|
return /*#__PURE__*/React.createElement(ToolbarDropdownMenuProvider, null, /*#__PURE__*/React.createElement(ToolbarDropdownMenuContent, {
|
|
65
70
|
iconBefore: iconBefore,
|
|
66
|
-
groupLocation: groupLocation,
|
|
67
71
|
isDisabled: isDisabled,
|
|
68
72
|
testId: testId,
|
|
69
73
|
label: label
|
|
70
|
-
},
|
|
74
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: ax([hasSectionMargin && styles.sectionMargin])
|
|
76
|
+
}, children)));
|
|
71
77
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
|
|
|
8
8
|
export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
9
9
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
10
10
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
11
|
-
export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
|
|
12
11
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
13
12
|
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
14
13
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
@@ -57,5 +56,5 @@ export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
|
|
|
57
56
|
export { IndentIcon } from './ui/icons/IndentIcon';
|
|
58
57
|
export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
59
58
|
export { default as ColorPalette } from './ui/ColorPalette';
|
|
60
|
-
export type { IconComponent
|
|
59
|
+
export type { IconComponent } from './types';
|
|
61
60
|
export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
3
|
type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
5
4
|
children?: ReactNode;
|
|
6
5
|
isSelected?: boolean;
|
|
@@ -9,7 +8,6 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
9
8
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
10
9
|
testId?: string;
|
|
11
10
|
iconBefore: React.ReactNode;
|
|
12
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
13
11
|
isDisabled?: boolean;
|
|
14
12
|
ariaKeyshortcuts?: string;
|
|
15
13
|
label?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
2
6
|
type ToolbarButtonGroupProps = {
|
|
3
7
|
children?: ReactNode;
|
|
4
8
|
};
|
|
5
|
-
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) =>
|
|
9
|
+
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) => JSX.Element;
|
|
6
10
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
type ToolbarDropdownItemSectionProps = {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
+
hasSeparator?: boolean;
|
|
5
|
+
title?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare const ToolbarDropdownItemSection: ({ children }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
7
|
+
export declare const ToolbarDropdownItemSection: ({ children, hasSeparator, title, }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
1
5
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
6
|
type ToolbarDropdownMenuProps = {
|
|
5
7
|
iconBefore: React.ReactNode;
|
|
6
8
|
children?: ReactNode;
|
|
7
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
8
9
|
isDisabled?: boolean;
|
|
9
10
|
testId?: string;
|
|
10
11
|
label?: string;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Whether to add margin around sections to align with 4px block padding existing in current editor dropdown
|
|
14
|
+
*/
|
|
15
|
+
hasSectionMargin?: boolean;
|
|
13
16
|
};
|
|
14
|
-
export declare const ToolbarDropdownMenu: ({ iconBefore,
|
|
17
|
+
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
15
18
|
export {};
|
|
@@ -8,5 +8,5 @@ export declare const useToolbarDropdownMenu: () => ToolbarDropdownMenuContextVal
|
|
|
8
8
|
interface ToolbarDropdownMenuProviderProps {
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare const ToolbarDropdownMenuProvider: ({ children
|
|
11
|
+
export declare const ToolbarDropdownMenuProvider: ({ children }: ToolbarDropdownMenuProviderProps) => React.JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -8,7 +8,6 @@ export { ToolbarNestedDropdownMenu } from './ui/ToolbarNestedDropdownMenu';
|
|
|
8
8
|
export { ToolbarKeyboardShortcutHint } from './ui/ToolbarKeyboardShortcutHint';
|
|
9
9
|
export { ToolbarSection } from './ui/ToolbarSection';
|
|
10
10
|
export { ToolbarTooltip } from './ui/ToolbarTooltip';
|
|
11
|
-
export { ToolbarDropdownDivider } from './ui/ToolbarDropdownDivider';
|
|
12
11
|
export { ToolbarColorSwatch } from './ui/ToolbarColorSwatch';
|
|
13
12
|
export { useToolbarDropdownMenu } from './ui/ToolbarDropdownMenuContext';
|
|
14
13
|
export { AIAdjustLengthIcon } from './ui/icons/AIAdjustLengthIcon';
|
|
@@ -57,5 +56,5 @@ export { AlignTextRightIcon } from './ui/icons/AlignTextRightIcon';
|
|
|
57
56
|
export { IndentIcon } from './ui/icons/IndentIcon';
|
|
58
57
|
export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
59
58
|
export { default as ColorPalette } from './ui/ColorPalette';
|
|
60
|
-
export type { IconComponent
|
|
59
|
+
export type { IconComponent } from './types';
|
|
61
60
|
export { useToolbarUI, ToolbarUIProvider } from './hooks/ui-context';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { type TriggerProps } from '@atlaskit/popup';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
3
|
type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
5
4
|
children?: ReactNode;
|
|
6
5
|
isSelected?: boolean;
|
|
@@ -9,7 +8,6 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
9
8
|
onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;
|
|
10
9
|
testId?: string;
|
|
11
10
|
iconBefore: React.ReactNode;
|
|
12
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
13
11
|
isDisabled?: boolean;
|
|
14
12
|
ariaKeyshortcuts?: string;
|
|
15
13
|
label?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
2
6
|
type ToolbarButtonGroupProps = {
|
|
3
7
|
children?: ReactNode;
|
|
4
8
|
};
|
|
5
|
-
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) =>
|
|
9
|
+
export declare const ToolbarButtonGroup: ({ children }: ToolbarButtonGroupProps) => JSX.Element;
|
|
6
10
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
type ToolbarDropdownItemSectionProps = {
|
|
3
3
|
children?: ReactNode;
|
|
4
|
+
hasSeparator?: boolean;
|
|
5
|
+
title?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare const ToolbarDropdownItemSection: ({ children }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
7
|
+
export declare const ToolbarDropdownItemSection: ({ children, hasSeparator, title, }: ToolbarDropdownItemSectionProps) => React.JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
1
5
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type OnOpenChangeArgs } from '@atlaskit/dropdown-menu';
|
|
3
|
-
import { type ToolbarButtonGroupLocation } from '../types';
|
|
4
6
|
type ToolbarDropdownMenuProps = {
|
|
5
7
|
iconBefore: React.ReactNode;
|
|
6
8
|
children?: ReactNode;
|
|
7
|
-
groupLocation?: ToolbarButtonGroupLocation;
|
|
8
9
|
isDisabled?: boolean;
|
|
9
10
|
testId?: string;
|
|
10
11
|
label?: string;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Whether to add margin around sections to align with 4px block padding existing in current editor dropdown
|
|
14
|
+
*/
|
|
15
|
+
hasSectionMargin?: boolean;
|
|
13
16
|
};
|
|
14
|
-
export declare const ToolbarDropdownMenu: ({ iconBefore,
|
|
17
|
+
export declare const ToolbarDropdownMenu: ({ iconBefore, children, isDisabled, testId, label, hasSectionMargin, }: ToolbarDropdownMenuProps) => JSX.Element;
|
|
15
18
|
export {};
|
|
@@ -8,5 +8,5 @@ export declare const useToolbarDropdownMenu: () => ToolbarDropdownMenuContextVal
|
|
|
8
8
|
interface ToolbarDropdownMenuProviderProps {
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare const ToolbarDropdownMenuProvider: ({ children
|
|
11
|
+
export declare const ToolbarDropdownMenuProvider: ({ children }: ToolbarDropdownMenuProviderProps) => React.JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -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
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
|
|
|
@@ -61,6 +60,6 @@ export { OutdentIcon } from './ui/icons/OutdentIcon';
|
|
|
61
60
|
|
|
62
61
|
export { default as ColorPalette } from './ui/ColorPalette';
|
|
63
62
|
|
|
64
|
-
export type { IconComponent
|
|
63
|
+
export type { IconComponent } from './types';
|
|
65
64
|
|
|
66
65
|
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'),
|