Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4b132c33
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,发现更多精彩内容 >>
提交
4b132c33
编写于
5月 08, 2020
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweaks from notebook focus PR
上级
08a17329
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
70 addition
and
51 deletion
+70
-51
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
...workbench/contrib/notebook/browser/contrib/coreActions.ts
+38
-5
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+32
-46
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
浏览文件 @
4b132c33
...
...
@@ -66,7 +66,8 @@ const EXECUTE_CELL_INSERT_BELOW = 'notebook.cell.executeAndInsertBelow';
const
CLEAR_CELL_OUTPUTS_COMMAND_ID
=
'
notebook.cell.clearOutputs
'
;
const
CHANGE_CELL_LANGUAGE
=
'
notebook.cell.changeLanguage
'
;
const
FOCUS_OUTPUT_COMMAND_ID
=
'
notebook.cell.focusOutput
'
;
const
FOCUS_IN_OUTPUT_COMMAND_ID
=
'
notebook.cell.focusInOutput
'
;
const
FOCUS_OUT_OUTPUT_COMMAND_ID
=
'
notebook.cell.focusOutOutput
'
;
export
const
NOTEBOOK_ACTIONS_CATEGORY
=
localize
(
'
notebookActions.category
'
,
"
Notebook
"
);
...
...
@@ -1126,14 +1127,16 @@ registerAction2(class extends Action2 {
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
FOCUS_OUTPUT_COMMAND_ID
,
title
:
localize
(
'
focusOutput
'
,
'
Focus
o
utput
'
),
id
:
FOCUS_
IN_
OUTPUT_COMMAND_ID
,
title
:
localize
(
'
focusOutput
'
,
'
Focus
In Active Cell O
utput
'
),
category
:
NOTEBOOK_ACTIONS_CATEGORY
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
NOTEBOOK_EDITOR_FOCUSED
),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
DownArrow
,
weight
:
EDITOR_WIDGET_ACTION_WEIGHT
}
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
DownArrow
,
},
weight
:
KeybindingWeight
.
WorkbenchContrib
},
f1
:
true
});
}
...
...
@@ -1151,6 +1154,36 @@ registerAction2(class extends Action2 {
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
FOCUS_OUT_OUTPUT_COMMAND_ID
,
title
:
localize
(
'
focusOutputOut
'
,
'
Focus Out Active Cell Output
'
),
category
:
NOTEBOOK_ACTIONS_CATEGORY
,
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
NOTEBOOK_EDITOR_FOCUSED
),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
UpArrow
,
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
UpArrow
,
},
weight
:
KeybindingWeight
.
WorkbenchContrib
},
f1
:
true
});
}
async
run
(
accessor
:
ServicesAccessor
,
context
?:
INotebookCellActionContext
):
Promise
<
void
>
{
if
(
!
isCellActionContext
(
context
))
{
context
=
getActiveCellContext
(
accessor
);
if
(
!
context
)
{
return
;
}
}
const
editor
=
context
.
notebookEditor
;
const
activeCell
=
context
.
cell
;
editor
.
focusNotebookCell
(
activeCell
,
'
editor
'
);
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
4b132c33
...
...
@@ -105,6 +105,14 @@ export interface IUpdatePreloadResourceMessage {
resources
:
string
[];
}
function
html
(
strings
:
TemplateStringsArray
,
...
values
:
any
[]):
string
{
let
str
=
''
;
strings
.
forEach
((
string
,
i
)
=>
{
str
+=
string
+
values
[
i
];
});
return
str
;
}
type
IMessage
=
IDimensionMessage
|
IScrollAckMessage
|
IWheelMessage
|
IMouseEnterMessage
|
IMouseLeaveMessage
|
IBlurOutputMessage
;
let
version
=
0
;
...
...
@@ -120,8 +128,6 @@ export class BackLayerWebView extends Disposable {
private
readonly
_onMessage
=
this
.
_register
(
new
Emitter
<
any
>
());
public
readonly
onMessage
:
Event
<
any
>
=
this
.
_onMessage
.
event
;
private
_initalized
:
Promise
<
void
>
;
private
activeCellId
:
string
|
undefined
;
constructor
(
public
notebookEditor
:
INotebookEditor
,
...
...
@@ -174,7 +180,7 @@ ${loaderJs}
}
generateContent
(
outputNodePadding
:
number
,
coreDependencies
:
string
)
{
return
/* html */
`
return
html
`
<html lang="en">
<head>
<meta charset="UTF-8">
...
...
@@ -290,6 +296,21 @@ ${loaderJs}
});
};
function createFocusSink(cellId, focusNext) {
const element = document.createElement('div');
element.tabIndex = 0;
element.addEventListener('focus', () => {
vscode.postMessage({
__vscode_notebook_message: true,
type: 'focus-editor',
id: cellId,
focusNext
});
});
return element;
}
window.addEventListener('wheel', handleWheel);
window.addEventListener('message', event => {
...
...
@@ -303,16 +324,8 @@ ${loaderJs}
if (!cellOutputContainer) {
const container = document.getElementById('container');
let upperWrapperElement = document.createElement('div');
upperWrapperElement.tabIndex = 0;
const upperWrapperElement = createFocusSink(outputId);
container.appendChild(upperWrapperElement);
upperWrapperElement.addEventListener('focus', () => {
vscode.postMessage({
__vscode_notebook_message: true,
type: 'focus-editor',
id: outputId,
});
});
let newElement = document.createElement('div');
...
...
@@ -337,31 +350,8 @@ ${loaderJs}
});
});
const handleKeyDown = (event) => {
if (event.defaultPrevented || !(event.key === 'ArrowUp' && event.ctrlKey)) {
return;
}
vscode.postMessage({
__vscode_notebook_message: true,
type: 'focus-editor',
id: outputId,
});
};
cellOutputContainer.addEventListener("keydown", handleKeyDown);
let lowerWrapperElement = document.createElement('div');
lowerWrapperElement.tabIndex = 0;
const lowerWrapperElement = createFocusSink(outputId, true);
container.appendChild(lowerWrapperElement);
lowerWrapperElement.addEventListener('focus', () => {
vscode.postMessage({
__vscode_notebook_message: true,
type: 'focus-editor',
id: outputId,
focusNext: true
});
});
}
let outputNode = document.createElement('div');
...
...
@@ -466,15 +456,6 @@ ${loaderJs}
initialize
(
content
:
string
)
{
this
.
webview
=
this
.
_createInset
(
this
.
webviewService
,
content
);
this
.
webview
.
mountTo
(
this
.
element
);
this
.
webview
.
onDidFocus
(()
=>
{
if
(
this
.
activeCellId
)
{
this
.
webview
.
sendMessage
({
type
:
'
focus-output
'
,
id
:
this
.
activeCellId
});
this
.
activeCellId
=
undefined
;
}
});
this
.
_register
(
this
.
webview
.
onDidClickLink
(
link
=>
{
this
.
openerService
.
open
(
link
,
{
fromUserGesture
:
true
});
...
...
@@ -679,8 +660,13 @@ ${loaderJs}
}
focusOutput
(
cellId
:
string
)
{
this
.
activeCellId
=
cellId
;
this
.
webview
.
focus
();
setTimeout
(()
=>
{
// Need this, or focus decoration is not shown. No clue.
this
.
webview
.
sendMessage
({
type
:
'
focus-output
'
,
id
:
cellId
});
},
50
);
}
updateRendererPreloads
(
preloads
:
Set
<
number
>
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录