Skip to content

Commit b95e83a

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

File tree

8 files changed

+22
-6
lines changed

8 files changed

+22
-6
lines changed

src/bundle/MarkdownEditorView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const EditorWrapper = forwardRef<HTMLDivElement, EditorWrapperProps>(
6666
unsetShowPreview,
6767
wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,
6868
wysiwygToolbarConfig: initialWysiwygToolbarConfig,
69-
mobile = false,
69+
mobile,
7070
},
7171
ref,
7272
) => {
@@ -309,7 +309,7 @@ export const MarkdownEditorView = forwardRef<HTMLDivElement, MarkdownEditorViewP
309309
toolbarsPreset,
310310
wysiwygHiddenActionsConfig,
311311
wysiwygToolbarConfig,
312-
mobile = false,
312+
mobile,
313313
} = props;
314314

315315
const rerender = useUpdate();

src/bundle/MarkupEditorView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const MarkupEditorView = memo<MarkupEditorViewProps>((props) => {
4747
toolbarClassName,
4848
children,
4949
stickyToolbar = true,
50-
mobile = false,
50+
mobile,
5151
} = props;
5252
useRenderTime((time) => {
5353
globalLogger.metrics({

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/bundle/useMarkdownEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useMarkdownEditor(
3131
markupConfig = {},
3232
wysiwygConfig = {},
3333
logger = new Logger2(),
34-
mobile = false,
34+
mobile,
3535
} = props;
3636

3737
const preset: MarkdownEditorPreset = props.preset ?? 'full';

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
@@ -6,4 +6,8 @@
66

77
border-left: 1px solid var(--g-color-line-generic);
88
}
9+
10+
&_mobile {
11+
overflow: auto;
12+
}
913
}

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)