提交 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
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
import { CellKind, NotebookCellRunState, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { containsDragType } from 'vs/workbench/browser/dnd';
const $ = DOM.$;
......@@ -513,6 +514,8 @@ interface CellDragEvent {
}
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
// to figure out how to prevent that
private currentDraggedCell: ICellViewModel | undefined;
......@@ -619,6 +622,15 @@ export class CellDragAndDropController extends Disposable {
}
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) {
this.setInsertIndicatorVisibility(false);
return;
......@@ -691,6 +703,8 @@ export class CellDragAndDropController extends Disposable {
return;
}
event.dataTransfer.setData(CellDragAndDropController.DATA_TYPE, 'true');
this.currentDraggedCell = templateData.currentRenderedCell!;
this.currentDraggedCell.dragging = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册