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

experiment with html-zone #13686

Merged
merged 5 commits into from
Oct 20, 2016
Merged

experiment with html-zone #13686

merged 5 commits into from
Oct 20, 2016

Conversation

jrieken
Copy link
Member

@jrieken jrieken commented Oct 13, 2016

Some experiment with embedding web views into the editor. fyi @DonJayamanne

@mention-bot
Copy link

@jrieken, thanks for your PR! By analyzing the history of the files in this pull request, we identified @kieferrm, @bpasero and @joaomoreno to be potential reviewers.

@jrieken
Copy link
Member Author

jrieken commented Oct 13, 2016

To get a feel for this, add this keybinding

    {
        "key": "cmd+l l",
        "command": "_workbench.htmlZone",
        "when": "editorTextFocus"
    }

@DonJayamanne
Copy link
Contributor

@jrieken , had a look at this and looks great. It is as discussed.
One problem I have with this approach (identified early on and discussed in our meeting) is the fact that I won't necessarily know the height of the contents, until they are rendered.

Sometimes, the contents could be an image, sometimes an iFrame, and sometimes javascript code.
Is it possible to build in an event that could be triggered to cause the html zone to resize.

The workflow would be as follows:

  • we provide the html
  • html zone is added with a default height of 4 lines
  • once loaded, we measure the height (some how, not sure)
  • Then we trigger the resize event of the zone

Challenges:

  • passing back the calculated height from html webview into the extension (up-to extension author to figure this out or generic vs code solution - to auto resize zones)
  • triggering a resize of the zone (vs code api)

I'll try to have a play with the changes. Thanks

@jrieken
Copy link
Member Author

jrieken commented Oct 14, 2016

Understood - I think the height challenge can be tackled with a two step approach. Unsure if we can measure things from the outside but a zone can be always be resized afterwards or we add a sash to them (like in reference search)

My biggest current challenge is that there are layout issues with the web view. Often, for yet unknown reasons, it doesn't use its full (assigned) width. Makes me a little less positive about this...

@DonJayamanne
Copy link
Contributor

we add a sash to them (like in reference search)

Yes found that, was hoping we could expose that in some form. Cheers.

Unsure if we can measure things from the outside

Agreed. That's one of the reason why I thought we could measure it form within the zone and then pass the information back to the extension and then again pass that information to vscode... fun and games :)

@jrieken
Copy link
Member Author

jrieken commented Oct 20, 2016

@DonJayamanne I going to merge this despite it being more or less useless. I have spent quite some time just hunting layout weirdness (depending on multiple editor, screen resolutions etc) and I'd like to hear what you experience.

A snippet using this goes like this:

    vscode.commands.registerCommand('extension.runInNode', () => {
        if (!vscode.window.activeTextEditor) {
            return;
        }
        const {viewColumn, selection} = vscode.window.activeTextEditor;
        if (!viewColumn) {
            return;
        }
        const resource = vscode.Uri.parse('testing:foo/bar/' + Date.now());
        return vscode.commands.executeCommand('_workbench.htmlZone', { editorPosition: viewColumn - 1, lineNumber: selection.active.line, resource });
    });

    const contentProvider = new class implements vscode.TextDocumentContentProvider {
        provideTextDocumentContent(uri: vscode.Uri, token: CancellationToken): string {

            return `<html>
            <body style="background-color: pink;">
                <h3>Hello World at ${new Date()}</h3>
            </body>
            </html>`;
        }
    }

There is a very long list of things that don't work. To name a few

  • zone doesn't update when document updates
  • zone cannot be clicked on
  • zone has fixed height
  • zone dies when editors are shuffled around

Again, this is to get feedback on the basics... The test would be if your zone always takes full width of the editor (as shown below) and isn't weirdly cropped on the right side

screen shot 2016-10-20 at 17 03 23

@jrieken jrieken merged commit fc3418f into master Oct 20, 2016
@jrieken jrieken deleted the joh/htmlzone branch October 20, 2016 15:04
@DonJayamanne
Copy link
Contributor

@jrieken
Thanks, I will look at these and will post my feedback on #3220

@bpasero bpasero modified the milestone: October 2016 Oct 28, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants