Skip to content

Commit 3aede0a

Browse files
committed
Fix showDocumentation.
- Instead of using an iframe to render the content, we read and pass the html content to the webview.
1 parent f33d636 commit 3aede0a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/docsBrowser.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
Uri,
1717
ViewColumn,
1818
window,
19+
workspace,
1920
} from 'vscode';
2021
import { ProvideCompletionItemsSignature, ProvideHoverSignature } from 'vscode-languageclient';
2122

@@ -37,14 +38,27 @@ export namespace DocsBrowser {
3738
localResourceRoots: [Uri.parse(documentationDirectory)],
3839
enableFindWidget: true,
3940
enableCommandUris: true,
41+
enableScripts: true,
4042
});
41-
const uri = panel.webview.asWebviewUri(Uri.parse(localPath));
4243

4344
const encoded = encodeURIComponent(JSON.stringify({ hackageUri }));
4445
const hackageCmd = 'command:haskell.openDocumentationOnHackage?' + encoded;
4546

46-
panel.webview.html = `<div><a href="${hackageCmd}">Open on Hackage</a></div>
47-
<div><iframe src="${uri}" frameBorder = "0" style = "background: white; width: 100%; height: 100%; position:absolute; left: 0; right: 0; bottom: 0; top: 30px;"/></div>`;
47+
const bytes = await workspace.fs.readFile(Uri.parse(localPath));
48+
49+
const addBase = `
50+
<base href="${panel.webview.asWebviewUri(Uri.parse(documentationDirectory))}/">
51+
`;
52+
53+
panel.webview.html = `
54+
<html>
55+
${addBase}
56+
<body>
57+
<div><a href="${hackageCmd}">Open on Hackage</a></div>
58+
${bytes.toString()}
59+
</body>
60+
</html>
61+
`;
4862
} catch (e) {
4963
await window.showErrorMessage(e);
5064
}

0 commit comments

Comments
 (0)