Skip to content

Commit 25d0cdc

Browse files
committed
Fix dragging views across notebook
Fix microsoft#96678
1 parent 5de0ef6 commit 25d0cdc

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

src/vs/workbench/contrib/notebook/browser/media/notebook.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
position: relative;
3636
}
3737

38+
.monaco-workbench .part.editor > .content .notebook-editor.global-drag-active .webview {
39+
pointer-events: none;
40+
}
41+
3842
.monaco-workbench .part.editor > .content .notebook-editor .cell-list-container .webview-cover {
3943
position: absolute;
4044
top: 0;
@@ -459,13 +463,6 @@
459463
color: inherit;
460464
}
461465

462-
.notebook-webview {
463-
position: absolute;
464-
z-index: 1000000;
465-
left: 373px;
466-
top: 0px;
467-
}
468-
469466
/* markdown */
470467

471468

src/vs/workbench/contrib/notebook/browser/notebookEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
254254
private createCellList(): void {
255255
DOM.addClass(this.body, 'cell-list-container');
256256

257-
const dndController = new CellDragAndDropController(this);
257+
const dndController = this._register(new CellDragAndDropController(this));
258258
const renders = [
259259
this.instantiationService.createInstance(CodeCellRenderer, this, this.renderedEditors, dndController),
260260
this.instantiationService.createInstance(MarkdownCellRenderer, this.contextKeyService, this, dndController, this.renderedEditors),

src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,31 @@ const DRAGGING_CLASS = 'cell-dragging';
488488
const DRAGOVER_TOP_CLASS = 'cell-dragover-top';
489489
const DRAGOVER_BOTTOM_CLASS = 'cell-dragover-bottom';
490490

491+
const GLOBAL_DRAG_CLASS = 'global-drag-active';
492+
491493
type DragImageProvider = () => HTMLElement;
492494

493-
export class CellDragAndDropController {
495+
export class CellDragAndDropController extends Disposable {
494496
// TODO@roblourens - should probably use dataTransfer here, but any dataTransfer set makes the editor think I am dropping a file, need
495497
// to figure out how to prevent that
496498
private currentDraggedCell: ICellViewModel | undefined;
497499

498500
constructor(
499501
private readonly notebookEditor: INotebookEditor
500-
) { }
502+
) {
503+
super();
504+
505+
this._register(domEvent(document.body, DOM.EventType.DRAG_START, true)(this.onGlobalDragStart.bind(this)));
506+
this._register(domEvent(document.body, DOM.EventType.DRAG_END, true)(this.onGlobalDragEnd.bind(this)));
507+
}
508+
509+
private onGlobalDragStart() {
510+
this.notebookEditor.getDomNode().classList.add(GLOBAL_DRAG_CLASS);
511+
}
512+
513+
private onGlobalDragEnd() {
514+
this.notebookEditor.getDomNode().classList.remove(GLOBAL_DRAG_CLASS);
515+
}
501516

502517
addListeners(templateData: BaseCellRenderTemplate, dragImageProvider: DragImageProvider): void {
503518
const container = templateData.container;
@@ -511,17 +526,12 @@ export class CellDragAndDropController {
511526
};
512527

513528
templateData.disposables.add(domEvent(dragHandle, DOM.EventType.DRAG_END)(() => {
514-
// TODO@roblourens
515-
(this.notebookEditor.getInnerWebview() as any)!.element.style['pointer-events'] = '';
516-
517529
// Note, templateData may have a different element rendered into it by now
518530
container.classList.remove(DRAGGING_CLASS);
519531
dragCleanup();
520532
}));
521533

522534
templateData.disposables.add(domEvent(dragHandle, DOM.EventType.DRAG_START)(event => {
523-
(this.notebookEditor.getInnerWebview() as any)!.element.style['pointer-events'] = 'none';
524-
525535
if (!event.dataTransfer) {
526536
return;
527537
}

0 commit comments

Comments
 (0)