Skip to content

Commit a150ddd

Browse files
committed
switched from using hardcoded vscode-resource scheme to Webview.asWebviewUri (fixes #101)
1 parent 222f10a commit a150ddd

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.5.4 / 2020-08-13
4+
5+
- switched from using hardcoded `vscode-resource` scheme to `Webview.asWebviewUri`
6+
37
## 1.5.3 / 2020-04-16
48

59
- updated mermaid

extension.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@ function activate(context) {
1616
'Mermaid Preview',
1717
vscode.ViewColumn.Two,
1818
{
19-
enableScripts: true
19+
enableScripts: true,
2020
}
2121
);
2222

2323
const getContent = () => {
2424
const config = vscode.workspace.getConfiguration('mermaid');
2525
const configString = JSON.stringify(config);
2626

27-
const faBase = vscode.Uri.file(
28-
context.asAbsolutePath(
29-
'previewer/dist/vendor/font-awesome/css/font-awesome.min.css'
27+
const faBase = panel.webview.asWebviewUri(
28+
vscode.Uri.file(
29+
context.asAbsolutePath(
30+
'previewer/dist/vendor/font-awesome/css/font-awesome.min.css'
31+
)
3032
)
31-
).with({
32-
scheme: 'vscode-resource'
33-
});
33+
);
3434

35-
const jsUrl = vscode.Uri.file(
36-
context.asAbsolutePath('previewer/dist/index.js')
37-
).with({
38-
scheme: 'vscode-resource'
39-
});
35+
const jsUrl = panel.webview.asWebviewUri(
36+
vscode.Uri.file(context.asAbsolutePath('previewer/dist/index.js'))
37+
);
4038

4139
return `
4240
<!DOCTYPE html>
@@ -66,12 +64,12 @@ function activate(context) {
6664
: findDiagram(text, cursor);
6765

6866
panel.webview.postMessage({
69-
diagram
67+
diagram,
7068
});
7169
};
7270

7371
vscode.workspace.onDidChangeTextDocument(
74-
e => {
72+
(e) => {
7573
if (e.document === vscode.window.activeTextEditor.document) {
7674
previewHandler();
7775
}
@@ -81,15 +79,15 @@ function activate(context) {
8179
);
8280

8381
vscode.workspace.onDidChangeConfiguration(
84-
e => {
82+
(e) => {
8583
panel.webview.html = getContent();
8684
},
8785
null,
8886
_disposables
8987
);
9088

9189
vscode.window.onDidChangeTextEditorSelection(
92-
e => {
90+
(e) => {
9391
if (e.textEditor === vscode.window.activeTextEditor) {
9492
previewHandler();
9593
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Mermaid Preview",
44
"description": "Previews Mermaid diagrams in Visual Studio Code",
55
"license": "MIT",
6-
"version": "1.5.3",
6+
"version": "1.5.4",
77
"publisher": "vstirbu",
88
"bugs": {
99
"url": "https://github.com/vstirbu/vscode-mermaid-preview/issues"

0 commit comments

Comments
 (0)