Skip to content

Commit

Permalink
switched from using hardcoded vscode-resource scheme to `Webview.as…
Browse files Browse the repository at this point in the history
…WebviewUri` (fixes #101)
  • Loading branch information
vstirbu committed Aug 13, 2020
1 parent 222f10a commit a150ddd
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.5.4 / 2020-08-13

- switched from using hardcoded `vscode-resource` scheme to `Webview.asWebviewUri`

## 1.5.3 / 2020-04-16

- updated mermaid
30 changes: 14 additions & 16 deletions extension.js
Original file line number Diff line number Diff line change
@@ -16,27 +16,25 @@ function activate(context) {
'Mermaid Preview',
vscode.ViewColumn.Two,
{
enableScripts: true
enableScripts: true,
}
);

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

const faBase = vscode.Uri.file(
context.asAbsolutePath(
'previewer/dist/vendor/font-awesome/css/font-awesome.min.css'
const faBase = panel.webview.asWebviewUri(
vscode.Uri.file(
context.asAbsolutePath(
'previewer/dist/vendor/font-awesome/css/font-awesome.min.css'
)
)
).with({
scheme: 'vscode-resource'
});
);

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

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

panel.webview.postMessage({
diagram
diagram,
});
};

vscode.workspace.onDidChangeTextDocument(
e => {
(e) => {
if (e.document === vscode.window.activeTextEditor.document) {
previewHandler();
}
@@ -81,15 +79,15 @@ function activate(context) {
);

vscode.workspace.onDidChangeConfiguration(
e => {
(e) => {
panel.webview.html = getContent();
},
null,
_disposables
);

vscode.window.onDidChangeTextEditorSelection(
e => {
(e) => {
if (e.textEditor === vscode.window.activeTextEditor) {
previewHandler();
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"displayName": "Mermaid Preview",
"description": "Previews Mermaid diagrams in Visual Studio Code",
"license": "MIT",
"version": "1.5.3",
"version": "1.5.4",
"publisher": "vstirbu",
"bugs": {
"url": "https://github.com/vstirbu/vscode-mermaid-preview/issues"

0 comments on commit a150ddd

Please sign in to comment.