Visual Studio Code extension that includes offline

2019-07-25 16:35发布

Is it possible for a VSCode extension to include HTML that are written to disk somewhere (doesn't matter where) when the extension is installed, so that I can then open that HTML from links?

E.g. I want a link to the offline documentation for a function in its tooltip.

1条回答
放我归山
2楼-- · 2019-07-25 17:00

Yes, your extension can use the standard node apis to download the files. Then you can:

  • Use the standard VS Code apis to open the file as a text document
  • Use the markdown.showPreview command to open the file as a html preview in VS Code:

    import * as vscode from 'vscode';
    
    vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.parse('file:///Users/you/path/to/file.html'));
    
  • Use node apis to open the file in the user's standard web browser (again using the file: uri)

查看更多
登录 后发表回答