Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5da820a3
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,发现更多精彩内容 >>
提交
5da820a3
编写于
7月 05, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
restore ability to drop folders or *.vsix into Code
上级
1d8a0023
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
111 addition
and
25 deletion
+111
-25
src/vs/base/browser/dnd.ts
src/vs/base/browser/dnd.ts
+9
-7
src/vs/workbench/browser/media/workbench.css
src/vs/workbench/browser/media/workbench.css
+23
-0
src/vs/workbench/electron-browser/window.ts
src/vs/workbench/electron-browser/window.ts
+79
-18
未找到文件。
src/vs/base/browser/dnd.ts
浏览文件 @
5da820a3
...
...
@@ -42,17 +42,19 @@ export class DelayedDragHandler {
}
}
export
function
extractResources
(
e
:
DragEvent
):
URI
[]
{
export
function
extractResources
(
e
:
DragEvent
,
externalOnly
?:
boolean
):
URI
[]
{
const
resources
:
URI
[]
=
[];
if
(
e
.
dataTransfer
.
types
.
length
>
0
)
{
// Check for in-app DND
const
rawData
=
e
.
dataTransfer
.
getData
(
e
.
dataTransfer
.
types
[
0
]);
if
(
rawData
)
{
try
{
resources
.
push
(
URI
.
parse
(
rawData
));
}
catch
(
error
)
{
// Invalid URI
if
(
!
externalOnly
)
{
const
rawData
=
e
.
dataTransfer
.
getData
(
e
.
dataTransfer
.
types
[
0
]);
if
(
rawData
)
{
try
{
resources
.
push
(
URI
.
parse
(
rawData
));
}
catch
(
error
)
{
// Invalid URI
}
}
}
...
...
src/vs/workbench/browser/media/workbench.css
浏览文件 @
5da820a3
...
...
@@ -40,6 +40,29 @@
margin-top
:
7px
;
/* Center the select box */
}
#monaco-workbench-drop-overlay
{
position
:
absolute
;
top
:
0
;
left
:
0
;
height
:
100%
;
width
:
100%
;
z-index
:
3000000
;
}
.vs
#monaco-workbench-drop-overlay
{
background-color
:
rgba
(
51
,
153
,
255
,
0.18
);
}
.vs-dark
#monaco-workbench-drop-overlay
{
background-color
:
rgba
(
83
,
89
,
93
,
0.5
);
}
.hc-black
#monaco-workbench-drop-overlay
{
background
:
none
!important
;
outline
:
2px
dashed
#f38518
;
outline-offset
:
-2px
;
}
/* ---------- Light Theme ---------- */
.vs
.monaco-workbench
{
background-color
:
#F3F3F3
;
}
...
...
src/vs/workbench/electron-browser/window.ts
浏览文件 @
5da820a3
...
...
@@ -8,7 +8,10 @@
import
platform
=
require
(
'
vs/base/common/platform
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
workbenchEditorCommon
=
require
(
'
vs/workbench/common/editor
'
);
import
DND
=
require
(
'
vs/base/browser/dnd
'
);
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
{
Identifiers
}
from
'
vs/workbench/common/constants
'
;
import
{
asFileEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/common/viewletService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
...
...
@@ -17,6 +20,8 @@ import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
ipcRenderer
as
ipc
,
shell
,
remote
}
from
'
electron
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
const
dialog
=
remote
.
dialog
;
...
...
@@ -29,6 +34,13 @@ export interface IWindowConfiguration {
};
}
enum
DraggedFileType
{
UNKNOWN
,
FILE
,
EXTENSION
,
FOLDER
}
export
class
ElectronWindow
{
private
win
:
Electron
.
BrowserWindow
;
private
windowId
:
number
;
...
...
@@ -53,7 +65,7 @@ export class ElectronWindow {
// React to editor input changes (Mac only)
if
(
platform
.
platform
===
platform
.
Platform
.
Mac
)
{
this
.
editorGroupService
.
onEditorsChanged
(()
=>
{
let
fileInput
=
workbenchEditorCommon
.
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
let
fileInput
=
asFileEditorInput
(
this
.
editorService
.
getActiveEditorInput
(),
true
);
let
representedFilename
=
''
;
if
(
fileInput
)
{
representedFilename
=
fileInput
.
getResource
().
fsPath
;
...
...
@@ -63,11 +75,61 @@ export class ElectronWindow {
});
}
// Prevent a dropped link from opening within
[
DOM
.
EventType
.
DRAG_OVER
,
DOM
.
EventType
.
DROP
].
forEach
(
event
=>
{
let
draggedExternalResources
:
URI
[];
let
dropOverlay
:
Builder
;
function
cleanUp
():
void
{
draggedExternalResources
=
void
0
;
if
(
dropOverlay
)
{
dropOverlay
.
destroy
();
dropOverlay
=
void
0
;
}
}
// Detect resources dropped into Code from outside
window
.
document
.
body
.
addEventListener
(
DOM
.
EventType
.
DRAG_OVER
,
(
e
:
DragEvent
)
=>
{
DOM
.
EventHelper
.
stop
(
e
);
if
(
!
draggedExternalResources
)
{
draggedExternalResources
=
DND
.
extractResources
(
e
,
true
/* external only */
);
// Show Code wide overlay if we detect a Folder or Extension to be dragged
if
(
draggedExternalResources
.
some
(
r
=>
{
const
kind
=
this
.
getFileKind
(
r
);
return
kind
===
DraggedFileType
.
FOLDER
||
kind
===
DraggedFileType
.
EXTENSION
;
}))
{
dropOverlay
=
$
(
window
.
document
.
getElementById
(
Identifiers
.
WORKBENCH_CONTAINER
))
.
div
({
id
:
'
monaco-workbench-drop-overlay
'
})
.
on
(
DOM
.
EventType
.
DROP
,
(
e
:
DragEvent
)
=>
{
DOM
.
EventHelper
.
stop
(
e
,
true
);
this
.
focus
();
// make sure this window has focus so that the open call reaches the right window!
ipc
.
send
(
'
vscode:windowOpen
'
,
draggedExternalResources
.
map
(
r
=>
r
.
fsPath
));
// handled from browser process
cleanUp
();
})
.
on
([
DOM
.
EventType
.
DRAG_LEAVE
,
DOM
.
EventType
.
DRAG_END
],
()
=>
{
cleanUp
();
});
}
}
});
// Clear our map and overlay on any finish of DND outside the overlay
[
DOM
.
EventType
.
DROP
,
DOM
.
EventType
.
DRAG_END
].
forEach
(
event
=>
{
window
.
document
.
body
.
addEventListener
(
event
,
(
e
:
DragEvent
)
=>
{
DOM
.
EventHelper
.
stop
(
e
);
});
if
(
!
dropOverlay
||
e
.
target
!==
dropOverlay
.
getHTMLElement
())
{
DOM
.
EventHelper
.
stop
(
e
);
// this prevents opening a real URL inside the shell
cleanUp
();
}
},
true
/* use capture because components within may preventDefault() when they accept the drop */
);
});
// prevent opening a real URL inside the shell
window
.
document
.
body
.
addEventListener
(
DOM
.
EventType
.
DROP
,
(
e
:
DragEvent
)
=>
{
DOM
.
EventHelper
.
stop
(
e
);
});
// Handle window.open() calls
...
...
@@ -86,20 +148,19 @@ export class ElectronWindow {
};
}
public
open
(
pathsToOpen
:
string
[]):
void
;
public
open
(
fileResource
:
URI
):
void
;
public
open
(
pathToOpen
:
string
):
void
;
public
open
(
arg1
:
any
):
void
{
let
pathsToOpen
:
string
[];
if
(
Array
.
isArray
(
arg1
))
{
pathsToOpen
=
arg1
;
}
else
if
(
typeof
arg1
===
'
string
'
)
{
pathsToOpen
=
[
arg1
];
}
else
{
pathsToOpen
=
[(
<
URI
>
arg1
).
fsPath
];
private
getFileKind
(
resource
:
URI
):
DraggedFileType
{
if
(
path
.
extname
(
resource
.
fsPath
)
===
'
.vsix
'
)
{
return
DraggedFileType
.
EXTENSION
;
}
let
kind
=
DraggedFileType
.
UNKNOWN
;
try
{
kind
=
fs
.
statSync
(
resource
.
fsPath
).
isDirectory
()
?
DraggedFileType
.
FOLDER
:
DraggedFileType
.
FILE
;
}
catch
(
error
)
{
// Do not fail in DND handler
}
ipc
.
send
(
'
vscode:windowOpen
'
,
pathsToOpen
);
// handled from browser process
return
kind
;
}
public
openNew
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录