Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
343fdecf
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
343fdecf
编写于
3月 23, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
notebook metadata sync between ext and main
上级
ebb2030e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
120 addition
and
20 deletion
+120
-20
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+10
-0
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+14
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-0
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+36
-9
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+1
-0
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+17
-6
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
...bench/contrib/notebook/browser/view/renderers/codeCell.ts
+5
-0
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+7
-1
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
...ch/contrib/notebook/common/model/notebookCellTextModel.ts
+16
-1
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+10
-2
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+1
-0
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+2
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
343fdecf
...
@@ -1666,6 +1666,9 @@ declare module 'vscode' {
...
@@ -1666,6 +1666,9 @@ declare module 'vscode' {
export
type
CellOutput
=
CellStreamOutput
|
CellErrorOutput
|
CellDisplayOutput
;
export
type
CellOutput
=
CellStreamOutput
|
CellErrorOutput
|
CellDisplayOutput
;
export
interface
NotebookCellMetadata
{
export
interface
NotebookCellMetadata
{
/**
* Controls if the content of a cell is editable or not.
*/
editable
:
boolean
;
editable
:
boolean
;
}
}
...
@@ -1680,7 +1683,14 @@ declare module 'vscode' {
...
@@ -1680,7 +1683,14 @@ declare module 'vscode' {
}
}
export
interface
NotebookDocumentMetadata
{
export
interface
NotebookDocumentMetadata
{
/**
* Controls if users can add or delete cells
*/
editable
:
boolean
;
editable
:
boolean
;
/**
* Default value for [cell editable metadata](#NotebookCellMetadata.editable).
*/
cellEditable
:
boolean
;
}
}
export
interface
NotebookDocument
{
export
interface
NotebookDocument
{
...
...
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
343fdecf
...
@@ -8,7 +8,7 @@ import { MainContext, MainThreadNotebookShape, NotebookExtensionDescription, IEx
...
@@ -8,7 +8,7 @@ import { MainContext, MainThreadNotebookShape, NotebookExtensionDescription, IEx
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
INotebookService
,
IMainNotebookController
}
from
'
vs/workbench/contrib/notebook/browser/notebookService
'
;
import
{
INotebookService
,
IMainNotebookController
}
from
'
vs/workbench/contrib/notebook/browser/notebookService
'
;
import
{
INotebookTextModel
,
INotebookMimeTypeSelector
,
NOTEBOOK_DISPLAY_ORDER
,
NotebookCellsSplice
,
NotebookCellOutputsSplice
,
CellKind
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookTextModel
,
INotebookMimeTypeSelector
,
NOTEBOOK_DISPLAY_ORDER
,
NotebookCellsSplice
,
NotebookCellOutputsSplice
,
CellKind
,
NotebookDocumentMetadata
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
...
@@ -135,6 +135,14 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
...
@@ -135,6 +135,14 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
}
}
}
}
async
$updateNotebookCellMetadata
(
viewType
:
string
,
resource
:
UriComponents
,
handle
:
number
,
metadata
:
NotebookCellMetadata
):
Promise
<
void
>
{
let
controller
=
this
.
_notebookProviders
.
get
(
viewType
);
if
(
controller
)
{
controller
.
updateNotebookCellMetadata
(
resource
,
handle
,
metadata
);
}
}
async
resolveNotebook
(
viewType
:
string
,
uri
:
URI
):
Promise
<
number
|
undefined
>
{
async
resolveNotebook
(
viewType
:
string
,
uri
:
URI
):
Promise
<
number
|
undefined
>
{
let
handle
=
await
this
.
_proxy
.
$resolveNotebook
(
viewType
,
uri
);
let
handle
=
await
this
.
_proxy
.
$resolveNotebook
(
viewType
,
uri
);
return
handle
;
return
handle
;
...
@@ -233,6 +241,11 @@ export class MainThreadNotebookController implements IMainNotebookController {
...
@@ -233,6 +241,11 @@ export class MainThreadNotebookController implements IMainNotebookController {
document
?.
textModel
.
updateNotebookMetadata
(
metadata
);
document
?.
textModel
.
updateNotebookMetadata
(
metadata
);
}
}
updateNotebookCellMetadata
(
resource
:
UriComponents
,
handle
:
number
,
metadata
:
NotebookCellMetadata
)
{
let
document
=
this
.
_mapping
.
get
(
URI
.
from
(
resource
).
toString
());
document
?.
textModel
.
updateNotebookCellMetadata
(
handle
,
metadata
);
}
updateNotebookRenderers
(
resource
:
UriComponents
,
renderers
:
number
[]):
void
{
updateNotebookRenderers
(
resource
:
UriComponents
,
renderers
:
number
[]):
void
{
let
document
=
this
.
_mapping
.
get
(
URI
.
from
(
resource
).
toString
());
let
document
=
this
.
_mapping
.
get
(
URI
.
from
(
resource
).
toString
());
document
?.
textModel
.
updateRenderers
(
renderers
);
document
?.
textModel
.
updateRenderers
(
renderers
);
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
343fdecf
...
@@ -694,6 +694,7 @@ export interface MainThreadNotebookShape extends IDisposable {
...
@@ -694,6 +694,7 @@ export interface MainThreadNotebookShape extends IDisposable {
$createNotebookDocument
(
handle
:
number
,
viewType
:
string
,
resource
:
UriComponents
):
Promise
<
void
>
;
$createNotebookDocument
(
handle
:
number
,
viewType
:
string
,
resource
:
UriComponents
):
Promise
<
void
>
;
$updateNotebookLanguages
(
viewType
:
string
,
resource
:
UriComponents
,
languages
:
string
[]):
Promise
<
void
>
;
$updateNotebookLanguages
(
viewType
:
string
,
resource
:
UriComponents
,
languages
:
string
[]):
Promise
<
void
>
;
$updateNotebookMetadata
(
viewType
:
string
,
resource
:
UriComponents
,
metadata
:
NotebookDocumentMetadata
|
undefined
):
Promise
<
void
>
;
$updateNotebookMetadata
(
viewType
:
string
,
resource
:
UriComponents
,
metadata
:
NotebookDocumentMetadata
|
undefined
):
Promise
<
void
>
;
$updateNotebookCellMetadata
(
viewType
:
string
,
resource
:
UriComponents
,
handle
:
number
,
metadata
:
NotebookCellMetadata
):
Promise
<
void
>
;
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[],
renderers
:
number
[]):
Promise
<
void
>
;
$spliceNotebookCells
(
viewType
:
string
,
resource
:
UriComponents
,
splices
:
NotebookCellsSplice
[],
renderers
:
number
[]):
Promise
<
void
>
;
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[],
renderers
:
number
[]):
Promise
<
void
>
;
$spliceNotebookCellOutputs
(
viewType
:
string
,
resource
:
UriComponents
,
cellHandle
:
number
,
splices
:
NotebookCellOutputsSplice
[],
renderers
:
number
[]):
Promise
<
void
>
;
$postMessage
(
handle
:
number
,
value
:
any
):
Promise
<
boolean
>
;
$postMessage
(
handle
:
number
,
value
:
any
):
Promise
<
boolean
>
;
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
343fdecf
...
@@ -16,6 +16,15 @@ import { INotebookDisplayOrder, ITransformedDisplayOutputDto, IOrderedMimeType,
...
@@ -16,6 +16,15 @@ import { INotebookDisplayOrder, ITransformedDisplayOutputDto, IOrderedMimeType,
import
{
ISplice
}
from
'
vs/base/common/sequence
'
;
import
{
ISplice
}
from
'
vs/base/common/sequence
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
const
notebookDocumentMetadataDefaults
:
vscode
.
NotebookDocumentMetadata
=
{
editable
:
true
,
cellEditable
:
true
};
const
notebookCellMetadataDefaults
:
vscode
.
NotebookCellMetadata
=
{
editable
:
true
};
export
class
ExtHostCell
implements
vscode
.
NotebookCell
{
export
class
ExtHostCell
implements
vscode
.
NotebookCell
{
public
source
:
string
[];
public
source
:
string
[];
...
@@ -27,13 +36,16 @@ export class ExtHostCell implements vscode.NotebookCell {
...
@@ -27,13 +36,16 @@ export class ExtHostCell implements vscode.NotebookCell {
private
_outputMapping
=
new
Set
<
vscode
.
CellOutput
>
();
private
_outputMapping
=
new
Set
<
vscode
.
CellOutput
>
();
constructor
(
constructor
(
private
viewType
:
string
,
private
documentUri
:
URI
,
readonly
handle
:
number
,
readonly
handle
:
number
,
readonly
uri
:
URI
,
readonly
uri
:
URI
,
private
_content
:
string
,
private
_content
:
string
,
public
cellKind
:
CellKind
,
public
cellKind
:
CellKind
,
public
language
:
string
,
public
language
:
string
,
outputs
:
any
[],
outputs
:
any
[],
public
metadata
:
vscode
.
NotebookCellMetadata
,
private
_metadata
:
vscode
.
NotebookCellMetadata
,
private
_proxy
:
MainThreadNotebookShape
)
{
)
{
this
.
source
=
this
.
_content
.
split
(
/
\r
|
\n
|
\r\n
/g
);
this
.
source
=
this
.
_content
.
split
(
/
\r
|
\n
|
\r\n
/g
);
this
.
_outputs
=
outputs
;
this
.
_outputs
=
outputs
;
...
@@ -62,6 +74,20 @@ export class ExtHostCell implements vscode.NotebookCell {
...
@@ -62,6 +74,20 @@ export class ExtHostCell implements vscode.NotebookCell {
this
.
_onDidChangeOutputs
.
fire
(
diffs
);
this
.
_onDidChangeOutputs
.
fire
(
diffs
);
}
}
get
metadata
()
{
return
this
.
_metadata
;
}
set
metadata
(
newMetadata
:
vscode
.
NotebookCellMetadata
)
{
let
newMetadataWithDefaults
=
{
...
notebookCellMetadataDefaults
,
...(
newMetadata
||
{})
};
this
.
_metadata
=
newMetadataWithDefaults
;
this
.
_proxy
.
$updateNotebookCellMetadata
(
this
.
viewType
,
this
.
documentUri
,
this
.
handle
,
newMetadataWithDefaults
);
}
getContent
():
string
{
getContent
():
string
{
if
(
this
.
_textDocument
&&
this
.
_initalVersion
!==
this
.
_textDocument
?.
version
)
{
if
(
this
.
_textDocument
&&
this
.
_initalVersion
!==
this
.
_textDocument
?.
version
)
{
return
this
.
_textDocument
.
getText
();
return
this
.
_textDocument
.
getText
();
...
@@ -131,14 +157,19 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
...
@@ -131,14 +157,19 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
this
.
_proxy
.
$updateNotebookLanguages
(
this
.
viewType
,
this
.
uri
,
this
.
_languages
);
this
.
_proxy
.
$updateNotebookLanguages
(
this
.
viewType
,
this
.
uri
,
this
.
_languages
);
}
}
private
_metadata
:
vscode
.
NotebookDocumentMetadata
|
undefined
=
undefined
;
private
_metadata
:
vscode
.
NotebookDocumentMetadata
=
notebookDocumentMetadataDefaults
;
get
metadata
()
{
get
metadata
()
{
return
this
.
_metadata
;
return
this
.
_metadata
;
}
}
set
metadata
(
newMetadata
:
vscode
.
NotebookDocumentMetadata
|
undefined
)
{
set
metadata
(
newMetadata
:
vscode
.
NotebookDocumentMetadata
|
undefined
)
{
this
.
_metadata
=
newMetadata
;
let
newMetadataWithDefaults
=
{
...
notebookDocumentMetadataDefaults
,
...(
newMetadata
||
{})
};
this
.
_metadata
=
newMetadataWithDefaults
;
this
.
_proxy
.
$updateNotebookMetadata
(
this
.
viewType
,
this
.
uri
,
this
.
_metadata
);
this
.
_proxy
.
$updateNotebookMetadata
(
this
.
viewType
,
this
.
uri
,
this
.
_metadata
);
}
}
...
@@ -341,17 +372,13 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
...
@@ -341,17 +372,13 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
}
}
}
}
const
notebookCellMetadataDefaults
:
vscode
.
NotebookCellMetadata
=
{
editable
:
true
};
export
class
ExtHostNotebookEditor
extends
Disposable
implements
vscode
.
NotebookEditor
{
export
class
ExtHostNotebookEditor
extends
Disposable
implements
vscode
.
NotebookEditor
{
private
_viewColumn
:
vscode
.
ViewColumn
|
undefined
;
private
_viewColumn
:
vscode
.
ViewColumn
|
undefined
;
private
static
_cellhandlePool
:
number
=
0
;
private
static
_cellhandlePool
:
number
=
0
;
onDidReceiveMessage
:
vscode
.
Event
<
any
>
=
this
.
_onDidReceiveMessage
.
event
;
onDidReceiveMessage
:
vscode
.
Event
<
any
>
=
this
.
_onDidReceiveMessage
.
event
;
constructor
(
constructor
(
viewType
:
string
,
private
readonly
viewType
:
string
,
readonly
id
:
string
,
readonly
id
:
string
,
public
uri
:
URI
,
public
uri
:
URI
,
private
_proxy
:
MainThreadNotebookShape
,
private
_proxy
:
MainThreadNotebookShape
,
...
@@ -390,7 +417,7 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
...
@@ -390,7 +417,7 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook
...
notebookCellMetadataDefaults
,
...
notebookCellMetadataDefaults
,
...(
metadata
||
{})
...(
metadata
||
{})
};
};
const
cell
=
new
ExtHostCell
(
handle
,
uri
,
content
,
type
,
language
,
outputs
,
metadata
);
const
cell
=
new
ExtHostCell
(
this
.
viewType
,
this
.
uri
,
handle
,
uri
,
content
,
type
,
language
,
outputs
,
metadata
,
this
.
_proxy
);
return
cell
;
return
cell
;
}
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
343fdecf
...
@@ -255,6 +255,7 @@ export interface CellRenderTemplate {
...
@@ -255,6 +255,7 @@ export interface CellRenderTemplate {
editor
?:
CodeEditorWidget
;
editor
?:
CodeEditorWidget
;
progressBar
?:
ProgressBar
;
progressBar
?:
ProgressBar
;
disposables
:
DisposableStore
;
disposables
:
DisposableStore
;
toJSON
():
void
;
}
}
export
interface
IOutputTransformContribution
{
export
interface
IOutputTransformContribution
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
343fdecf
...
@@ -192,7 +192,8 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
...
@@ -192,7 +192,8 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
cellContainer
:
innerContent
,
cellContainer
:
innerContent
,
editingContainer
:
codeInnerContent
,
editingContainer
:
codeInnerContent
,
disposables
,
disposables
,
toolbar
toolbar
,
toJSON
:
()
=>
{
return
{};
}
};
};
}
}
...
@@ -214,9 +215,14 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
...
@@ -214,9 +215,14 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
elementDisposable
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
elementDisposable
.
add
(
new
StatefullMarkdownCell
(
this
.
notebookEditor
,
element
,
templateData
,
this
.
editorOptions
,
this
.
instantiationService
));
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
markdown
'
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
element
.
metadata
.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_EDITABLE_CONTEXT_KEY
,
this
.
notebookEditor
.
viewModel
?.
metadata
?.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_EDITABLE_CONTEXT_KEY
,
this
.
notebookEditor
.
viewModel
?.
metadata
?.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
markdown
'
);
const
cellEditableKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
element
.
metadata
.
editable
);
elementDisposable
.
add
(
element
.
onDidChangeMetadata
((
e
)
=>
{
cellEditableKey
.
set
(
e
.
editable
);
}));
const
editModeKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY
,
element
.
editState
===
CellEditState
.
Editing
);
const
editModeKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE_CONTEXT_KEY
,
element
.
editState
===
CellEditState
.
Editing
);
elementDisposable
.
add
(
element
.
onDidChangeCellEditState
(()
=>
{
elementDisposable
.
add
(
element
.
onDidChangeCellEditState
(()
=>
{
editModeKey
.
set
(
element
.
editState
===
CellEditState
.
Editing
);
editModeKey
.
set
(
element
.
editState
===
CellEditState
.
Editing
);
...
@@ -307,7 +313,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
...
@@ -307,7 +313,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
runToolbar
,
runToolbar
,
outputContainer
,
outputContainer
,
editor
,
editor
,
disposables
disposables
,
toJSON
:
()
=>
{
return
{};
}
};
};
}
}
...
@@ -350,9 +357,13 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
...
@@ -350,9 +357,13 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
};
};
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
(
templateData
.
container
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
code
'
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
element
.
metadata
.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_EDITABLE_CONTEXT_KEY
,
this
.
notebookEditor
.
viewModel
?.
metadata
?.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_EDITABLE_CONTEXT_KEY
,
this
.
notebookEditor
.
viewModel
?.
metadata
?.
editable
);
contextKeyService
.
createKey
(
NOTEBOOK_CELL_TYPE_CONTEXT_KEY
,
'
code
'
);
const
cellEditableKey
=
contextKeyService
.
createKey
(
NOTEBOOK_CELL_EDITABLE_CONTEXT_KEY
,
element
.
metadata
.
editable
);
elementDisposable
.
add
(
element
.
onDidChangeMetadata
((
e
)
=>
{
cellEditableKey
.
set
(
e
.
editable
);
}));
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
);
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposable
);
templateData
.
toolbar
.
context
=
toolbarContext
;
templateData
.
toolbar
.
context
=
toolbarContext
;
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
浏览文件 @
343fdecf
...
@@ -80,6 +80,11 @@ export class CodeCell extends Disposable {
...
@@ -80,6 +80,11 @@ export class CodeCell extends Disposable {
}
}
}));
}));
templateData
.
editor
?.
updateOptions
({
readOnly
:
!
viewCell
.
metadata
.
editable
});
this
.
_register
(
viewCell
.
onDidChangeMetadata
((
e
)
=>
{
templateData
.
editor
?.
updateOptions
({
readOnly
:
!
e
.
editable
});
}));
let
cellWidthResizeObserver
=
getResizesObserver
(
templateData
.
editorContainer
!
,
{
let
cellWidthResizeObserver
=
getResizesObserver
(
templateData
.
editorContainer
!
,
{
width
:
width
,
width
:
width
,
height
:
totalHeight
height
:
totalHeight
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
343fdecf
...
@@ -9,7 +9,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
...
@@ -9,7 +9,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ICell
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
ICell
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CursorAtBoundary
,
CellFocusMode
,
CellEditState
,
CellRunState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CursorAtBoundary
,
CellFocusMode
,
CellEditState
,
CellRunState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
EDITOR_TOP_PADDING
,
EDITOR_TOOLBAR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
EDITOR_TOP_PADDING
,
EDITOR_TOOLBAR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
...
@@ -27,6 +27,8 @@ export abstract class BaseCellViewModel extends Disposable {
...
@@ -27,6 +27,8 @@ export abstract class BaseCellViewModel extends Disposable {
readonly
onDidChangeEditorAttachState
=
this
.
_onDidChangeEditorAttachState
.
event
;
readonly
onDidChangeEditorAttachState
=
this
.
_onDidChangeEditorAttachState
.
event
;
protected
readonly
_onDidChangeCursorSelection
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
protected
readonly
_onDidChangeCursorSelection
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
public
readonly
onDidChangeCursorSelection
:
Event
<
void
>
=
this
.
_onDidChangeCursorSelection
.
event
;
public
readonly
onDidChangeCursorSelection
:
Event
<
void
>
=
this
.
_onDidChangeCursorSelection
.
event
;
protected
readonly
_onDidChangeMetadata
:
Emitter
<
NotebookCellMetadata
>
=
this
.
_register
(
new
Emitter
<
NotebookCellMetadata
>
());
public
readonly
onDidChangeMetadata
:
Event
<
NotebookCellMetadata
>
=
this
.
_onDidChangeMetadata
.
event
;
get
handle
()
{
get
handle
()
{
return
this
.
cell
.
handle
;
return
this
.
cell
.
handle
;
}
}
...
@@ -92,6 +94,10 @@ export abstract class BaseCellViewModel extends Disposable {
...
@@ -92,6 +94,10 @@ export abstract class BaseCellViewModel extends Disposable {
constructor
(
readonly
viewType
:
string
,
readonly
notebookHandle
:
number
,
readonly
cell
:
ICell
,
public
id
:
string
)
{
constructor
(
readonly
viewType
:
string
,
readonly
notebookHandle
:
number
,
readonly
cell
:
ICell
,
public
id
:
string
)
{
super
();
super
();
this
.
_register
(
cell
.
onDidChangeMetadata
((
e
)
=>
{
this
.
_onDidChangeMetadata
.
fire
(
e
);
}));
}
}
abstract
hasDynamicHeight
():
boolean
;
abstract
hasDynamicHeight
():
boolean
;
...
...
src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts
浏览文件 @
343fdecf
...
@@ -15,6 +15,9 @@ export class NotebookCellTextModel implements ICell {
...
@@ -15,6 +15,9 @@ export class NotebookCellTextModel implements ICell {
private
_onDidChangeContent
=
new
Emitter
<
void
>
();
private
_onDidChangeContent
=
new
Emitter
<
void
>
();
onDidChangeContent
:
Event
<
void
>
=
this
.
_onDidChangeContent
.
event
;
onDidChangeContent
:
Event
<
void
>
=
this
.
_onDidChangeContent
.
event
;
private
_onDidChangeMetadata
=
new
Emitter
<
NotebookCellMetadata
>
();
onDidChangeMetadata
:
Event
<
NotebookCellMetadata
>
=
this
.
_onDidChangeMetadata
.
event
;
private
_outputs
:
IOutput
[];
private
_outputs
:
IOutput
[];
get
outputs
():
IOutput
[]
{
get
outputs
():
IOutput
[]
{
...
@@ -30,6 +33,17 @@ export class NotebookCellTextModel implements ICell {
...
@@ -30,6 +33,17 @@ export class NotebookCellTextModel implements ICell {
this
.
_buffer
=
null
;
this
.
_buffer
=
null
;
}
}
private
_metadata
:
NotebookCellMetadata
;
get
metadata
()
{
return
this
.
_metadata
;
}
set
metadata
(
newMetadata
:
NotebookCellMetadata
)
{
this
.
_metadata
=
newMetadata
;
this
.
_onDidChangeMetadata
.
fire
(
this
.
_metadata
);
}
private
_buffer
:
PieceTreeTextBufferFactory
|
null
=
null
;
private
_buffer
:
PieceTreeTextBufferFactory
|
null
=
null
;
constructor
(
constructor
(
...
@@ -39,9 +53,10 @@ export class NotebookCellTextModel implements ICell {
...
@@ -39,9 +53,10 @@ export class NotebookCellTextModel implements ICell {
public
language
:
string
,
public
language
:
string
,
public
cellKind
:
CellKind
,
public
cellKind
:
CellKind
,
outputs
:
IOutput
[],
outputs
:
IOutput
[],
public
readonly
metadata
:
NotebookCellMetadata
metadata
:
NotebookCellMetadata
)
{
)
{
this
.
_outputs
=
outputs
;
this
.
_outputs
=
outputs
;
this
.
_metadata
=
metadata
;
}
}
contentChange
()
{
contentChange
()
{
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
343fdecf
...
@@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event';
...
@@ -7,7 +7,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookCellsSplice
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookTextModel
,
NotebookCellOutputsSplice
,
NotebookCellsSplice
,
NotebookDocumentMetadata
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
class
NotebookTextModel
extends
Disposable
implements
INotebookTextModel
{
export
class
NotebookTextModel
extends
Disposable
implements
INotebookTextModel
{
private
readonly
_onWillDispose
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
private
readonly
_onWillDispose
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
...
@@ -20,7 +20,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
...
@@ -20,7 +20,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
private
_cellListeners
:
Map
<
number
,
IDisposable
>
=
new
Map
();
private
_cellListeners
:
Map
<
number
,
IDisposable
>
=
new
Map
();
cells
:
NotebookCellTextModel
[];
cells
:
NotebookCellTextModel
[];
languages
:
string
[]
=
[];
languages
:
string
[]
=
[];
metadata
:
NotebookDocumentMetadata
|
undefined
=
undefined
;
metadata
:
NotebookDocumentMetadata
|
undefined
=
{
editable
:
true
}
;
renderers
=
new
Set
<
number
>
();
renderers
=
new
Set
<
number
>
();
constructor
(
constructor
(
...
@@ -40,6 +40,14 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
...
@@ -40,6 +40,14 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
this
.
metadata
=
metadata
;
this
.
metadata
=
metadata
;
}
}
updateNotebookCellMetadata
(
handle
:
number
,
metadata
:
NotebookCellMetadata
)
{
const
cell
=
this
.
cells
.
find
(
cell
=>
cell
.
handle
===
handle
);
if
(
cell
)
{
cell
.
metadata
=
metadata
;
}
}
updateRenderers
(
renderers
:
number
[])
{
updateRenderers
(
renderers
:
number
[])
{
renderers
.
forEach
(
render
=>
{
renderers
.
forEach
(
render
=>
{
this
.
renderers
.
add
(
render
);
this
.
renderers
.
add
(
render
);
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
343fdecf
...
@@ -132,6 +132,7 @@ export interface ICell {
...
@@ -132,6 +132,7 @@ export interface ICell {
outputs
:
IOutput
[];
outputs
:
IOutput
[];
metadata
:
NotebookCellMetadata
;
metadata
:
NotebookCellMetadata
;
onDidChangeOutputs
?:
Event
<
NotebookCellOutputsSplice
[]
>
;
onDidChangeOutputs
?:
Event
<
NotebookCellOutputsSplice
[]
>
;
onDidChangeMetadata
:
Event
<
NotebookCellMetadata
>
;
resolveTextBufferFactory
():
PieceTreeTextBufferFactory
;
resolveTextBufferFactory
():
PieceTreeTextBufferFactory
;
// TODO@rebornix it should be later on replaced by moving textmodel resolution into CellTextModel
// TODO@rebornix it should be later on replaced by moving textmodel resolution into CellTextModel
contentChange
():
void
;
contentChange
():
void
;
...
...
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
343fdecf
...
@@ -24,6 +24,8 @@ export class TestCell implements ICell {
...
@@ -24,6 +24,8 @@ export class TestCell implements ICell {
uri
:
URI
;
uri
:
URI
;
private
_onDidChangeOutputs
=
new
Emitter
<
NotebookCellOutputsSplice
[]
>
();
private
_onDidChangeOutputs
=
new
Emitter
<
NotebookCellOutputsSplice
[]
>
();
onDidChangeOutputs
:
Event
<
NotebookCellOutputsSplice
[]
>
=
this
.
_onDidChangeOutputs
.
event
;
onDidChangeOutputs
:
Event
<
NotebookCellOutputsSplice
[]
>
=
this
.
_onDidChangeOutputs
.
event
;
private
_onDidChangeMetadata
=
new
Emitter
<
NotebookCellMetadata
>
();
onDidChangeMetadata
:
Event
<
NotebookCellMetadata
>
=
this
.
_onDidChangeMetadata
.
event
;
private
_isDirty
:
boolean
=
false
;
private
_isDirty
:
boolean
=
false
;
private
_outputs
:
IOutput
[];
private
_outputs
:
IOutput
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录