-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.js
41 lines (30 loc) · 953 Bytes
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const vscode = require("vscode")
const pug = require("pug")
const path = require("path")
const utils = require("./utils")
const render = (context, title = "iTodo", datas) => {
const webviewDir = path.join(context.extensionPath, '.')
const _title = vscode.workspace.getConfiguration().get(`itodo.bartext`)
if (!!_title) title = _title
const panel = vscode.window.createWebviewPanel(
"",
title,
vscode.ViewColumn.One,
{
enableScripts: true,
retainContextWhenHidden: true,
localResourceRoots: [vscode.Uri.file(webviewDir)]
}
);
const tpl = path.join(webviewDir, 'todo.pug')
const mainStyle = utils.getExtensionFileVscodeResource(context, "main.css")
const mainJS = utils.getExtensionFileVscodeResource(context, "webview.js")
const html = pug.renderFile(tpl, {
css: mainStyle,
webviewjs: mainJS,
datas,
})
panel.webview.html = html
return panel
}
module.exports = render