提交 777d226c 编写于 作者: R Rob Lourens

Disallow dragging other things over the notebook

Fix #99257
上级 ccf724d6
...@@ -51,6 +51,7 @@ import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewMod ...@@ -51,6 +51,7 @@ import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewMod
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel'; import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel'; import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
import { CellKind, NotebookCellRunState, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { CellKind, NotebookCellRunState, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { containsDragType } from 'vs/workbench/browser/dnd';
const $ = DOM.$; const $ = DOM.$;
...@@ -513,6 +514,8 @@ interface CellDragEvent { ...@@ -513,6 +514,8 @@ interface CellDragEvent {
} }
export class CellDragAndDropController extends Disposable { export class CellDragAndDropController extends Disposable {
private static DATA_TYPE = 'vscode_notebook_cell';
// TODO@roblourens - should probably use dataTransfer here, but any dataTransfer set makes the editor think I am dropping a file, need // TODO@roblourens - should probably use dataTransfer here, but any dataTransfer set makes the editor think I am dropping a file, need
// to figure out how to prevent that // to figure out how to prevent that
private currentDraggedCell: ICellViewModel | undefined; private currentDraggedCell: ICellViewModel | undefined;
...@@ -619,6 +622,15 @@ export class CellDragAndDropController extends Disposable { ...@@ -619,6 +622,15 @@ export class CellDragAndDropController extends Disposable {
} }
private onCellDragover(event: CellDragEvent): void { private onCellDragover(event: CellDragEvent): void {
if (!event.browserEvent.dataTransfer) {
return;
}
if (!this.currentDraggedCell || !containsDragType(event.browserEvent, CellDragAndDropController.DATA_TYPE)) {
event.browserEvent.dataTransfer.dropEffect = 'none';
return;
}
if (this.isScrolling || this.currentDraggedCell === event.draggedOverCell) { if (this.isScrolling || this.currentDraggedCell === event.draggedOverCell) {
this.setInsertIndicatorVisibility(false); this.setInsertIndicatorVisibility(false);
return; return;
...@@ -691,6 +703,8 @@ export class CellDragAndDropController extends Disposable { ...@@ -691,6 +703,8 @@ export class CellDragAndDropController extends Disposable {
return; return;
} }
event.dataTransfer.setData(CellDragAndDropController.DATA_TYPE, 'true');
this.currentDraggedCell = templateData.currentRenderedCell!; this.currentDraggedCell = templateData.currentRenderedCell!;
this.currentDraggedCell.dragging = true; this.currentDraggedCell.dragging = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册