|
@@ -15,10 +15,16 @@ export class TldrawEditorProvider implements vscode.CustomTextEditorProvider {
|
15
|
15
|
private static readonly viewType = 'tldraw.tldr'
|
16
|
16
|
|
17
|
17
|
public static register = (context: vscode.ExtensionContext): vscode.Disposable => {
|
18
|
|
- // Register the 'Create new Tldraw file' command, which creates
|
19
|
|
- // a temporary .tldr file and opens it in the editor.
|
20
|
|
- vscode.commands.registerCommand('tldraw.tldr.new', () => {
|
21
|
|
- const id = TldrawEditorProvider.newTDFileId++
|
|
18
|
+ // Several commands exist only to prevent the default keyboard shortcuts
|
|
19
|
+ const noopCmds = ['zoomIn', 'zoomOut', 'resetZoom', 'toggleDarkMode']
|
|
20
|
+ noopCmds.forEach((name) =>
|
|
21
|
+ vscode.commands.registerCommand(`${this.viewType}.${name}`, () => null)
|
|
22
|
+ )
|
|
23
|
+
|
|
24
|
+ // Register the 'Create New File' command, which creates a temporary
|
|
25
|
+ // .tldr file and opens it in the editor.
|
|
26
|
+ vscode.commands.registerCommand(`${this.viewType}.new`, () => {
|
|
27
|
+ const id = this.newTDFileId++
|
22
|
28
|
const name = id > 1 ? `New Document ${id}.tldr` : `New Document.tldr`
|
23
|
29
|
|
24
|
30
|
const workspaceFolders = vscode.workspace.workspaceFolders
|
|
@@ -27,34 +33,17 @@ export class TldrawEditorProvider implements vscode.CustomTextEditorProvider {
|
27
|
33
|
vscode.commands.executeCommand(
|
28
|
34
|
'vscode.openWith',
|
29
|
35
|
vscode.Uri.joinPath(path, name).with({ scheme: 'untitled' }),
|
30
|
|
- TldrawEditorProvider.viewType
|
|
36
|
+ this.viewType
|
31
|
37
|
)
|
32
|
38
|
})
|
33
|
39
|
|
34
|
|
- vscode.commands.registerCommand('tldraw.tldr.zoomIn', () => {
|
35
|
|
- // Noop
|
36
|
|
- })
|
37
|
|
-
|
38
|
|
- vscode.commands.registerCommand('tldraw.tldr.zoomOut', () => {
|
39
|
|
- // Noop
|
40
|
|
- })
|
41
|
|
-
|
42
|
|
- vscode.commands.registerCommand('tldraw.tldr.resetZoom', () => {
|
43
|
|
- // Noop
|
44
|
|
- })
|
45
|
|
-
|
46
|
40
|
// Register our editor provider, indicating to VS Code that we can
|
47
|
41
|
// handle files with the .tldr extension.
|
48
|
42
|
return vscode.window.registerCustomEditorProvider(
|
49
|
|
- TldrawEditorProvider.viewType,
|
|
43
|
+ this.viewType,
|
50
|
44
|
new TldrawEditorProvider(context),
|
51
|
45
|
{
|
52
|
|
- webviewOptions: {
|
53
|
|
- // See https://code.visualstudio.com/api/extension-guides/webview#retaincontextwhenhidden
|
54
|
|
- retainContextWhenHidden: true,
|
55
|
|
- },
|
56
|
|
-
|
57
|
|
- // See https://code.visualstudio.com/api/extension-guides/custom-editors#custom-editor-lifecycle
|
|
46
|
+ webviewOptions: { retainContextWhenHidden: true },
|
58
|
47
|
supportsMultipleEditorsPerDocument: true,
|
59
|
48
|
}
|
60
|
49
|
)
|