Add notebook open protocol handler (#6093)

Adds a protocol handler for notebook open, which can be used from browsers
Uses extension-based handler support so all URIs must start with `azuredatastudio://microsoft.notebook`

Adds 2 actions:
- `/new` opens a new empty notebook
- `/open` opens a HTTP/S file as an untitled notebook or text document

Sample URL:
```
azuredatastudio://microsoft.notebook/open?url=https%3A%2F%2Fraw.githubusercontent.com%2Fkevcunnane%2Fmsbuild_ads_demo%2Fmaster%2F0_YoAzdata.ipynb
```
This commit is contained in:
Kevin Cunnane
2019-06-20 11:00:24 -07:00
committed by GitHub
parent 72c3239d63
commit 578ac6cae5
3 changed files with 143 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import * as childProcess from 'child_process';
import * as fs from 'fs-extra';
import * as nls from 'vscode-nls';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
const localize = nls.loadMessageBundle();
@@ -135,3 +136,9 @@ function outputDataChunk(data: string | Buffer, outputChannel: vscode.OutputChan
outputChannel.appendLine(header + line);
});
}
export function isEditorTitleFree(title: string): boolean {
let hasTextDoc = vscode.workspace.textDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1;
let hasNotebookDoc = azdata.nb.notebookDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1;
return !hasTextDoc && !hasNotebookDoc;
}