diff --git a/README.md b/README.md index 7f13d485..0dea4e02 100644 --- a/README.md +++ b/README.md @@ -54,14 +54,6 @@ You can expect from each sample: | [LSP Multi Root Server Sample](https://github.com/Microsoft/vscode-extension-samples/tree/master/lsp-multi-server-sample) | https://github.com/Microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs#language-client--language-server | | -## :warning: Legacy Samples :warning: - -Legacy samples are at [`/legacy-samples`](/legacy-samples). They are unlikely to receive any updates and might not work with the latest version of VS Code. - -| Sample | Deprecated Reason | -| ------ | ----------------- | -| [Preview HTML](/legacy-samples/previewhtml-sample/README.md) | [Webview API](/webview-sample/README.md) supersedes the old HTML Preview functionality | - ## License Copyright (c) Microsoft Corporation. All rights reserved. diff --git a/legacy-samples/README.md b/legacy-samples/README.md deleted file mode 100644 index 154b4c91..00000000 --- a/legacy-samples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# :warning: Legacy Samples :warning: - -These samples are unlikely to receive any updates and might not work with the latest version of VS Code. \ No newline at end of file diff --git a/legacy-samples/previewhtml-sample/.gitignore b/legacy-samples/previewhtml-sample/.gitignore deleted file mode 100644 index 8e5962ee..00000000 --- a/legacy-samples/previewhtml-sample/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -out -node_modules \ No newline at end of file diff --git a/legacy-samples/previewhtml-sample/.vscode/launch.json b/legacy-samples/previewhtml-sample/.vscode/launch.json deleted file mode 100644 index c09f5a18..00000000 --- a/legacy-samples/previewhtml-sample/.vscode/launch.json +++ /dev/null @@ -1,28 +0,0 @@ -// A launch configuration that compiles the extension and then opens it inside a new window -{ - "version": "0.1.0", - "configurations": [ - { - "name": "Launch Extension", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], - "stopOnEntry": false, - "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/src/**/*.js"], - "preLaunchTask": "npm compile" - }, - { - "name": "Launch Tests", - "type": "extensionHost", - "request": "launch", - "runtimeExecutable": "${execPath}", - "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], - "stopOnEntry": false, - "sourceMaps": true, - "outFiles": ["${workspaceRoot}/out/test/**/*.js"], - "preLaunchTask": "npm compile" - } - ] -} diff --git a/legacy-samples/previewhtml-sample/.vscode/settings.json b/legacy-samples/previewhtml-sample/.vscode/settings.json deleted file mode 100644 index 5b12d4ad..00000000 --- a/legacy-samples/previewhtml-sample/.vscode/settings.json +++ /dev/null @@ -1,13 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files - }, - "search.exclude": { - "out": true // set this to false to include "out" folder in search results - }, - "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version - - "typescript.tsc.autoDetect": "off", - "npm.autoDetect": "off" -} \ No newline at end of file diff --git a/legacy-samples/previewhtml-sample/.vscode/tasks.json b/legacy-samples/previewhtml-sample/.vscode/tasks.json deleted file mode 100644 index bd02b04a..00000000 --- a/legacy-samples/previewhtml-sample/.vscode/tasks.json +++ /dev/null @@ -1,27 +0,0 @@ -// Available variables which can be used inside of strings. -// ${workspaceRoot}: the root folder of the team -// ${file}: the current opened file -// ${fileBasename}: the current opened file's basename -// ${fileDirname}: the current opened file's dirname -// ${fileExtname}: the current opened file's extension -// ${cwd}: the current working directory of the spawned process -// A task runner that calls a custom npm script that compiles the extension. -{ - "version": "2.0.0", - "tasks": [ - { - "type": "shell", - "command": "npm run compile --loglevel silent", - "label": "npm compile", - "problemMatcher": "$tsc-watch", - "isBackground": true, - "presentation": { - "reveal": "silent" - }, - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file diff --git a/legacy-samples/previewhtml-sample/.vscodeignore b/legacy-samples/previewhtml-sample/.vscodeignore deleted file mode 100644 index 93e28ff2..00000000 --- a/legacy-samples/previewhtml-sample/.vscodeignore +++ /dev/null @@ -1,9 +0,0 @@ -.vscode/** -typings/** -out/test/** -test/** -src/** -**/*.map -.gitignore -tsconfig.json -vsc-extension-quickstart.md diff --git a/legacy-samples/previewhtml-sample/README.md b/legacy-samples/previewhtml-sample/README.md deleted file mode 100644 index b2576918..00000000 --- a/legacy-samples/previewhtml-sample/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# :rotating_light: Deprecated - -Please use the new Webview API instead: - -- Guide: https://code.visualstudio.com/api/extension-guides/webview -- Sample: https://github.com/Microsoft/vscode-extension-samples/tree/master/webview-sample - -# CSS Properties Preview Sample - -This is an sample extension that illustrates the use of virtual documents or `TextDocumentContentProviders` together with the `vscode.previewHtml` -[command](https://code.visualstudio.com/api/references/commands#commands). - -It is not intended as a product quality extension. - -The purpose of the extension is to show a preview of the properties in the declaration block of a CSS rule. To play with the extension: - -- Open a CSS file -- Use `Show CSS Properties Preview` -- Position the cursor inside the declaration block of the rule -- The properties are rendered in the preview -- Edit the properties and the preview is updated - -![Navigation](images/preview.gif) - -# How it works - -- The extension implements and registers a [`TextDocumentContentProvider`](https://code.visualstudio.com/api/references/vscode-api#TextDocumentContentProvider) for a particular URI scheme. -- The content provider creates a HTML document that contains the declaration block of the selected CSS rule in the active editor. -- The generated HTML document contains a link that invokes a contributed command to highlight the CSS rule in the source editor -- The generated HTML document is then opened in an editor in the 2nd Column using the command `vscode.previewHtml`. - -# How to run locally - -- `npm install` -- `npm run compile` to start the compiler in watch mode -- open this folder in VS Code and press `F5` diff --git a/legacy-samples/previewhtml-sample/images/preview.gif b/legacy-samples/previewhtml-sample/images/preview.gif deleted file mode 100644 index 3947d280..00000000 Binary files a/legacy-samples/previewhtml-sample/images/preview.gif and /dev/null differ diff --git a/legacy-samples/previewhtml-sample/package-lock.json b/legacy-samples/previewhtml-sample/package-lock.json deleted file mode 100644 index 3d65635e..00000000 --- a/legacy-samples/previewhtml-sample/package-lock.json +++ /dev/null @@ -1,333 +0,0 @@ -{ - "name": "vscode-css-properties", - "version": "0.0.10", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "esutils": "^2.0.2", - "js-tokens": "^3.0.2" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - } - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, - "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", - "dev": true - }, - "resolve": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", - "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", - "dev": true, - "requires": { - "path-parse": "^1.0.5" - } - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", - "dev": true - }, - "tslint": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", - "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", - "dev": true, - "requires": { - "babel-code-frame": "^6.22.0", - "builtin-modules": "^1.1.1", - "chalk": "^2.3.0", - "commander": "^2.12.1", - "diff": "^3.2.0", - "glob": "^7.1.1", - "js-yaml": "^3.7.0", - "minimatch": "^3.0.4", - "resolve": "^1.3.2", - "semver": "^5.3.0", - "tslib": "^1.8.0", - "tsutils": "^2.27.2" - } - }, - "tsutils": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", - "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - } -} diff --git a/legacy-samples/previewhtml-sample/package.json b/legacy-samples/previewhtml-sample/package.json deleted file mode 100644 index 14ea2820..00000000 --- a/legacy-samples/previewhtml-sample/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "vscode-css-properties", - "displayName": "Preview CSS Properties Sample", - "description": "A sample illustrating the use of TextContentProviders and the `vscode.previewHtml` command, introduce in 0.10.7", - "version": "0.0.10", - "publisher": "vscode-samples", - "galleryBanner": { - "color": "#5c2d91", - "theme": "dark" - }, - "bugs": { - "url": "https://github.com/Microsoft/vscode-extension-samples/issues", - "email": "egamma@microsoft.com" - }, - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/vscode-extension-samples.git" - }, - "homepage": "https://github.com/Microsoft/vscode-extension-samples/tree/master/textdocumentprovider-sample/README.md", - "categories": [ - "Other" - ], - "engines": { - "vscode": "^0.10.7" - }, - "activationEvents": [ - "onCommand:extension.showCssPropertyPreview" - ], - "main": "./out/extension.js", - "contributes": { - "commands": [ - { - "command": "extension.showCssPropertyPreview", - "title": "Show CSS Properties Preview" - } - ], - "menus": { - "editor/title": [ - { - "command": "extension.showCssPropertyPreview", - "when": "resourceLangId == css" - } - ] - } - }, - "scripts": { - "vscode:prepublish": "tsc -p ./", - "compile": "tsc -watch -p ./", - "postinstall": "node ./node_modules/vscode/bin/install", - "tslint": "tslint -c tslint.json src/extension.ts" - }, - "devDependencies": { - "@types/node": "*", - "tslint": "^5.11.0", - "typescript": "^2.1.4", - "vscode": "^1.1.17" - } -} diff --git a/legacy-samples/previewhtml-sample/src/extension.ts b/legacy-samples/previewhtml-sample/src/extension.ts deleted file mode 100644 index edba3985..00000000 --- a/legacy-samples/previewhtml-sample/src/extension.ts +++ /dev/null @@ -1,109 +0,0 @@ -/*--------------------------------------------------------- - * Copyright (C) Microsoft Corporation. All rights reserved. - *--------------------------------------------------------*/ -'use strict'; - -import * as vscode from 'vscode'; - -export function activate(context: vscode.ExtensionContext) { - - let previewUri = vscode.Uri.parse('css-preview://authority/css-preview'); - - class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { - private _onDidChange = new vscode.EventEmitter(); - - public provideTextDocumentContent(uri: vscode.Uri): string { - return this.createCssSnippet(); - } - - get onDidChange(): vscode.Event { - return this._onDidChange.event; - } - - public update(uri: vscode.Uri) { - this._onDidChange.fire(uri); - } - - private createCssSnippet() { - let editor = vscode.window.activeTextEditor; - if (!(editor.document.languageId === 'css')) { - return this.errorSnippet("Active editor doesn't show a CSS document - no properties to preview.") - } - return this.extractSnippet(); - } - - private extractSnippet(): string { - let editor = vscode.window.activeTextEditor; - let text = editor.document.getText(); - let selStart = editor.document.offsetAt(editor.selection.anchor); - let propStart = text.lastIndexOf('{', selStart); - let propEnd = text.indexOf('}', selStart); - - if (propStart === -1 || propEnd === -1) { - return this.errorSnippet("Cannot determine the rule's properties."); - } else { - return this.snippet(editor.document, propStart, propEnd); - } - } - - private errorSnippet(error: string): string { - return ` - - ${error} - `; - } - - private snippet(document: vscode.TextDocument, propStart: number, propEnd: number): string { - const properties = document.getText().slice(propStart + 1, propEnd); - return ` - -
Preview of the CSS properties
-
-
Lorem ipsum dolor sit amet, mi et mauris nec ac luctus lorem, proin leo nulla integer metus vestibulum lobortis, eget
- `; - } - } - - let provider = new TextDocumentContentProvider(); - let registration = vscode.workspace.registerTextDocumentContentProvider('css-preview', provider); - - vscode.workspace.onDidChangeTextDocument((e: vscode.TextDocumentChangeEvent) => { - if (e.document === vscode.window.activeTextEditor.document) { - provider.update(previewUri); - } - }); - - vscode.window.onDidChangeTextEditorSelection((e: vscode.TextEditorSelectionChangeEvent) => { - if (e.textEditor === vscode.window.activeTextEditor) { - provider.update(previewUri); - } - }) - - let disposable = vscode.commands.registerCommand('extension.showCssPropertyPreview', () => { - return vscode.commands.executeCommand('vscode.previewHtml', previewUri, vscode.ViewColumn.Two, 'CSS Property Preview').then((success) => { - }, (reason) => { - vscode.window.showErrorMessage(reason); - }); - }); - - let highlight = vscode.window.createTextEditorDecorationType({ backgroundColor: 'rgba(200,200,200,.35)' }); - - vscode.commands.registerCommand('extension.revealCssRule', (uri: vscode.Uri, propStart: number, propEnd: number) => { - - for (let editor of vscode.window.visibleTextEditors) { - if (editor.document.uri.toString() === uri.toString()) { - let start = editor.document.positionAt(propStart); - let end = editor.document.positionAt(propEnd + 1); - - editor.setDecorations(highlight, [new vscode.Range(start, end)]); - setTimeout(() => editor.setDecorations(highlight, []), 1500); - } - } - }); - - context.subscriptions.push(disposable, registration); -} diff --git a/legacy-samples/previewhtml-sample/tsconfig.json b/legacy-samples/previewhtml-sample/tsconfig.json deleted file mode 100644 index 43668414..00000000 --- a/legacy-samples/previewhtml-sample/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es5", - "outDir": "out", - "lib": ["es6"], - "sourceMap": true, - "rootDir": "src" - }, - "exclude": ["node_modules"] -} diff --git a/legacy-samples/previewhtml-sample/tslint.json b/legacy-samples/previewhtml-sample/tslint.json deleted file mode 100644 index 3301356f..00000000 --- a/legacy-samples/previewhtml-sample/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rules": { - "no-unused-variable": true, - "no-unused-expression": true - } -}