@@ -7,9 +7,12 @@ import { CodeTour } from "../store";
77import { getStepFileUri , getWorkspaceUri } from "../utils" ;
88
99class CodeTourNotebookProvider implements vscode . NotebookSerializer {
10- originalContent : Uint8Array = new TextEncoder ( ) . encode ( '' ) ;
10+ originalContent : Uint8Array = new TextEncoder ( ) . encode ( "" ) ;
1111
12- async deserializeNotebook ( content : Uint8Array , token : any ) : Promise < vscode . NotebookData > {
12+ async deserializeNotebook (
13+ content : Uint8Array ,
14+ token : any
15+ ) : Promise < vscode . NotebookData > {
1316 this . originalContent = content ;
1417 let contents = new TextDecoder ( ) . decode ( content ) ;
1518
@@ -21,8 +24,8 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer {
2124 const uri = await getStepFileUri ( item , workspaceRoot , tour . ref ) ;
2225 const document = await vscode . workspace . openTextDocument ( uri ) ;
2326
24- const startLine = ( item . line ! > 10 ) ? item . line ! - 10 : 0 ;
25- const endLine = ( item . line ! > 1 ) ? item . line ! - 1 : 0 ;
27+ const startLine = item . line ! > 10 ? item . line ! - 10 : 0 ;
28+ const endLine = item . line ! > 1 ? item . line ! - 1 : 0 ;
2629 const contents = document . getText (
2730 new vscode . Range (
2831 new vscode . Position ( startLine , 0 ) ,
@@ -40,24 +43,39 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer {
4043 let cells : vscode . NotebookCellData [ ] = [ ] ;
4144
4245 // Title cell
43- cells . push ( new vscode . NotebookCellData ( 1 ,
44- `##  CodeTour (${ tour . title } ) - ${ steps . length } steps\n\n${ tour . description === undefined ? '' : tour . description } ` ,
45- 'markdown' ) )
46+ cells . push (
47+ new vscode . NotebookCellData (
48+ 1 ,
49+ `##  CodeTour (${ tour . title } ) - ${
50+ steps . length
51+ } steps\n\n${ tour . description === undefined ? "" : tour . description } `,
52+ "markdown"
53+ )
54+ ) ;
4655
4756 steps . forEach ( ( step , index ) => {
48- cells . push ( new vscode . NotebookCellData ( 2 ,
49- step . contents ,
50- step . language ,
51- [ new vscode . NotebookCellOutput ( [
52- new vscode . NotebookCellOutputItem ( 'text/markdown' , `_Step #${ index + 1 } of ${ steps . length } :_ ${ step . description } ([View File](${ step . uri } ))` )
53- ] ) ]
54- ) )
55- } )
57+ const cell = new vscode . NotebookCellData ( 2 , step . contents , step . language ) ;
58+ cell . outputs = [
59+ new vscode . NotebookCellOutput ( [
60+ new vscode . NotebookCellOutputItem (
61+ new TextEncoder ( ) . encode (
62+ `_Step #${ index + 1 } of ${ steps . length } :_ ${
63+ step . description
64+ } ([View File](${ step . uri } ))`
65+ ) ,
66+ "text/markdown"
67+ )
68+ ] )
69+ ] ;
70+ } ) ;
5671
57- return new vscode . NotebookData ( cells , new vscode . NotebookDocumentMetadata ( true ) )
72+ return new vscode . NotebookData ( cells ) ;
5873 }
5974
60- async serializeNotebook ( data : vscode . NotebookData , token : any ) : Promise < Uint8Array > {
75+ async serializeNotebook (
76+ data : vscode . NotebookData ,
77+ token : any
78+ ) : Promise < Uint8Array > {
6179 return this . originalContent ;
6280 }
6381}
0 commit comments