Skip to content

Commit 974ce51

Browse files
committed
feat(mobile): scroll toolbar action
1 parent 53bd29b commit 974ce51

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/bundle/WysiwygEditorView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {
4343
toolbarClassName,
4444
children,
4545
stickyToolbar = true,
46+
mobile,
4647
} = props;
4748

4849
useRenderTime((time) => {
@@ -72,6 +73,7 @@ export const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {
7273
hiddenActionsConfig={hiddenActionsConfig}
7374
settingsVisible={settingsVisible}
7475
className={b('toolbar', [toolbarClassName])}
76+
mobile={mobile}
7577
>
7678
{children}
7779
</ToolbarView>

src/toolbar/FlexToolbar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ export function FlexToolbar<E>(props: FlexToolbarProps<E>) {
5454
data,
5555
availableWidth: width,
5656
hiddenActions: filteredHiddenAction,
57+
mobile,
5758
});
58-
}, [data, width, hiddenActions]);
59+
}, [data, hiddenActions, mobile, width]);
5960

6061
return (
6162
<div ref={ref} className={b(null, [className])}>

src/toolbar/Toolbar.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.g-md-toolbar {
22
display: flex;
33

4+
&_mobile {
5+
overflow: auto;
6+
}
7+
48
&__group-separator {
59
margin: 6px 8px;
610

src/toolbar/Toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ToolbarProps<E> = ToolbarBaseProps<E> & {
1717

1818
export function Toolbar<E>({editor, data, className, focus, onClick, mobile}: ToolbarProps<E>) {
1919
return (
20-
<div className={b(null, [className])}>
20+
<div className={b({mobile}, [className])}>
2121
{data.map<React.ReactNode>((group, index) => {
2222
const isLastGroup = index === data.length - 1;
2323

src/toolbar/flexible.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,25 @@ export type ShrinkToolbarDataParams<E> = {
2020
data: ToolbarData<E>;
2121
availableWidth: number;
2222
hiddenActions?: ToolbarItemData<E>[];
23+
mobile?: boolean;
2324
};
2425

2526
export function shrinkToolbarData<E>({
2627
availableWidth,
2728
data,
2829
hiddenActions = [],
30+
mobile,
2931
}: ShrinkToolbarDataParams<E>): {
3032
data: ToolbarData<E>;
3133
dots?: ToolbarItemData<E>[];
3234
} {
35+
if (mobile) {
36+
return {
37+
data,
38+
dots: hiddenActions.length ? hiddenActions : undefined,
39+
};
40+
}
41+
3342
const fittingData: ToolbarData<E> = [];
3443
const dotsData: ToolbarItemData<E>[] = [];
3544
let currentWidth = 0;

0 commit comments

Comments
 (0)