├── .gitignore
├── images
├── ScreenShot.gif
└── webapp-icon-128.png
├── .vscodeignore
├── .vscode
├── extensions.json
└── launch.json
├── CHANGELOG.md
├── test
├── suite
│ ├── extension.test.js
│ └── index.js
└── runTest.js
├── .eslintrc.json
├── LICENSE.txt
├── vsc-extension-quickstart.md
├── README.md
├── package.json
├── CODE_OF_CONDUCT.md
└── extension.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .vscode-test/
3 | *.vsix
4 |
--------------------------------------------------------------------------------
/images/ScreenShot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mohamed3nan/DevDocs-Tab/HEAD/images/ScreenShot.gif
--------------------------------------------------------------------------------
/images/webapp-icon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mohamed3nan/DevDocs-Tab/HEAD/images/webapp-icon-128.png
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | test/**
4 | .gitignore
5 | .yarnrc
6 | vsc-extension-quickstart.md
7 | **/jsconfig.json
8 | **/*.map
9 | **/.eslintrc.json
10 | images/ScreenShot.gif
11 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "dbaeumer.vscode-eslint"
6 | ]
7 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to the **DevDocs Tab** extension will be documented in this file.
4 |
5 |
6 |
7 | ## [1.0.1]
8 |
9 | - Initial release
10 |
--------------------------------------------------------------------------------
/test/suite/extension.test.js:
--------------------------------------------------------------------------------
1 | const assert = require('assert');
2 |
3 | // You can import and use all API from the 'vscode' module
4 | // as well as import your extension to test it
5 | const vscode = require('vscode');
6 | // const myExtension = require('../extension');
7 |
8 | suite('Extension Test Suite', () => {
9 | vscode.window.showInformationMessage('Start all tests.');
10 |
11 | test('Sample test', () => {
12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5));
13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0));
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": false,
4 | "commonjs": true,
5 | "es6": true,
6 | "node": true,
7 | "mocha": true
8 | },
9 | "parserOptions": {
10 | "ecmaVersion": 2018,
11 | "ecmaFeatures": {
12 | "jsx": true
13 | },
14 | "sourceType": "module"
15 | },
16 | "rules": {
17 | "no-const-assign": "warn",
18 | "no-this-before-super": "warn",
19 | "no-undef": "warn",
20 | "no-unreachable": "warn",
21 | "no-unused-vars": "warn",
22 | "constructor-super": "warn",
23 | "valid-typeof": "warn"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/runTest.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | const { runTests } = require('vscode-test');
4 |
5 | async function main() {
6 | try {
7 | // The folder containing the Extension Manifest package.json
8 | // Passed to `--extensionDevelopmentPath`
9 | const extensionDevelopmentPath = path.resolve(__dirname, '../');
10 |
11 | // The path to the extension test script
12 | // Passed to --extensionTestsPath
13 | const extensionTestsPath = path.resolve(__dirname, './suite/index');
14 |
15 | // Download VS Code, unzip it and run the integration test
16 | await runTests({ extensionDevelopmentPath, extensionTestsPath });
17 | } catch (err) {
18 | console.error('Failed to run tests');
19 | process.exit(1);
20 | }
21 | }
22 |
23 | main();
24 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that launches the extension inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "1.0.0",
7 | "configurations": [
8 | {
9 | "name": "Run Extension",
10 | "type": "extensionHost",
11 | "request": "launch",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}"
14 | ]
15 | },
16 | {
17 | "name": "Extension Tests",
18 | "type": "extensionHost",
19 | "request": "launch",
20 | "args": [
21 | "--extensionDevelopmentPath=${workspaceFolder}",
22 | "--extensionTestsPath=${workspaceFolder}/test/suite/index"
23 | ]
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/test/suite/index.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const Mocha = require('mocha');
3 | const glob = require('glob');
4 |
5 | function run() {
6 | // Create the mocha test
7 | const mocha = new Mocha({
8 | ui: 'tdd',
9 | color: true
10 | });
11 |
12 | const testsRoot = path.resolve(__dirname, '..');
13 |
14 | return new Promise((c, e) => {
15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16 | if (err) {
17 | return e(err);
18 | }
19 |
20 | // Add files to the test suite
21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
22 |
23 | try {
24 | // Run the mocha test
25 | mocha.run(failures => {
26 | if (failures > 0) {
27 | e(new Error(`${failures} tests failed.`));
28 | } else {
29 | c();
30 | }
31 | });
32 | } catch (err) {
33 | console.error(err);
34 | e(err);
35 | }
36 | });
37 | });
38 | }
39 |
40 | module.exports = {
41 | run
42 | };
43 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021 Mohamed Anan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/vsc-extension-quickstart.md:
--------------------------------------------------------------------------------
1 | # Welcome to your VS Code Extension
2 |
3 | ## What's in the folder
4 |
5 | * This folder contains all of the files necessary for your extension.
6 | * `package.json` - this is the manifest file in which you declare your extension and command.
7 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
8 | * `extension.js` - this is the main file where you will provide the implementation of your command.
9 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
11 |
12 | ## Get up and running straight away
13 |
14 | * Press `F5` to open a new window with your extension loaded.
15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
16 | * Set breakpoints in your code inside `extension.js` to debug your extension.
17 | * Find output from your extension in the debug console.
18 |
19 | ## Make changes
20 |
21 | * You can relaunch the extension from the debug toolbar after changing code in `extension.js`.
22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
23 |
24 | ## Explore the API
25 |
26 | * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
27 |
28 | ## Run tests
29 |
30 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
31 | * Press `F5` to run the tests in a new window with your extension loaded.
32 | * See the output of the test result in the debug console.
33 | * Make changes to `src/test/suite/extension.test.js` or create new test files inside the `test/suite` folder.
34 | * The provided test runner will only consider files matching the name pattern `**.test.ts`.
35 | * You can create folders inside the `test` folder to structure your tests any way you want.
36 | ## Go further
37 |
38 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace.
39 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VS Code - DevDocs Tab
2 |
3 |
4 |
5 |
6 | [](https://open.vscode.dev/mohamed3nan/DevDocs-Tab)
7 | [](https://vsmarketplacebadge.apphb.com/version/Anan.devdocstab.svg)
8 | [](https://vsmarketplacebadge.apphb.com/installs-short/Anan.devdocstab.svg)
9 | [](https://vsmarketplacebadge.apphb.com/downloads-short/Anan.devdocstab.svg)
10 | [](https://vsmarketplacebadge.apphb.com/rating-star/Anan.devdocstab.svg)
11 |
12 | ## Description
13 |
14 | An extension for Visual Studio Code to 🔍search for documentation on DevDocs.io faster⚡️ by displaying it in a tab inside VS Code.
15 |
16 | ## Installation
17 |
18 | Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
19 |
20 | ```ext install anan.devdocstab```
21 |
22 | or:
23 |
24 | [Download from VisualStudio Marketplace](https://marketplace.visualstudio.com/items?itemName=Anan.devdocstab)
25 |
26 | ## Screenshot
27 |
28 | 
29 |
30 | ## Features
31 |
32 | The extension search your selected text from the current active file in DevDocs.io by using shortcut or by using mouse>Right-Click>"DevDocsTab: Search in DevDocs.io". Also a convenient `DevDocsTab` command could be used via command palette.
33 |
34 | ## Commands
35 |
36 | Name | Description | Keybindings
37 | -------------------- | --------------------------------------- | ------------
38 | DevDocsTab.home | Open DevDocs Home Page |
39 | DevDocsTab.search | Search DevDocs with the selected words | `ctrl+k ctrl+k`
40 | DevDocsTab.preferences | Open DevDocs Docs/Settings Page |
41 | DevDocsTab.offline | Open DevDocs Offline Documentation page |
42 |
43 | ## General Notes
44 |
45 | This is a simple wrapper around DevDocs.io. All documentations are provided and hosted by DevDocs.io. The extension has no control over DevDocs.
46 | For best user experience, you should configure it manually:
47 |
48 | * Run `DevDocsTab.preferences` You can choose enabled DOCS, choose theme, and general preferences.
49 | * Run `DevDocsTab.offline` to cache documentations locally.
50 |
51 | ## Contribution
52 |
53 | Feel free to make a pull request or open a new issue.
54 |
55 | ## Changelog
56 |
57 | [CHANGELOG](CHANGELOG.md)
58 |
59 | ## License
60 |
61 | This project is licensed under the MIT License - see the
62 | [MIT](LICENSE.txt) file for details.
63 |
64 | ---
65 |
66 | **Enjoy!**
67 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "devdocstab",
3 | "displayName": "DevDocs Tab",
4 | "description": "An extension for Visual Studio Code to search for documentation on DevDocs.io faster by displaying it in a tab inside VS Code.",
5 | "publisher": "Anan",
6 | "version": "1.0.1",
7 | "license": "MIT",
8 | "icon": "images/webapp-icon-128.png",
9 | "galleryBanner": {
10 | "color": "#3c3f41",
11 | "theme": "dark"
12 | },
13 | "engines": {
14 | "vscode": "^1.56.0"
15 | },
16 | "categories": [
17 | "Other",
18 | "Programming Languages"
19 | ],"keywords": [
20 | "docs",
21 | "doc",
22 | "documentation",
23 | "documentations",
24 | "search",
25 | "keybindings",
26 | "keybinding",
27 | "devdocs",
28 | "devdoc"
29 | ],
30 | "homepage": "https://github.com/mohamed3nan/DevDocs-Tab",
31 | "repository": {
32 | "type": "git",
33 | "url": "https://github.com/mohamed3nan/DevDocs-Tab"
34 | },
35 | "bugs": {
36 | "url": "https://github.com/mohamed3nan/DevDocs-Tab/issues"
37 | },
38 | "badges": [
39 | {
40 | "url": "https://vsmarketplacebadge.apphb.com/version/Anan.devdocstab.svg",
41 | "href": "https://marketplace.visualstudio.com/items/Anan.devdocstab",
42 | "description": "Version"
43 | },
44 | {
45 | "url": "https://vsmarketplacebadge.apphb.com/installs-short/Anan.devdocstab.svg",
46 | "href": "https://marketplace.visualstudio.com/items/Anan.devdocstab",
47 | "description": "Installs"
48 | },
49 | {
50 | "url": "https://vsmarketplacebadge.apphb.com/downloads-short/Anan.devdocstab.svg",
51 | "href": "https://marketplace.visualstudio.com/items/Anan.devdocstab",
52 | "description": "Downloads"
53 | },
54 | {
55 | "url": "https://vsmarketplacebadge.apphb.com/rating-star/Anan.devdocstab.svg",
56 | "href": "https://marketplace.visualstudio.com/items/Anan.devdocstab",
57 | "description": "Rating"
58 | }
59 | ],
60 | "activationEvents": [
61 | "onCommand:DevDocsTab.home",
62 | "onCommand:DevDocsTab.search",
63 | "onCommand:DevDocsTab.preferences",
64 | "onCommand:DevDocsTab.offline"
65 | ],
66 | "main": "./extension.js",
67 | "contributes": {
68 | "commands": [
69 | {
70 | "command": "DevDocsTab.home",
71 | "title": "DevDocsTab: Home DevDocs.io"
72 | },
73 | {
74 | "command": "DevDocsTab.search",
75 | "title": "DevDocsTab: Search in DevDocs.io"
76 | },
77 | {
78 | "command": "DevDocsTab.preferences",
79 | "title": "DevDocsTab: Preferences DevDocs.io"
80 | },
81 | {
82 | "command": "DevDocsTab.offline",
83 | "title": "DevDocsTab: Offline Data DevDocs.io"
84 | }
85 | ],
86 | "menus": {
87 | "editor/context": [
88 | {
89 | "command": "DevDocsTab.search",
90 | "group": "y_commands@0"
91 | }
92 | ]
93 | },
94 | "keybindings": [
95 | {
96 | "command": "DevDocsTab.search",
97 | "key": "ctrl+k ctrl+k",
98 | "mac": "cmd+k cmd+k",
99 | "when": "editorTextFocus"
100 | }
101 | ]
102 | },
103 | "scripts": {
104 | "lint": "eslint .",
105 | "pretest": "npm run lint",
106 | "test": "node ./test/runTest.js"
107 | },
108 | "devDependencies": {
109 | "@types/vscode": "^1.56.0",
110 | "@types/glob": "^7.1.3",
111 | "@types/mocha": "^8.0.4",
112 | "@types/node": "^12.11.7",
113 | "eslint": "^7.19.0",
114 | "glob": "^7.1.6",
115 | "mocha": "^8.2.1",
116 | "typescript": "^4.1.3",
117 | "vscode-test": "^1.5.0"
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | https://github.com/mohamed3nan.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/extension.js:
--------------------------------------------------------------------------------
1 | // The module 'vscode' contains the VS Code extensibility API
2 | // Import the module and reference it with the alias vscode in your code below
3 | const vscode = require("vscode");
4 |
5 | // this method is called when your extension is activated
6 | // your extension is activated the very first time the command is executed
7 |
8 | /**
9 | * @param {vscode.ExtensionContext} context
10 | */
11 |
12 | function activate(context) {
13 | // Use the console to output diagnostic information (console.log) and errors (console.error)
14 | // This line of code will only be executed once when your extension is activated
15 | //console.log('Hello Friend, extension "DevDocsTab" is now active!');
16 |
17 | // The command has been defined in the package.json file
18 | // Now provide the implementation of the command with registerCommand
19 | // The commandId parameter must match the command field in package.json
20 |
21 | function get_uri() {
22 | const editor = vscode.window.activeTextEditor;
23 | if (!editor) {
24 | return; // No open text editor
25 | }
26 |
27 | const url = "https://devdocs.io/";
28 | let keyword = "";
29 |
30 | // selection.
31 | var selection = editor.selection;
32 | if (!selection.isEmpty) {
33 | keyword = editor.document.getText(selection);
34 | } else {
35 | const position = editor.selection.active;
36 | const range = editor.document.getWordRangeAtPosition(position);
37 | keyword = editor.document.getText(range);
38 | }
39 |
40 | // Safety checks
41 | if (keyword.length == 0) {
42 | vscode.window.showErrorMessage(
43 | "DevDocsTab: Null string in text variable."
44 | );
45 | keyword = "";
46 | }
47 | if (keyword.indexOf("\n") >= 0) {
48 | vscode.window.showErrorMessage(
49 | "DevDocsTab: Multiline selection not allowed for your security."
50 | );
51 | keyword = "";
52 | }
53 |
54 | // Open URI
55 | let uri = vscode.Uri.parse(url + "#q=" + keyword);
56 | //vscode.commands.executeCommand('vscode.open', uri);
57 | return uri;
58 | }
59 |
60 | function htmlMaker(url) {
61 | const html = `
62 |
66 | `;
67 | return html;
68 | }
69 |
70 | let currentPanel = undefined;
71 |
72 | let homeCommand = vscode.commands.registerCommand("DevDocsTab.home", function () {
73 | // The code you place here will be executed every time your command is executed
74 | const columnToShowIn = vscode.ViewColumn.Two;
75 |
76 | if (currentPanel) {
77 | // If we already have a panel, show it in the target column
78 | currentPanel.reveal(columnToShowIn);
79 | currentPanel.webview.html = htmlMaker("https://devdocs.io/");
80 | } else {
81 | // Otherwise, create a new panel
82 | currentPanel = vscode.window.createWebviewPanel(
83 | "DevDocs",
84 | "DevDocs.io",
85 | columnToShowIn,
86 | {
87 | enableScripts: true,
88 | retainContextWhenHidden: true,
89 | enableCommandUris: true,
90 | }
91 | );
92 | currentPanel.webview.html = htmlMaker("https://devdocs.io/");
93 | // Reset when the current panel is closed
94 | currentPanel.onDidDispose(
95 | () => {
96 | currentPanel = undefined;
97 | },
98 | null,
99 | context.subscriptions
100 | );
101 | }
102 | });
103 |
104 | let searchCommand = vscode.commands.registerCommand("DevDocsTab.search", function () {
105 | // The code you place here will be executed every time your command is executed
106 | const columnToShowIn = vscode.ViewColumn.Two;
107 |
108 | if (currentPanel) {
109 | // If we already have a panel, show it in the target column
110 | currentPanel.reveal(columnToShowIn);
111 | currentPanel.webview.html = htmlMaker(get_uri());
112 | } else {
113 | // Otherwise, create a new panel
114 | currentPanel = vscode.window.createWebviewPanel(
115 | "DevDocs",
116 | "DevDocs.io",
117 | columnToShowIn,
118 | {
119 | enableScripts: true,
120 | retainContextWhenHidden: true,
121 | enableCommandUris: true,
122 | }
123 | );
124 | currentPanel.webview.html = htmlMaker(get_uri());
125 | // Reset when the current panel is closed
126 | currentPanel.onDidDispose(
127 | () => {
128 | currentPanel = undefined;
129 | },
130 | null,
131 | context.subscriptions
132 | );
133 | }
134 | });
135 |
136 | let preferencesCommand = vscode.commands.registerCommand("DevDocsTab.preferences", function () {
137 | // The code you place here will be executed every time your command is executed
138 | const columnToShowIn = vscode.ViewColumn.Two;
139 |
140 | if (currentPanel) {
141 | // If we already have a panel, show it in the target column
142 | currentPanel.reveal(columnToShowIn);
143 | currentPanel.webview.html = htmlMaker("https://devdocs.io/settings");
144 | } else {
145 | // Otherwise, create a new panel
146 | currentPanel = vscode.window.createWebviewPanel(
147 | "DevDocs",
148 | "DevDocs.io",
149 | columnToShowIn,
150 | {
151 | enableScripts: true,
152 | retainContextWhenHidden: true,
153 | enableCommandUris: true,
154 | }
155 | );
156 | currentPanel.webview.html = htmlMaker("https://devdocs.io/settings");
157 | // Reset when the current panel is closed
158 | currentPanel.onDidDispose(
159 | () => {
160 | currentPanel = undefined;
161 | },
162 | null,
163 | context.subscriptions
164 | );
165 | }
166 | });
167 |
168 | let offlineCommand = vscode.commands.registerCommand("DevDocsTab.offline", function () {
169 | // The code you place here will be executed every time your command is executed
170 | const columnToShowIn = vscode.ViewColumn.Two;
171 |
172 | if (currentPanel) {
173 | // If we already have a panel, show it in the target column
174 | currentPanel.reveal(columnToShowIn);
175 | currentPanel.webview.html = htmlMaker("https://devdocs.io/offline");
176 | } else {
177 | // Otherwise, create a new panel
178 | currentPanel = vscode.window.createWebviewPanel(
179 | "DevDocs",
180 | "DevDocs.io",
181 | columnToShowIn,
182 | {
183 | enableScripts: true,
184 | retainContextWhenHidden: true,
185 | enableCommandUris: true,
186 | }
187 | );
188 | currentPanel.webview.html = htmlMaker("https://devdocs.io/offline");
189 | // Reset when the current panel is closed
190 | currentPanel.onDidDispose(
191 | () => {
192 | currentPanel = undefined;
193 | },
194 | null,
195 | context.subscriptions
196 | );
197 | }
198 | });
199 |
200 | context.subscriptions.push(homeCommand, searchCommand, preferencesCommand, offlineCommand)
201 |
202 | }
203 |
204 | // this method is called when your extension is deactivated
205 | function deactivate() { }
206 |
207 | module.exports = {
208 | activate,
209 | deactivate,
210 | };
211 |
--------------------------------------------------------------------------------