Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f25f1abf
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,发现更多精彩内容 >>
提交
f25f1abf
编写于
11月 20, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
give the option completely to notebook extension for now.
上级
d5a74a91
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
56 deletion
+51
-56
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
...workbench/contrib/notebook/browser/contrib/coreActions.ts
+16
-31
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+0
-1
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
...bench/contrib/notebook/browser/view/renderers/codeCell.ts
+23
-23
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+12
-1
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
浏览文件 @
f25f1abf
...
...
@@ -6,7 +6,7 @@
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
KeyChord
,
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
getIconClasses
}
from
'
vs/editor/common/services/getIconClasses
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -21,9 +21,9 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
CATEGORIES
}
from
'
vs/workbench/common/actions
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CellFocusMode
,
EXECUTE_CELL_COMMAND_ID
,
EXPAND_CELL_CONTENT_COMMAND_ID
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_EDITOR_FOCUSED
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
NOTEBOOK_CELL_LIST_FOCUSED
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
,
NOTEBOOK_OUTPUT_FOCUSED
,
TRUST_NOTEBOOK_COMMAND_ID
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CellFocusMode
,
EXECUTE_CELL_COMMAND_ID
,
EXPAND_CELL_CONTENT_COMMAND_ID
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_EDITOR_FOCUSED
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_INPUT_COLLAPSED
,
NOTEBOOK_CELL_LIST_FOCUSED
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_OUTPUT_COLLAPSED
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
,
NOTEBOOK_OUTPUT_FOCUSED
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
CellEditType
,
CellKind
,
ICellEditOperation
,
ICellRange
,
isDocumentExcludePattern
,
NotebookCellMetadata
,
NotebookCellRunState
,
N
otebookDocumentMetadata
,
N
OTEBOOK_EDITOR_CURSOR_BEGIN_END
,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY
,
TransientMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellEditType
,
CellKind
,
ICellEditOperation
,
ICellRange
,
isDocumentExcludePattern
,
NotebookCellMetadata
,
NotebookCellRunState
,
NOTEBOOK_EDITOR_CURSOR_BEGIN_END
,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY
,
TransientMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -1823,34 +1823,6 @@ registerAction2(class extends ChangeNotebookCellMetadataAction {
}
});
abstract
class
ChangeNotebookMetadataAction
extends
NotebookCellAction
{
async
runWithContext
(
accessor
:
ServicesAccessor
,
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
const
textModel
=
context
.
notebookEditor
.
viewModel
?.
notebookDocument
;
if
(
!
textModel
)
{
return
;
}
textModel
.
applyEdits
(
textModel
.
versionId
,
[{
editType
:
CellEditType
.
DocumentMetadata
,
metadata
:
{
...
textModel
.
metadata
,
...
this
.
getMetadataDelta
()
}
}],
true
,
undefined
,
()
=>
undefined
,
undefined
);
}
abstract
getMetadataDelta
():
Partial
<
NotebookDocumentMetadata
>
;
}
registerAction2
(
class
extends
ChangeNotebookMetadataAction
{
constructor
()
{
super
({
id
:
TRUST_NOTEBOOK_COMMAND_ID
,
title
:
localize
(
'
notebook.trust
'
,
"
Trust Current Notebook Document
"
),
});
}
getMetadataDelta
():
Partial
<
NotebookDocumentMetadata
>
{
return
{
trusted
:
true
};
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
...
...
@@ -1894,6 +1866,19 @@ registerAction2(class extends Action2 {
}
});
// Revisit once we have a story for trusted workspace
CommandsRegistry
.
registerCommand
(
'
notebook.trust
'
,
(
accessor
,
args
)
=>
{
const
uri
=
URI
.
revive
(
args
as
UriComponents
);
const
notebookService
=
accessor
.
get
<
INotebookService
>
(
INotebookService
);
const
document
=
notebookService
.
listNotebookDocuments
().
find
(
document
=>
document
.
uri
.
toString
()
===
uri
.
toString
());
if
(
document
)
{
document
.
applyEdits
(
document
.
versionId
,
[{
editType
:
CellEditType
.
DocumentMetadata
,
metadata
:
{
...
document
.
metadata
,
...{
trusted
:
true
}
}
}],
true
,
undefined
,
()
=>
undefined
,
undefined
,
false
);
}
});
CommandsRegistry
.
registerCommand
(
'
_resolveNotebookContentProvider
'
,
(
accessor
,
args
):
{
viewType
:
string
;
displayName
:
string
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
f25f1abf
...
...
@@ -61,7 +61,6 @@ export const NOTEBOOK_CELL_OUTPUT_COLLAPSED = new RawContextKey<boolean>('notebo
// Shared commands
export
const
EXPAND_CELL_CONTENT_COMMAND_ID
=
'
notebook.cell.expandCellContent
'
;
export
const
EXECUTE_CELL_COMMAND_ID
=
'
notebook.cell.execute
'
;
export
const
TRUST_NOTEBOOK_COMMAND_ID
=
'
notebook.trust
'
;
// Kernels
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
浏览文件 @
f25f1abf
...
...
@@ -12,14 +12,14 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IQuickInputService
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellFocusMode
,
CodeCellRenderTemplate
,
INotebookEditor
,
TRUST_NOTEBOOK_COMMAND_ID
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFocusMode
,
CodeCellRenderTemplate
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ClickTargetType
,
getExecuteCellPlaceholder
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellWidgets
'
;
import
{
OutputContainer
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellOutput
'
;
import
{
INotebookCellStatusBarService
}
from
'
vs/workbench/contrib/notebook/common/notebookCellStatusBarService
'
;
import
{
CellStatusbarAlignment
,
NotebookCellsChangeType
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellsChangeType
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
class
CodeCell
extends
Disposable
{
...
...
@@ -248,35 +248,35 @@ export class CodeCell extends Disposable {
updatePlaceholder
();
}));
const
updateUntrustedStatus
=
()
=>
{
if
(
this
.
notebookEditor
.
viewModel
&&
this
.
notebookEditor
.
viewModel
.
metadata
.
trusted
)
{
this
.
_untrustedStatusItem
?.
dispose
();
this
.
_untrustedStatusItem
=
null
;
}
else
{
if
(
this
.
_untrustedStatusItem
===
null
)
{
this
.
_untrustedStatusItem
=
this
.
notebookCellStatusBarService
.
addEntry
({
alignment
:
CellStatusbarAlignment
.
LEFT
,
priority
:
-
1
,
cellResource
:
viewCell
.
uri
,
command
:
TRUST_NOTEBOOK_COMMAND_ID
,
text
:
'
Untrusted
'
,
tooltip
:
'
Untrusted notebook
'
,
visible
:
true
,
});
}
}
};
//
const updateUntrustedStatus = () => {
//
if (this.notebookEditor.viewModel
//
&& this.notebookEditor.viewModel.metadata.trusted) {
//
this._untrustedStatusItem?.dispose();
//
this._untrustedStatusItem = null;
//
} else {
//
if (this._untrustedStatusItem === null) {
//
this._untrustedStatusItem = this.notebookCellStatusBarService.addEntry({
//
alignment: CellStatusbarAlignment.LEFT,
//
priority: -1,
//
cellResource: viewCell.uri,
//
command: TRUST_NOTEBOOK_COMMAND_ID,
//
text: 'Untrusted',
//
tooltip: 'Untrusted notebook',
//
visible: true,
//
});
//
}
//
}
//
};
this
.
_register
(
this
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
onDidChangeContent
(
e
=>
{
if
(
e
.
rawEvents
.
find
(
event
=>
event
.
kind
===
NotebookCellsChangeType
.
ChangeDocumentMetadata
))
{
updatePlaceholder
();
updateUntrustedStatus
();
//
updateUntrustedStatus();
}
}));
updatePlaceholder
();
updateUntrustedStatus
();
//
updateUntrustedStatus();
}
private
viewUpdate
():
void
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
f25f1abf
...
...
@@ -483,6 +483,17 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}
}
private
_isDocumentMetadataChangeTransient
(
a
:
NotebookDocumentMetadata
,
b
:
NotebookDocumentMetadata
)
{
const
keys
=
new
Set
([...
Object
.
keys
(
a
||
{}),
...
Object
.
keys
(
b
||
{})]);
for
(
let
key
of
keys
)
{
if
(
key
!==
'
trusted
'
)
{
return
true
;
}
}
return
false
;
}
private
_updateNotebookMetadata
(
metadata
:
NotebookDocumentMetadata
,
computeUndoRedo
:
boolean
)
{
const
oldMetadata
=
this
.
metadata
;
this
.
metadata
=
metadata
;
...
...
@@ -504,7 +515,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
}(),
undefined
,
undefined
);
}
this
.
_eventEmitter
.
emit
({
kind
:
NotebookCellsChangeType
.
ChangeDocumentMetadata
,
metadata
:
this
.
metadata
,
transient
:
false
},
true
);
this
.
_eventEmitter
.
emit
({
kind
:
NotebookCellsChangeType
.
ChangeDocumentMetadata
,
metadata
:
this
.
metadata
,
transient
:
this
.
_isDocumentMetadataChangeTransient
(
oldMetadata
,
metadata
)
},
true
);
}
private
_insertNewCell
(
index
:
number
,
cells
:
NotebookCellTextModel
[],
synchronous
:
boolean
,
endSelections
?:
number
[]):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录