From 4eaa27f099a80d27d404016e27e98edc54aa41c0 Mon Sep 17 00:00:00 2001 From: cssho Date: Tue, 29 Mar 2016 12:06:49 +0900 Subject: [PATCH 1/2] Add new feature.Copy SVG data URI scheme to the clipboard. --- package.json | 151 +++++++++++++++++++++++++---------------------- src/extension.ts | 14 ++++- 2 files changed, 92 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index ae774de..22b4ce0 100644 --- a/package.json +++ b/package.json @@ -1,73 +1,84 @@ { - "name": "vscode-svgviewer", - "displayName": "SVG Viewer", - "description": "SVG Viewer", - "version": "1.1.0", - "publisher": "cssho", - "engines": { - "vscode": "^0.10.8" - }, - "categories": [ - "Other" + "name": "vscode-svgviewer", + "displayName": "SVG Viewer", + "description": "SVG Viewer", + "version": "1.1.3", + "publisher": "cssho", + "engines": { + "vscode": "^0.10.8" + }, + "categories": [ + "Other" + ], + "activationEvents": [ + "onCommand:svgviewer.open", + "onCommand:svgviewer.saveas", + "onCommand:svgviewer.copydui" + ], + "main": "./out/src/extension", + "contributes": { + "commands": [ + { + "command": "svgviewer.open", + "title": "SVG Viewer: View SVG" + }, + { + "command": "svgviewer.saveas", + "title": "SVG Viewer: Export PNG" + }, + { + "command": "svgviewer.copydui", + "title": "SVG Viewer: Copy data URI scheme" + } ], - "activationEvents": [ - "onCommand:svgviewer.open", - "onCommand:svgviewer.saveas" + "keybindings": [ + { + "command": "svgviewer.open", + "key": "ctrl+i o", + "mac": "cmd+i o" + }, + { + "command": "svgviewer.saveas", + "key": "ctrl+i e", + "mac": "cmd+i e" + }, + { + "command": "svgviewer.copydui", + "key": "ctrl+i c", + "mac": "cmd+i c" + } ], - "main": "./out/src/extension", - "contributes": { - "commands": [ - { - "command": "svgviewer.open", - "title": "SVG Viewer: View SVG" - }, - { - "command": "svgviewer.saveas", - "title": "SVG Viewer: Export PNG" - } - ], - "keybindings": [ - { - "command": "svgviewer.open", - "key": "ctrl+i o", - "mac": "cmd+i o" - }, - { - "command": "svgviewer.saveas", - "key": "ctrl+i e", - "mac": "cmd+i e" - } - ], - "configuration": { - "type": "object", - "title": "VSCode SVG Viewer configuration", - "properties": { - "svgviewer.transparencygrid": { - "type": "boolean", - "default": true, - "description": "Show Transparency Grid" - } - } - } - }, - "scripts": { - "vscode:prepublish": "node ./node_modules/vscode/bin/compile", - "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", - "postinstall": "node ./node_modules/vscode/bin/install" - }, - "devDependencies": { - "typescript": "^1.7.5", - "vscode": "^0.11.1" - }, - "dependencies": { - "pn": "^1.0.0", - "svg2png": "^3.0.0", - "tmp": "0.0.28" - }, - "repository": { - "type": "git", - "url": "https://github.com/cssho/vscode-svgviewer.git" - }, - "license": "MIT", - "icon": "icon.png" -} \ No newline at end of file + "configuration": { + "type": "object", + "title": "VSCode SVG Viewer configuration", + "properties": { + "svgviewer.transparencygrid": { + "type": "boolean", + "default": true, + "description": "Show Transparency Grid" + } + } + } + }, + "scripts": { + "vscode:prepublish": "node ./node_modules/vscode/bin/compile", + "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", + "postinstall": "node ./node_modules/vscode/bin/install" + }, + "devDependencies": { + "typescript": "^1.7.5", + "vscode": "^0.11.1" + }, + "dependencies": { + "copy-paste": "^1.1.4", + "pn": "^1.0.0", + "svg2png": "^3.0.0", + "tmp": "0.0.28" + }, + "repository": { + "type": "git", + "url": "https://github.com/cssho/vscode-svgviewer.git" + }, + "license": "MIT", + "icon": "icon.png" +} diff --git a/src/extension.ts b/src/extension.ts index 672bb91..34675c7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,7 +5,7 @@ import * as vscode from 'vscode'; const fs = require('pn/fs'); const svg2png = require('svg2png'); const tmp = require('tmp'); - +const cp = require('copy-paste'); export function activate(context: vscode.ExtensionContext) { @@ -49,8 +49,7 @@ export function activate(context: vscode.ExtensionContext) { private snippet(properties): string { let showTransGrid = vscode.workspace.getConfiguration('svgviewer').get('transparencygrid'); let transparencyGridCss = ''; - if(showTransGrid) - { + if (showTransGrid) { transparencyGridCss = `