Skip to content

Commit a599552

Browse files
committed
fix #4765 -- support drag-n-drop upload of all file types to chat and jupyter markdown etc in markdown source mode (non-wysiwyg)
1 parent 30243f5 commit a599552

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/packages/frontend/editors/markdown-input/component.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ export function MarkdownInput(props: Props) {
275275

276276
cm.current = CodeMirror.fromTextArea(node, {
277277
...options,
278+
// dragDrop=false: instead of useless codemirror dnd, we upload file and make link.
279+
// Note that for the md editor or other full code editors, we DO want dragDrop true,
280+
// since, e.g., you can select some text, then drag it around, which is useful. For
281+
// a simple chat message or tiny bit of markdown (like this is for), that's not so
282+
// useful and drag-n-drop file upload is way better.
283+
dragDrop: false,
278284
// IMPORTANT: there is a useEffect involving options below
279285
// where the following four properties must be explicitly excluded!
280286
inputStyle: "contenteditable" as "contenteditable", // needed for spellcheck to work!
@@ -616,7 +622,6 @@ export function MarkdownInput(props: Props) {
616622
}
617623

618624
function handle_paste_event(_, e): void {
619-
// console.log("handle_paste_event", e);
620625
const items = e.clipboardData.items;
621626
for (let i = 0; i < items.length; i++) {
622627
const item = items[i];
@@ -909,11 +914,6 @@ export function MarkdownInput(props: Props) {
909914
style={{ height: "100%", width: "100%" }}
910915
dropzone_ref={dropzone_ref}
911916
close_preview_ref={upload_close_preview_ref}
912-
config={
913-
// only images work since when pasting other doc types
914-
// things blow up (due to conflict with codemirror?)
915-
{ acceptedFiles: "image/*" }
916-
}
917917
>
918918
{body}
919919
</BlobUpload>

0 commit comments

Comments
 (0)