|
6 | 6 | import { ReactWidget } from '@jupyterlab/apputils'; |
7 | 7 | import { Cell } from '@jupyterlab/cells'; |
8 | 8 | import { DirListing } from '@jupyterlab/filebrowser'; |
| 9 | +import { DocumentWidget } from '@jupyterlab/docregistry'; |
9 | 10 | import { ICell, isCode, isMarkdown, isRaw } from '@jupyterlab/nbformat'; |
10 | 11 | import React from 'react'; |
11 | 12 | import { Message } from '@lumino/messaging'; |
12 | 13 | import { Drag } from '@lumino/dragdrop'; |
| 14 | +import { Widget } from '@lumino/widgets'; |
13 | 15 |
|
14 | 16 | import { Chat, IInputToolbarRegistry, MESSAGE_CLASS } from '../components'; |
15 | 17 | import { chatIcon } from '../icons'; |
@@ -332,27 +334,26 @@ export class ChatWidget extends ReactWidget { |
332 | 334 | * Process dropped tabBar files |
333 | 335 | */ |
334 | 336 | private _processTabDrop(event: Drag.Event) { |
335 | | - const factory = event.mimeData.getData(TABBAR_FILE_MIME) as () => any; |
| 337 | + const factory = event.mimeData.getData(TABBAR_FILE_MIME) as () => Widget; |
336 | 338 | if (!factory) { |
337 | 339 | console.warn('No factory in drag event'); |
338 | 340 | return; |
339 | 341 | } |
340 | 342 |
|
341 | 343 | const widget = factory(); |
342 | | - if (!widget) { |
343 | | - console.warn('Factory did not return a widget'); |
| 344 | + if (!widget || !(widget instanceof DocumentWidget)) { |
| 345 | + console.warn('No file associated to the element'); |
344 | 346 | return; |
345 | 347 | } |
346 | 348 |
|
347 | | - const path = |
348 | | - typeof widget.context?.path === 'string' ? widget.context.path : null; |
| 349 | + const path = widget.context.path; |
349 | 350 | if (!path) { |
350 | 351 | console.warn('Widget has no path'); |
351 | 352 | return; |
352 | 353 | } |
353 | 354 |
|
354 | 355 | const mimetype = |
355 | | - widget.context?.model?.mimeType || 'application/octet-stream'; |
| 356 | + widget.context.model?.mimeType || 'application/octet-stream'; |
356 | 357 | const attachment: IFileAttachment = { |
357 | 358 | type: 'file', |
358 | 359 | value: path, |
|
0 commit comments