Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ac05ae7b
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,发现更多精彩内容 >>
未验证
提交
ac05ae7b
编写于
6月 02, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move file'ish things into workspace namespace
上级
0b6e7030
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
121 addition
and
127 deletion
+121
-127
extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts
...pi-tests/src/singlefolder-tests/notebook.document.test.ts
+19
-19
extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts
...-api-tests/src/singlefolder-tests/notebook.editor.test.ts
+4
-4
extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts
.../vscode-api-tests/src/singlefolder-tests/notebook.test.ts
+5
-5
extensions/vscode-api-tests/src/singlefolder-tests/rpc.test.ts
...sions/vscode-api-tests/src/singlefolder-tests/rpc.test.ts
+2
-2
extensions/vscode-notebook-tests/src/extension.ts
extensions/vscode-notebook-tests/src/extension.ts
+2
-2
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+59
-65
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-2
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+28
-28
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts
浏览文件 @
ac05ae7b
...
...
@@ -48,22 +48,22 @@ suite('Notebook Document', function () {
});
suiteSetup
(
function
()
{
disposables
.
push
(
vscode
.
notebook
.
registerNotebookContentProvider
(
'
notebook.nbdtest
'
,
complexContentProvider
));
disposables
.
push
(
vscode
.
notebook
.
registerNotebookSerializer
(
'
notebook.nbdserializer
'
,
simpleContentProvider
));
disposables
.
push
(
vscode
.
workspace
.
registerNotebookContentProvider
(
'
notebook.nbdtest
'
,
complexContentProvider
));
disposables
.
push
(
vscode
.
workspace
.
registerNotebookSerializer
(
'
notebook.nbdserializer
'
,
simpleContentProvider
));
});
test
(
'
cannot register sample provider multiple times
'
,
function
()
{
assert
.
throws
(()
=>
{
vscode
.
notebook
.
registerNotebookContentProvider
(
'
notebook.nbdtest
'
,
complexContentProvider
);
vscode
.
workspace
.
registerNotebookContentProvider
(
'
notebook.nbdtest
'
,
complexContentProvider
);
});
// assert.throws(() => {
// vscode.
notebook
.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider);
// vscode.
workspace
.registerNotebookSerializer('notebook.nbdserializer', simpleContentProvider);
// });
});
test
(
'
cannot open unknown types
'
,
async
function
()
{
try
{
await
vscode
.
notebook
.
openNotebookDocument
(
vscode
.
Uri
.
parse
(
'
some:///thing.notTypeKnown
'
));
await
vscode
.
workspace
.
openNotebookDocument
(
vscode
.
Uri
.
parse
(
'
some:///thing.notTypeKnown
'
));
assert
.
ok
(
false
);
}
catch
{
assert
.
ok
(
true
);
...
...
@@ -72,7 +72,7 @@ suite('Notebook Document', function () {
test
(
'
document basics
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
notebook
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
notebook
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
assert
.
strictEqual
(
notebook
.
uri
.
toString
(),
uri
.
toString
());
assert
.
strictEqual
(
notebook
.
isDirty
,
false
);
...
...
@@ -92,7 +92,7 @@ suite('Notebook Document', function () {
// ignore other open events
return
;
}
const
notebook
=
vscode
.
notebook
.
notebookDocuments
.
find
(
notebook
=>
{
const
notebook
=
vscode
.
workspace
.
notebookDocuments
.
find
(
notebook
=>
{
const
cell
=
notebook
.
getCells
().
find
(
cell
=>
cell
.
document
===
doc
);
return
Boolean
(
cell
);
});
...
...
@@ -108,7 +108,7 @@ suite('Notebook Document', function () {
},
15000
);
});
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
await
p
;
assert
.
strictEqual
(
didHappen
,
true
);
});
...
...
@@ -116,7 +116,7 @@ suite('Notebook Document', function () {
test
(
'
notebook open/close, all cell-documents are ready
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
p
=
utils
.
asPromise
(
vscode
.
notebook
.
onDidOpenNotebookDocument
).
then
(
notebook
=>
{
const
p
=
utils
.
asPromise
(
vscode
.
workspace
.
onDidOpenNotebookDocument
).
then
(
notebook
=>
{
for
(
let
i
=
0
;
i
<
notebook
.
cellCount
;
i
++
)
{
let
cell
=
notebook
.
cellAt
(
i
);
...
...
@@ -130,12 +130,12 @@ suite('Notebook Document', function () {
}
});
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
await
p
;
});
test
(
'
open untitled notebook
'
,
async
function
()
{
const
nb
=
await
vscode
.
notebook
.
openNotebookDocument
(
'
notebook.nbdserializer
'
);
const
nb
=
await
vscode
.
workspace
.
openNotebookDocument
(
'
notebook.nbdserializer
'
);
assert
.
strictEqual
(
nb
.
isUntitled
,
true
);
assert
.
strictEqual
(
nb
.
isClosed
,
false
);
assert
.
strictEqual
(
nb
.
uri
.
scheme
,
'
untitled
'
);
...
...
@@ -143,7 +143,7 @@ suite('Notebook Document', function () {
});
test
(
'
open untitled with data
'
,
async
function
()
{
const
nb
=
await
vscode
.
notebook
.
openNotebookDocument
(
const
nb
=
await
vscode
.
workspace
.
openNotebookDocument
(
'
notebook.nbdserializer
'
,
new
vscode
.
NotebookData
([
new
vscode
.
NotebookCellData
(
vscode
.
NotebookCellKind
.
Code
,
'
console.log()
'
,
'
javascript
'
),
...
...
@@ -162,7 +162,7 @@ suite('Notebook Document', function () {
test
(
'
workspace edit API (replaceCells)
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
document
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
document
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
assert
.
strictEqual
(
document
.
cellCount
,
1
);
// inserting two new cells
...
...
@@ -237,7 +237,7 @@ suite('Notebook Document', function () {
test
(
'
workspace edit API (replaceCells, event)
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
document
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
document
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
assert
.
strictEqual
(
document
.
cellCount
,
1
);
const
edit
=
new
vscode
.
WorkspaceEdit
();
...
...
@@ -279,7 +279,7 @@ suite('Notebook Document', function () {
test
(
'
document save API
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
notebook
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
notebook
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
assert
.
strictEqual
(
notebook
.
uri
.
toString
(),
uri
.
toString
());
assert
.
strictEqual
(
notebook
.
isDirty
,
false
);
...
...
@@ -314,7 +314,7 @@ suite('Notebook Document', function () {
test
(
'
setTextDocumentLanguage for notebook cells
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
notebook
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
notebook
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
const
first
=
notebook
.
cellAt
(
0
);
assert
.
strictEqual
(
first
.
document
.
languageId
,
'
javascript
'
);
...
...
@@ -334,7 +334,7 @@ suite('Notebook Document', function () {
test
(
'
setTextDocumentLanguage when notebook editor is not open
'
,
async
function
()
{
const
uri
=
await
utils
.
createRandomFile
(
''
,
undefined
,
'
.nbdtest
'
);
const
notebook
=
await
vscode
.
notebook
.
openNotebookDocument
(
uri
);
const
notebook
=
await
vscode
.
workspace
.
openNotebookDocument
(
uri
);
const
firstCelUri
=
notebook
.
cellAt
(
0
).
document
.
uri
;
await
vscode
.
commands
.
executeCommand
(
'
workbench.action.closeActiveEditor
'
);
...
...
@@ -345,7 +345,7 @@ suite('Notebook Document', function () {
test
(
'
dirty state - complex
'
,
async
function
()
{
const
resource
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
document
=
await
vscode
.
notebook
.
openNotebookDocument
(
resource
);
const
document
=
await
vscode
.
workspace
.
openNotebookDocument
(
resource
);
assert
.
strictEqual
(
document
.
isDirty
,
false
);
const
edit
=
new
vscode
.
WorkspaceEdit
();
...
...
@@ -360,7 +360,7 @@ suite('Notebook Document', function () {
test
(
'
dirty state - serializer
'
,
async
function
()
{
const
resource
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdserializer
'
);
const
document
=
await
vscode
.
notebook
.
openNotebookDocument
(
resource
);
const
document
=
await
vscode
.
workspace
.
openNotebookDocument
(
resource
);
assert
.
strictEqual
(
document
.
isDirty
,
false
);
const
edit
=
new
vscode
.
WorkspaceEdit
();
...
...
extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts
浏览文件 @
ac05ae7b
...
...
@@ -29,19 +29,19 @@ suite('Notebook Editor', function () {
utils
.
disposeAll
(
disposables
);
disposables
.
length
=
0
;
for
(
let
doc
of
vscode
.
notebook
.
notebookDocuments
)
{
for
(
let
doc
of
vscode
.
workspace
.
notebookDocuments
)
{
assert
.
strictEqual
(
doc
.
isDirty
,
false
,
doc
.
uri
.
toString
());
}
});
suiteSetup
(
function
()
{
disposables
.
push
(
vscode
.
notebook
.
registerNotebookSerializer
(
'
notebook.nbdtest
'
,
contentSerializer
));
disposables
.
push
(
vscode
.
workspace
.
registerNotebookSerializer
(
'
notebook.nbdtest
'
,
contentSerializer
));
});
test
(
'
showNotebookDocment
'
,
async
function
()
{
const
p
=
utils
.
asPromise
(
vscode
.
notebook
.
onDidOpenNotebookDocument
);
const
p
=
utils
.
asPromise
(
vscode
.
workspace
.
onDidOpenNotebookDocument
);
const
uri
=
await
utils
.
createRandomFile
(
undefined
,
undefined
,
'
.nbdtest
'
);
const
editor
=
await
vscode
.
window
.
showNotebookDocument
(
uri
);
...
...
@@ -50,7 +50,7 @@ suite('Notebook Editor', function () {
const
event
=
await
p
;
assert
.
strictEqual
(
event
.
uri
.
toString
(),
uri
.
toString
());
const
includes
=
vscode
.
notebook
.
notebookDocuments
.
includes
(
editor
.
document
);
const
includes
=
vscode
.
workspace
.
notebookDocuments
.
includes
(
editor
.
document
);
assert
.
strictEqual
(
true
,
includes
);
});
...
...
extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts
浏览文件 @
ac05ae7b
...
...
@@ -15,7 +15,7 @@ async function createRandomNotebookFile() {
async
function
openRandomNotebookDocument
()
{
const
uri
=
await
createRandomNotebookFile
();
return
vscode
.
notebook
.
openNotebookDocument
(
uri
);
return
vscode
.
workspace
.
openNotebookDocument
(
uri
);
}
async
function
saveAllFilesAndCloseAll
()
{
...
...
@@ -104,7 +104,7 @@ suite('Notebook API tests', function () {
});
suiteSetup
(
function
()
{
suiteDisposables
.
push
(
vscode
.
notebook
.
registerNotebookContentProvider
(
'
notebookCoreTest
'
,
{
suiteDisposables
.
push
(
vscode
.
workspace
.
registerNotebookContentProvider
(
'
notebookCoreTest
'
,
{
openNotebook
:
async
(
resource
:
vscode
.
Uri
):
Promise
<
vscode
.
NotebookData
>
=>
{
if
(
/.*empty
\-
.*
\.
vsctestnb$/
.
test
(
resource
.
path
))
{
return
{
...
...
@@ -166,7 +166,7 @@ suite('Notebook API tests', function () {
kernel1
=
new
Kernel
(
'
mainKernel
'
,
'
Notebook Primary Test Kernel
'
);
const
listener
=
vscode
.
notebook
.
onDidOpenNotebookDocument
(
async
notebook
=>
{
const
listener
=
vscode
.
workspace
.
onDidOpenNotebookDocument
(
async
notebook
=>
{
if
(
notebook
.
notebookType
===
kernel1
.
controller
.
notebookType
)
{
await
vscode
.
commands
.
executeCommand
(
'
notebook.selectKernel
'
,
{
extension
:
'
vscode.vscode-api-tests
'
,
...
...
@@ -204,7 +204,7 @@ suite('Notebook API tests', function () {
test
(
'
shared document in notebook editors
'
,
async
function
()
{
let
counter
=
0
;
testDisposables
.
push
(
vscode
.
notebook
.
onDidOpenNotebookDocument
(()
=>
{
testDisposables
.
push
(
vscode
.
workspace
.
onDidOpenNotebookDocument
(()
=>
{
counter
++
;
}));
...
...
@@ -1149,7 +1149,7 @@ suite('Notebook API tests', function () {
test
(
'
#115855 onDidSaveNotebookDocument
'
,
async
function
()
{
const
resource
=
await
createRandomNotebookFile
();
const
notebook
=
await
vscode
.
notebook
.
openNotebookDocument
(
resource
);
const
notebook
=
await
vscode
.
workspace
.
openNotebookDocument
(
resource
);
const
editor
=
await
vscode
.
window
.
showNotebookDocument
(
notebook
);
const
cellsChangeEvent
=
asPromise
<
vscode
.
NotebookCellsChangeEvent
>
(
vscode
.
notebook
.
onDidChangeNotebookCells
);
...
...
extensions/vscode-api-tests/src/singlefolder-tests/rpc.test.ts
浏览文件 @
ac05ae7b
...
...
@@ -90,13 +90,13 @@ suite('vscode', function () {
});
test
(
'
no rpc, createNotebookEditorDecorationType(...)
'
,
function
()
{
const
item
=
vscode
.
notebook
.
createNotebookEditorDecorationType
({
top
:
{}
});
const
item
=
vscode
.
notebook
s
.
createNotebookEditorDecorationType
({
top
:
{}
});
dispo
.
push
(
item
);
assertNoRpcFromEntry
([
item
,
'
NotebookEditorDecorationType
'
]);
});
test
(
'
no rpc, createNotebookController(...)
'
,
function
()
{
const
ctrl
=
vscode
.
notebook
.
createNotebookController
(
'
foo
'
,
'
bar
'
,
''
);
const
ctrl
=
vscode
.
notebook
s
.
createNotebookController
(
'
foo
'
,
'
bar
'
,
''
);
dispo
.
push
(
ctrl
);
assertNoRpcFromEntry
([
ctrl
,
'
NotebookController
'
]);
});
...
...
extensions/vscode-notebook-tests/src/extension.ts
浏览文件 @
ac05ae7b
...
...
@@ -20,7 +20,7 @@ export function activate(context: vscode.ExtensionContext): any {
await
vscode
.
commands
.
executeCommand
(
'
vscode.open
'
,
vscode
.
Uri
.
file
(
notebookPath
));
}));
context
.
subscriptions
.
push
(
vscode
.
notebook
.
registerNotebookContentProvider
(
'
notebookSmokeTest
'
,
{
context
.
subscriptions
.
push
(
vscode
.
workspace
.
registerNotebookContentProvider
(
'
notebookSmokeTest
'
,
{
openNotebook
:
async
(
_resource
:
vscode
.
Uri
)
=>
{
const
dto
:
vscode
.
NotebookData
=
{
metadata
:
{},
...
...
@@ -58,7 +58,7 @@ export function activate(context: vscode.ExtensionContext): any {
}
}));
const
controller
=
vscode
.
notebook
.
createNotebookController
(
const
controller
=
vscode
.
notebook
s
.
createNotebookController
(
'
notebookSmokeTest
'
,
'
notebookSmokeTest
'
,
'
notebookSmokeTest
'
...
...
src/vs/vscode.d.ts
浏览文件 @
ac05ae7b
...
...
@@ -10639,6 +10639,65 @@ declare module 'vscode' {
*/
export
const
onDidSaveTextDocument
:
Event
<
TextDocument
>
;
/**
* All notebook documents currently known to the editor.
*/
export
const
notebookDocuments
:
readonly
NotebookDocument
[];
/**
* Open a notebook. Will return early if this notebook is already {@link notebook.notebookDocuments loaded}. Otherwise
* the notebook is loaded and the {@link notebook.onDidOpenNotebookDocument `onDidOpenNotebookDocument`}-event fires.
*
* *Note* that the lifecycle of the returned notebook is owned by the editor and not by the extension. That means an
* {@link notebook.onDidCloseNotebookDocument `onDidCloseNotebookDocument`}-event can occur at any time after.
*
* *Note* that opening a notebook does not show a notebook editor. This function only returns a notebook document which
* can be showns in a notebook editor but it can also be used for other things.
*
* @param uri The resource to open.
* @returns A promise that resolves to a {@link NotebookDocument notebook}
*/
export
function
openNotebookDocument
(
uri
:
Uri
):
Thenable
<
NotebookDocument
>
;
/**
* Open an untitled notebook. The editor will prompt the user for a file
* path when the document is to be saved.
*
* @see {@link openNotebookDocument}
* @param notebookType The notebook type that should be used.
* @param content The initial contents of the notebook.
* @returns A promise that resolves to a {@link NotebookDocument notebook}.
*/
export
function
openNotebookDocument
(
notebookType
:
string
,
content
?:
NotebookData
):
Thenable
<
NotebookDocument
>
;
/**
* Register a {@link NotebookSerializer notebook serializer}.
*
* A notebook serializer must be contributed through the `notebooks` extension point. When opening a notebook file, the editor will send
* the `onNotebook:<notebookType>` activation event, and extensions must register their serializer in return.
*
* @param notebookType A notebook.
* @param serializer A notebook serialzier.
* @param options Optional context options that define what parts of a notebook should be persisted
* @return A {@link Disposable} that unregisters this serializer when being disposed.
*/
export
function
registerNotebookSerializer
(
notebookType
:
string
,
serializer
:
NotebookSerializer
,
options
?:
NotebookDocumentContentOptions
):
Disposable
;
/**
* An event that is emitted when a {@link NotebookDocument notebook} is opened.
*/
export
const
onDidOpenNotebookDocument
:
Event
<
NotebookDocument
>
;
/**
* An event that is emitted when a {@link NotebookDocument notebook} is disposed.
*
* *Note 1:* There is no guarantee that this event fires when an editor tab is closed.
*
* *Note 2:* A notebook can be open but not shown in an editor which means this event can fire
* for a notebook that has not been shown in an editor.
*/
export
const
onDidCloseNotebookDocument
:
Event
<
NotebookDocument
>
;
/**
* An event that is emitted when files are being created.
*
...
...
@@ -12102,71 +12161,6 @@ declare module 'vscode' {
// todo@api what should be in this namespace? should notebookDocuments and friends be in the workspace namespace?
export
namespace
notebooks
{
/**
* All notebook documents currently known to the editor.
*/
// todo@api move to workspace
export
const
notebookDocuments
:
readonly
NotebookDocument
[];
/**
* Open a notebook. Will return early if this notebook is already {@link notebook.notebookDocuments loaded}. Otherwise
* the notebook is loaded and the {@link notebook.onDidOpenNotebookDocument `onDidOpenNotebookDocument`}-event fires.
*
* *Note* that the lifecycle of the returned notebook is owned by the editor and not by the extension. That means an
* {@link notebook.onDidCloseNotebookDocument `onDidCloseNotebookDocument`}-event can occur at any time after.
*
* *Note* that opening a notebook does not show a notebook editor. This function only returns a notebook document which
* can be showns in a notebook editor but it can also be used for other things.
*
* @param uri The resource to open.
* @returns A promise that resolves to a {@link NotebookDocument notebook}
*/
// todo@api move to workspace
export
function
openNotebookDocument
(
uri
:
Uri
):
Thenable
<
NotebookDocument
>
;
/**
* Open an untitled notebook. The editor will prompt the user for a file
* path when the document is to be saved.
*
* @see {@link openNotebookDocument}
* @param notebookType The notebook type that should be used.
* @param content The initial contents of the notebook.
* @returns A promise that resolves to a {@link NotebookDocument notebook}.
*/
// todo@api move to workspace
export
function
openNotebookDocument
(
notebookType
:
string
,
content
?:
NotebookData
):
Thenable
<
NotebookDocument
>
;
/**
* An event that is emitted when a {@link NotebookDocument notebook} is opened.
*/
// todo@api move to workspace
export
const
onDidOpenNotebookDocument
:
Event
<
NotebookDocument
>
;
/**
* An event that is emitted when a {@link NotebookDocument notebook} is disposed.
*
* *Note 1:* There is no guarantee that this event fires when an editor tab is closed.
*
* *Note 2:* A notebook can be open but not shown in an editor which means this event can fire
* for a notebook that has not been shown in an editor.
*/
// todo@api move to workspace
export
const
onDidCloseNotebookDocument
:
Event
<
NotebookDocument
>
;
/**
* Register a {@link NotebookSerializer notebook serializer}.
*
* A notebook serializer must be contributed through the `notebooks` extension point. When opening a notebook file, the editor will send
* the `onNotebook:<notebookType>` activation event, and extensions must register their serializer in return.
*
* @param notebookType A notebook.
* @param serializer A notebook serialzier.
* @param options Optional context options that define what parts of a notebook should be persisted
* @return A {@link Disposable} that unregisters this serializer when being disposed.
*/
// todo@api move to workspace
export
function
registerNotebookSerializer
(
notebookType
:
string
,
serializer
:
NotebookSerializer
,
options
?:
NotebookDocumentContentOptions
):
Disposable
;
/**
* Creates a new notebook controller.
*
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
ac05ae7b
...
...
@@ -1391,7 +1391,7 @@ declare module 'vscode' {
backupNotebook
(
document
:
NotebookDocument
,
context
:
NotebookDocumentBackupContext
,
token
:
CancellationToken
):
Thenable
<
NotebookDocumentBackup
>
;
}
export
namespace
notebooks
{
export
namespace
workspace
{
// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
// TODO@API options duplicates the more powerful variant on NotebookContentProvider
...
...
@@ -1408,7 +1408,7 @@ declare module 'vscode' {
exclusive
?:
boolean
;
}
export
namespace
notebooks
{
export
namespace
workspace
{
// SPECIAL overload with NotebookRegistrationData
export
function
registerNotebookContentProvider
(
notebookType
:
string
,
provider
:
NotebookContentProvider
,
options
?:
NotebookDocumentContentOptions
,
registrationData
?:
NotebookRegistrationData
):
Disposable
;
// SPECIAL overload with NotebookRegistrationData
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
ac05ae7b
...
...
@@ -858,6 +858,34 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
onWillSaveTextDocument
:
(
listener
,
thisArgs
?,
disposables
?)
=>
{
return
extHostDocumentSaveParticipant
.
getOnWillSaveTextDocumentEvent
(
extension
)(
listener
,
thisArgs
,
disposables
);
},
get
notebookDocuments
():
vscode
.
NotebookDocument
[]
{
return
extHostNotebook
.
notebookDocuments
.
map
(
d
=>
d
.
apiNotebook
);
},
async
openNotebookDocument
(
uriOrType
?:
URI
|
string
,
content
?:
vscode
.
NotebookData
)
{
let
uri
:
URI
;
if
(
URI
.
isUri
(
uriOrType
))
{
uri
=
uriOrType
;
await
extHostNotebook
.
openNotebookDocument
(
uriOrType
);
}
else
if
(
typeof
uriOrType
===
'
string
'
)
{
uri
=
URI
.
revive
(
await
extHostNotebook
.
createNotebookDocument
({
viewType
:
uriOrType
,
content
}));
}
else
{
throw
new
Error
(
'
Invalid arguments
'
);
}
return
extHostNotebook
.
getNotebookDocument
(
uri
).
apiNotebook
;
},
get
onDidOpenNotebookDocument
():
Event
<
vscode
.
NotebookDocument
>
{
return
extHostNotebook
.
onDidOpenNotebookDocument
;
},
get
onDidCloseNotebookDocument
():
Event
<
vscode
.
NotebookDocument
>
{
return
extHostNotebook
.
onDidCloseNotebookDocument
;
},
registerNotebookSerializer
(
viewType
:
string
,
serializer
:
vscode
.
NotebookSerializer
,
options
?:
vscode
.
NotebookDocumentContentOptions
,
registration
?:
vscode
.
NotebookRegistrationData
)
{
return
extHostNotebook
.
registerNotebookSerializer
(
extension
,
viewType
,
serializer
,
options
,
extension
.
enableProposedApi
?
registration
:
undefined
);
},
registerNotebookContentProvider
:
(
viewType
:
string
,
provider
:
vscode
.
NotebookContentProvider
,
options
?:
vscode
.
NotebookDocumentContentOptions
,
registration
?:
vscode
.
NotebookRegistrationData
)
=>
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
registerNotebookContentProvider
(
extension
,
viewType
,
provider
,
options
,
extension
.
enableProposedApi
?
registration
:
undefined
);
},
onDidChangeConfiguration
:
(
listener
:
(
_
:
any
)
=>
any
,
thisArgs
?:
any
,
disposables
?:
extHostTypes
.
Disposable
[])
=>
{
return
configProvider
.
onDidChangeConfiguration
(
listener
,
thisArgs
,
disposables
);
},
...
...
@@ -1055,30 +1083,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
// namespace: notebook
const
notebooks
:
typeof
vscode
.
notebooks
=
{
get
notebookDocuments
():
vscode
.
NotebookDocument
[]
{
return
extHostNotebook
.
notebookDocuments
.
map
(
d
=>
d
.
apiNotebook
);
},
async
openNotebookDocument
(
uriOrType
?:
URI
|
string
,
content
?:
vscode
.
NotebookData
)
{
let
uri
:
URI
;
if
(
URI
.
isUri
(
uriOrType
))
{
uri
=
uriOrType
;
await
extHostNotebook
.
openNotebookDocument
(
uriOrType
);
}
else
if
(
typeof
uriOrType
===
'
string
'
)
{
uri
=
URI
.
revive
(
await
extHostNotebook
.
createNotebookDocument
({
viewType
:
uriOrType
,
content
}));
}
else
{
throw
new
Error
(
'
Invalid arguments
'
);
}
return
extHostNotebook
.
getNotebookDocument
(
uri
).
apiNotebook
;
},
get
onDidOpenNotebookDocument
():
Event
<
vscode
.
NotebookDocument
>
{
return
extHostNotebook
.
onDidOpenNotebookDocument
;
},
get
onDidCloseNotebookDocument
():
Event
<
vscode
.
NotebookDocument
>
{
return
extHostNotebook
.
onDidCloseNotebookDocument
;
},
registerNotebookSerializer
(
viewType
:
string
,
serializer
:
vscode
.
NotebookSerializer
,
options
?:
vscode
.
NotebookDocumentContentOptions
,
registration
?:
vscode
.
NotebookRegistrationData
)
{
return
extHostNotebook
.
registerNotebookSerializer
(
extension
,
viewType
,
serializer
,
options
,
extension
.
enableProposedApi
?
registration
:
undefined
);
},
createNotebookController
(
id
:
string
,
notebookType
:
string
,
label
:
string
,
handler
?:
vscode
.
NotebookExecuteHandler
,
rendererScripts
?:
vscode
.
NotebookRendererScript
[])
{
return
extHostNotebookKernels
.
createNotebookController
(
extension
,
id
,
notebookType
,
label
,
handler
,
extension
.
enableProposedApi
?
rendererScripts
:
undefined
);
},
...
...
@@ -1089,10 +1093,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
onDidSaveNotebookDocument
;
},
registerNotebookContentProvider
:
(
viewType
:
string
,
provider
:
vscode
.
NotebookContentProvider
,
options
?:
vscode
.
NotebookDocumentContentOptions
,
registration
?:
vscode
.
NotebookRegistrationData
)
=>
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
registerNotebookContentProvider
(
extension
,
viewType
,
provider
,
options
,
extension
.
enableProposedApi
?
registration
:
undefined
);
},
createNotebookEditorDecorationType
(
options
:
vscode
.
NotebookDecorationRenderOptions
):
vscode
.
NotebookEditorDecorationType
{
checkProposedApiEnabled
(
extension
);
return
extHostNotebook
.
createNotebookEditorDecorationType
(
options
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录