Skip to content

Commit 2853944

Browse files
committed
Add APIClient config
1 parent 85590df commit 2853944

File tree

4 files changed

+18
-29
lines changed

4 files changed

+18
-29
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
},
5252
"Hackmd.enterprise": {
5353
"type": "boolean",
54+
"default": false,
5455
"description": "Check this if you are connecting to HackMD Enterprise server which contains more features."
5556
}
5657
}

src/api.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
import APIClient from '@hackmd/api';
22
import { ExportType } from '@hackmd/api';
3-
const API = new APIClient();
4-
3+
import * as vscode from 'vscode';
4+
const config = {
5+
serverUrl: vscode.workspace.getConfiguration('Hackmd').get('serverURL') as string,
6+
enterprise: vscode.workspace.getConfiguration('Hackmd').get('enterprise') as boolean
7+
};
8+
const API = new APIClient(config);
9+
vscode.workspace.onDidChangeConfiguration(async e => {
10+
if (e.affectsConfiguration('Hackmd')) {
11+
const clicked = await vscode.window.showInformationMessage('Setting updated. Restart to apply this change.', ...['Restart']);
12+
if (clicked === 'Restart') {
13+
vscode.commands.executeCommand("workbench.action.reloadWindow");
14+
}
15+
}
16+
});
517
export { API, ExportType };
618

719

src/commands/snippet.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/extension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import axios from 'axios';
44
import * as vscode from 'vscode';
55
import * as markdownitContainer from 'markdown-it-container';
66
import * as S from 'string';
7-
import { store } from './store'
8-
import { initializeStorage } from './store/storage'
7+
import { store } from './store';
8+
import { initializeStorage } from './store/storage';
99
import * as Prism from 'prismjs';
10-
import { registerCommand } from './commands'
10+
import { registerCommand } from './commands';
1111

1212
require('prismjs/components/prism-wiki');
1313
require('prismjs/components/prism-haskell');

0 commit comments

Comments
 (0)