Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebviewEditorInset cannot display local SVG files. #75931

Closed
tamuratak opened this issue Jun 22, 2019 · 2 comments
Closed

WebviewEditorInset cannot display local SVG files. #75931

tamuratak opened this issue Jun 22, 2019 · 2 comments
Assignees

Comments

@tamuratak
Copy link
Contributor

  • VSCode Version: 1.36.0-insider (1.36.0-insider) 9ff8ae0 2019-06-21T05:08:55.145Z
  • OS Version: macOS High Sierra 10.13.6 (17G7024)

Steps to Reproduce:

  1. Execute the following sample code of VS Code extension.
  2. A local file, sample.svg, is not displayed in WebviewEditorInset . sample.png is displayed.
  3. In WebviewPanel, both the files are displayed.

Does this issue occur when all extensions are disabled?: Yes

import * as vscode from 'vscode';
import * as path from 'path';

export function activate(context: vscode.ExtensionContext) {
    const rootUrl = vscode.Uri.file(context.extensionPath)
    const disposable = vscode.commands.registerCommand('extension.helloWorld', async (args, brgs, crgs) => {
        if (!vscode.window.activeTextEditor) {
            return;
        }

        const inset = vscode.window.createWebviewTextEditorInset(
            vscode.window.activeTextEditor, 0, 30,
            { localResourceRoots: [ rootUrl ] }
            );
        inset.onDidDispose(() => {
            console.log('WEBVIEW disposed...');
        });
        inset.webview.html = getHtml(rootUrl);

        /* the following works well.
        const panel = vscode.window.createWebviewPanel(
            'catCoding',
            'Cat Coding',
            vscode.ViewColumn.One,
            {
              localResourceRoots: [ rootUrl ]
            }
          );
        panel.webview.html = getHtml(rootUrl); 
        */
    });
	context.subscriptions.push(disposable);
}

function getHtml(rootUrl: vscode.Uri) {
    const png = rootUrl.with( { scheme: 'vscode-resource', path: path.join(rootUrl.path, './sample.png') }).toString()
    const svg = rootUrl.with( { scheme: 'vscode-resource', path: path.join(rootUrl.path, './sample.svg') }).toString()
    return `<img src="${png}"/><img src="${svg}"/>`
}


// this method is called when your extension is deactivated
export function deactivate() {}
@vscodebot
Copy link

vscodebot bot commented Jun 22, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@jrieken
Copy link
Member

jrieken commented Oct 7, 2019

SVG weren't allowed inside webviews as part of our design (SVG can basically run code). This has changed recently and SVG are now allowed.

@jrieken jrieken closed this as completed Oct 7, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants