mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
fix webview component css and add webview example (#1517)
This commit is contained in:
@@ -56,6 +56,10 @@ export default class MainController implements vscode.Disposable {
|
||||
this.openEditorWithWebview(buttonHtml, counterHtml);
|
||||
});
|
||||
|
||||
vscode.commands.registerCommand('sqlservices.openEditorWithWebView2', () => {
|
||||
this.openEditorWithWebview2();
|
||||
});
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
@@ -219,7 +223,7 @@ export default class MainController implements vscode.Disposable {
|
||||
}
|
||||
|
||||
private openEditorWithWebview(html1: string, html2: string): void {
|
||||
let editor = sqlops.workspace.createModelViewEditor('Editor view1', { retainContextWhenHidden: true });
|
||||
let editor = sqlops.workspace.createModelViewEditor('Editor webview', { retainContextWhenHidden: true });
|
||||
editor.registerContent(async view => {
|
||||
let count = 0;
|
||||
let webview1 = view.modelBuilder.webView()
|
||||
@@ -251,6 +255,34 @@ export default class MainController implements vscode.Disposable {
|
||||
editor.openEditor();
|
||||
}
|
||||
|
||||
private openEditorWithWebview2(): void {
|
||||
let editor = sqlops.workspace.createModelViewEditor('Editor webview2', { retainContextWhenHidden: true });
|
||||
editor.registerContent(async view => {
|
||||
|
||||
let webview = view.modelBuilder.webView()
|
||||
.component();
|
||||
let flexModel = view.modelBuilder.flexContainer()
|
||||
.withLayout({
|
||||
flexFlow: 'column',
|
||||
alignItems: 'stretch',
|
||||
height: '100%'
|
||||
}).withItems([
|
||||
webview
|
||||
], { flex: '1 1 50%' })
|
||||
.component();
|
||||
|
||||
let templateValues = {url: 'http://whoisactive.com/docs/'};
|
||||
Utils.renderTemplateHtml(path.join(__dirname, '..'), 'templateTab.html', templateValues)
|
||||
.then(html => {
|
||||
webview.html = html;
|
||||
});
|
||||
|
||||
await view.initializeModel(flexModel);
|
||||
});
|
||||
editor.openEditor();
|
||||
}
|
||||
|
||||
|
||||
private registerSqlServicesModelView(): void {
|
||||
sqlops.ui.registerModelViewProvider('sqlservices', async (view) => {
|
||||
let flexModel = view.modelBuilder.flexContainer()
|
||||
|
||||
36
samples/sqlservices/src/resources/templateTab.html
Normal file
36
samples/sqlservices/src/resources/templateTab.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!--
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
document.getElementById('frame').src = "{{{url}}}";
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
#frame {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="frame" width="100%" height="100%" frameborder="0"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user