Skip to content

Commit 546919e

Browse files
committed
markdown editor file upload -- show progress and upload area
- even more disconcerting to NOT have this, since you don't know progress - nice to have, since can easily then upload more docs - i fixed the X
1 parent b7b67e7 commit 546919e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/packages/frontend/editors/slate/upload.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function uploadTarget(path: string, file: { name: string }): string {
2020

2121
export default function useUpload(
2222
editor: SlateEditor,
23-
body: JSX.Element
23+
body: JSX.Element,
2424
): JSX.Element {
2525
const dropzoneRef = useRef<Dropzone>(null);
2626
const { actions, project_id, path } = useFrameContext();
@@ -50,7 +50,7 @@ export default function useUpload(
5050
if (file != null) {
5151
const blob = file.slice(0, -1, item.type);
5252
dropzoneRef?.current?.addFile(
53-
new File([blob], `paste-${Math.random()}`, { type: item.type })
53+
new File([blob], `paste-${Math.random()}`, { type: item.type }),
5454
);
5555
}
5656
return; // what if more than one ?
@@ -95,8 +95,6 @@ export default function useUpload(
9595
};
9696
}, []);
9797

98-
// Note: using show_upload={false} since showing the upload right in the
99-
// wysiwyg editor is really disconcerting.
10098
return (
10199
<FileUploadWrapper
102100
className="smc-vfill"

src/packages/frontend/file-upload.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const CHUNK_SIZE_MB = 8;
3535

3636
const TIMEOUT_S = 100;
3737

38+
const CLOSE_BUTTON_STYLE = {
39+
position: "absolute",
40+
right: 0,
41+
zIndex: 1, // so it floats above text/markdown buttons
42+
background: "white",
43+
cursor: "pointer",
44+
} as const;
45+
3846
/*
3947
CHUNK_SIZE_MB being set properly is critical for cloudflare to work --
4048
we want this to be as big as possible, but MUST be smaller than
@@ -123,7 +131,7 @@ export const FileUpload: React.FC<FileUploadProps> = (props) => {
123131

124132
function render_close_button() {
125133
return (
126-
<div className="close-button pull-right">
134+
<div className="close-button" style={CLOSE_BUTTON_STYLE}>
127135
<span
128136
onClick={props.close_button_onclick}
129137
className="close-button-x"
@@ -311,7 +319,7 @@ export const FileUploadWrapper: React.FC<FileUploadWrapperProps> = (props) => {
311319

312320
return (
313321
<div style={style}>
314-
<div className="close-button pull-right">
322+
<div className="close-button" style={CLOSE_BUTTON_STYLE}>
315323
<span
316324
onClick={() => {
317325
close_preview();

0 commit comments

Comments
 (0)