|
|
@@ -1,6 +1,7 @@
|
|
|
-import { memo } from 'react';
|
|
|
+import { memo, useCallback, useRef } from 'react';
|
|
|
|
|
|
import type { AcceptedUploadFileType } from '@growi/core';
|
|
|
+import SimpleBar from 'simplebar-react';
|
|
|
|
|
|
import type { GlobalCodeMirrorEditorKey } from '../../../../consts';
|
|
|
|
|
|
@@ -20,18 +21,31 @@ type Props = {
|
|
|
}
|
|
|
|
|
|
export const Toolbar = memo((props: Props): JSX.Element => {
|
|
|
-
|
|
|
const { editorKey, acceptedUploadFileType, onUpload } = props;
|
|
|
+ const simpleBarRef = useRef<SimpleBar>(null);
|
|
|
+
|
|
|
+ const onTextFormatToolsCollapseChange = useCallback(() => {
|
|
|
+ if (simpleBarRef.current) {
|
|
|
+ simpleBarRef.current.recalculate();
|
|
|
+ }
|
|
|
+ }, [simpleBarRef]);
|
|
|
+
|
|
|
return (
|
|
|
- <div className={`d-flex gap-2 py-1 px-2 px-md-3 border-top ${styles['codemirror-editor-toolbar']}`}>
|
|
|
- <AttachmentsDropup editorKey={editorKey} onUpload={onUpload} acceptedUploadFileType={acceptedUploadFileType} />
|
|
|
- <TextFormatTools editorKey={editorKey} />
|
|
|
- <EmojiButton
|
|
|
- editorKey={editorKey}
|
|
|
- />
|
|
|
- <TableButton editorKey={editorKey} />
|
|
|
- <DiagramButton editorKey={editorKey} />
|
|
|
- <TemplateButton editorKey={editorKey} />
|
|
|
- </div>
|
|
|
+ <>
|
|
|
+ <div className={`d-flex gap-2 py-1 px-2 px-md-3 border-top ${styles['codemirror-editor-toolbar']}`}>
|
|
|
+ <AttachmentsDropup editorKey={editorKey} onUpload={onUpload} acceptedUploadFileType={acceptedUploadFileType} />
|
|
|
+ <div className="flex-grow-1">
|
|
|
+ <SimpleBar ref={simpleBarRef} autoHide style={{ overflowY: 'hidden' }}>
|
|
|
+ <div className="d-flex gap-2">
|
|
|
+ <TextFormatTools editorKey={editorKey} onTextFormatToolsCollapseChange={onTextFormatToolsCollapseChange} />
|
|
|
+ <EmojiButton editorKey={editorKey} />
|
|
|
+ <TableButton editorKey={editorKey} />
|
|
|
+ <DiagramButton editorKey={editorKey} />
|
|
|
+ <TemplateButton editorKey={editorKey} />
|
|
|
+ </div>
|
|
|
+ </SimpleBar>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
);
|
|
|
});
|