Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ab3d507b
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab3d507b
编写于
5月 12, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - still allow copy operation when dropping onto same group
上级
cf8014ee
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
61 addition
and
50 deletion
+61
-50
src/vs/workbench/browser/parts/editor2/nextEditorDropTarget.ts
...s/workbench/browser/parts/editor2/nextEditorDropTarget.ts
+61
-50
未找到文件。
src/vs/workbench/browser/parts/editor2/nextEditorDropTarget.ts
浏览文件 @
ab3d507b
...
...
@@ -7,7 +7,7 @@
import
'
vs/css!./media/nextEditorDropTarget
'
;
import
{
LocalSelectionTransfer
,
DraggedEditorIdentifier
,
ResourcesDropHandler
,
DraggedEditorGroupIdentifier
,
DragAndDropObserver
}
from
'
vs/workbench/browser/dnd
'
;
import
{
addDisposableListener
,
EventType
,
EventHelper
,
isAncestor
,
toggleClass
,
addClass
}
from
'
vs/base/browser/dom
'
;
import
{
addDisposableListener
,
EventType
,
EventHelper
,
isAncestor
,
toggleClass
,
addClass
,
removeClass
}
from
'
vs/base/browser/dom
'
;
import
{
INextEditorGroupsAccessor
,
EDITOR_TITLE_HEIGHT
,
INextEditorGroupView
,
getActiveTextEditorOptions
}
from
'
vs/workbench/browser/parts/editor2/editor2
'
;
import
{
EDITOR_DRAG_AND_DROP_BACKGROUND
,
Themable
}
from
'
vs/workbench/common/theme
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -18,6 +18,10 @@ import { GroupDirection, MergeGroupMode } from 'vs/workbench/services/group/comm
import
{
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
interface
IDropOperation
{
splitDirection
?:
GroupDirection
;
}
class
DropOverlay
extends
Themable
{
private
static
OVERLAY_ID
=
'
monaco-workbench-editor-drop-overlay
'
;
...
...
@@ -26,7 +30,7 @@ class DropOverlay extends Themable {
private
container
:
HTMLElement
;
private
overlay
:
HTMLElement
;
private
splitDirection
:
GroupDirec
tion
;
private
currentDropOperation
:
IDropOpera
tion
;
private
_disposed
:
boolean
;
private
readonly
editorTransfer
=
LocalSelectionTransfer
.
getInstance
<
DraggedEditorIdentifier
>
();
...
...
@@ -86,16 +90,27 @@ class DropOverlay extends Themable {
this
.
_register
(
new
DragAndDropObserver
(
this
.
container
,
{
onDragEnter
:
e
=>
void
0
,
onDragOver
:
e
=>
{
const
isDraggingGroup
=
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
);
const
isDraggingEditor
=
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
);
// Update the dropEffect to "copy" if there is no local data to be dragged because
// in that case we can only copy the data into and not move it from its source
if
(
!
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
)
&&
!
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
)
)
{
if
(
!
isDraggingEditor
&&
!
isDraggingGroup
)
{
e
.
dataTransfer
.
dropEffect
=
'
copy
'
;
}
// Find out if operation is valid
const
isCopy
=
isDraggingGroup
?
this
.
isCopyOperation
(
e
)
:
this
.
isCopyOperation
(
e
,
this
.
editorTransfer
.
getData
(
DraggedEditorIdentifier
.
prototype
)[
0
].
identifier
);
if
(
!
isCopy
)
{
const
sourceGroupView
=
this
.
findSourceGroupView
();
if
(
sourceGroupView
===
this
.
groupView
)
{
if
(
isDraggingGroup
||
(
isDraggingEditor
&&
sourceGroupView
.
count
<
2
))
{
this
.
hideOverlay
();
return
;
// do not allow to drop group/editor on itself if this results in an empty group
}
}
}
// Position overlay
this
.
positionOverlay
(
e
.
offsetX
,
e
.
offsetY
);
},
...
...
@@ -109,8 +124,10 @@ class DropOverlay extends Themable {
// Dispose overlay
this
.
dispose
();
// Handle drop
this
.
handleDrop
(
e
);
// Handle drop if we have a valid operation
if
(
this
.
currentDropOperation
)
{
this
.
handleDrop
(
e
,
this
.
currentDropOperation
.
splitDirection
);
}
}
}));
...
...
@@ -128,13 +145,28 @@ class DropOverlay extends Themable {
}));
}
private
handleDrop
(
event
:
DragEvent
):
void
{
private
findSourceGroupView
():
INextEditorGroupView
{
// Check for group transfer
if
(
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
groupTransfer
.
getData
(
DraggedEditorGroupIdentifier
.
prototype
)[
0
].
identifier
);
}
// Check for editor transfer
else
if
(
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
editorTransfer
.
getData
(
DraggedEditorIdentifier
.
prototype
)[
0
].
identifier
.
group
.
id
);
}
return
void
0
;
}
private
handleDrop
(
event
:
DragEvent
,
splitDirection
?:
GroupDirection
):
void
{
// Determine target group
const
ensureTargetGroup
=
()
=>
{
let
targetGroup
:
INextEditorGroupView
;
if
(
typeof
this
.
splitDirection
===
'
number
'
)
{
targetGroup
=
this
.
accessor
.
addGroup
(
this
.
groupView
,
this
.
splitDirection
,
{
activate
:
true
});
if
(
typeof
splitDirection
===
'
number
'
)
{
targetGroup
=
this
.
accessor
.
addGroup
(
this
.
groupView
,
splitDirection
,
{
activate
:
true
});
}
else
{
targetGroup
=
this
.
groupView
;
}
...
...
@@ -148,17 +180,17 @@ class DropOverlay extends Themable {
// Return if the drop is a no-op
const
sourceGroup
=
this
.
accessor
.
getGroup
(
draggedEditorGroup
);
if
(
typeof
this
.
splitDirection
!==
'
number
'
&&
sourceGroup
===
this
.
groupView
)
{
if
(
typeof
splitDirection
!==
'
number
'
&&
sourceGroup
===
this
.
groupView
)
{
return
;
}
// Split to new group
let
targetGroup
:
INextEditorGroupView
;
if
(
typeof
this
.
splitDirection
===
'
number
'
)
{
if
(
typeof
splitDirection
===
'
number
'
)
{
if
(
this
.
isCopyOperation
(
event
))
{
targetGroup
=
this
.
accessor
.
copyGroup
(
sourceGroup
,
this
.
groupView
,
this
.
splitDirection
);
targetGroup
=
this
.
accessor
.
copyGroup
(
sourceGroup
,
this
.
groupView
,
splitDirection
);
}
else
{
targetGroup
=
this
.
accessor
.
moveGroup
(
sourceGroup
,
this
.
groupView
,
this
.
splitDirection
);
targetGroup
=
this
.
accessor
.
moveGroup
(
sourceGroup
,
this
.
groupView
,
splitDirection
);
}
}
...
...
@@ -270,7 +302,7 @@ class DropOverlay extends Themable {
setTimeout
(()
=>
addClass
(
this
.
overlay
,
'
overlay-move-transition
'
),
0
);
// Remember as current split direction
this
.
splitDirection
=
splitDirection
;
this
.
currentDropOperation
=
{
splitDirection
}
;
}
private
doPositionOverlay
(
options
:
{
top
:
string
,
left
:
string
,
width
:
string
,
height
:
string
}):
void
{
...
...
@@ -288,6 +320,17 @@ class DropOverlay extends Themable {
return
0
;
}
private
hideOverlay
():
void
{
// Reset overlay
this
.
doPositionOverlay
({
top
:
'
0
'
,
left
:
'
0
'
,
width
:
'
100%
'
,
height
:
'
100%
'
});
this
.
overlay
.
style
.
opacity
=
'
0
'
;
removeClass
(
this
.
overlay
,
'
overlay-move-transition
'
);
// Reset current operation
this
.
currentDropOperation
=
void
0
;
}
contains
(
element
:
HTMLElement
):
boolean
{
return
element
===
this
.
container
||
element
===
this
.
overlay
;
}
...
...
@@ -359,30 +402,13 @@ export class NextEditorDropTarget extends Themable {
// Create overlay over target
if
(
!
this
.
overlay
)
{
const
sourceGroupView
=
this
.
findSourceGroupView
();
const
targetGroupView
=
this
.
findTargetGroupView
(
target
);
if
(
!
targetGroupView
)
{
return
;
// we need a target at least
}
if
(
sourceGroupView
===
targetGroupView
)
{
const
isGroupTransfer
=
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
);
if
(
isGroupTransfer
)
{
return
;
// do not allow to drop group on itself
}
const
isEditorTransfer
=
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
);
if
(
isEditorTransfer
&&
sourceGroupView
.
count
<
2
)
{
return
;
// do not allow to drop editor on itself unless there are 2 editors at least
}
}
// Show overlay
if
(
targetGroupView
)
{
this
.
_overlay
=
new
DropOverlay
(
this
.
accessor
,
targetGroupView
,
this
.
themeService
,
this
.
instantiationService
);
}
}
}
}
private
onDragLeave
():
void
{
this
.
counter
--
;
...
...
@@ -399,21 +425,6 @@ export class NextEditorDropTarget extends Themable {
this
.
disposeOverlay
();
}
private
findSourceGroupView
():
INextEditorGroupView
{
// Check for group transfer
if
(
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
groupTransfer
.
getData
(
DraggedEditorGroupIdentifier
.
prototype
)[
0
].
identifier
);
}
// Check for editor transfer
else
if
(
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
editorTransfer
.
getData
(
DraggedEditorIdentifier
.
prototype
)[
0
].
identifier
.
group
.
id
);
}
return
void
0
;
}
private
findTargetGroupView
(
child
:
HTMLElement
):
INextEditorGroupView
{
const
groups
=
this
.
accessor
.
groups
;
for
(
let
i
=
0
;
i
<
groups
.
length
;
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录