Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from cssho/DataUriCopy
Browse files Browse the repository at this point in the history
Add new feature.Copy "SVG data URI scheme" to the clipboard.
  • Loading branch information
cssho committed Mar 29, 2016
2 parents 1d23920 + 25c8d99 commit 8b9ed53
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 73 deletions.
3 changes: 3 additions & 0 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ SVGをエディタ上で表示
### Export PNG - `Ctrl(Cmd)+I E`
SVGをPNGに変換

### Copy data URI scheme - `Ctrl(Cmd)+I C`
SVGをdata URI schemeに変換し、クリップボードにコピー

![preview](img/preview.png)

### Options
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Display SVG on an Editor
### Export PNG - `Ctrl(Cmd)+I E`
Convert from SVG to PNG

### Copy data URI scheme - `Ctrl(Cmd)+I C`
Convert from SVG to data URI scheme and copy to the clipboard

![preview](img/preview.png)

### Options
Expand Down
Binary file modified img/palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
151 changes: 81 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
"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"
}
14 changes: 11 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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 = `
<style type="text/css">
.svgbg svg {
Expand Down Expand Up @@ -104,6 +103,15 @@ export function activate(context: vscode.ExtensionContext) {
});

context.subscriptions.push(saveas);

let copydu = vscode.commands.registerTextEditorCommand('svgviewer.copydui', (te, t) => {
if (checkNoSvg(te)) return;
let editor = vscode.window.activeTextEditor;
let text = editor.document.getText();
cp.copy('data:image/svg+xml,' + encodeURIComponent(text));
});

context.subscriptions.push(copydu);
}
function checkNoSvg(editor: vscode.TextEditor) {

Expand Down

0 comments on commit 8b9ed53

Please sign in to comment.