This repository has been archived by the owner on Feb 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6acdf82
commit 2e598d8
Showing
15 changed files
with
192 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
// 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 | ||
"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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,15 @@ | |
"name": "vscode-mjml", | ||
"displayName": "MJML", | ||
"description": "MJML preview, lint, compile for Visual Studio Code.", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"publisher": "attilabuti", | ||
"license": "MIT", | ||
"readme": "README.md", | ||
"icon": "images/icon.png", | ||
"author": { | ||
"name": "Attila Buti", | ||
"url": "www.attilabuti.com" | ||
"email": "[email protected]", | ||
"url": "https://attilabuti.com" | ||
}, | ||
"homepage": "https://github.com/attilabuti/vscode-mjml#readme", | ||
"repository": { | ||
|
@@ -26,7 +27,8 @@ | |
"categories": [ | ||
"Other", | ||
"Linters", | ||
"Snippets" | ||
"Snippets", | ||
"Formatters" | ||
], | ||
"keywords": [ | ||
"vscode", | ||
|
@@ -46,6 +48,7 @@ | |
"onCommand:mjml.multipleScreenshots", | ||
"onCommand:mjml.sendEmail", | ||
"onCommand:mjml.template", | ||
"onCommand:mjml.beautify", | ||
"onLanguage:mjml" | ||
], | ||
"main": "./out/extension", | ||
|
@@ -136,6 +139,14 @@ | |
"type": "string", | ||
"default": "", | ||
"description": "Comma separated list of recipients email addresses." | ||
}, | ||
"mjml.beautify": { | ||
"type": "object", | ||
"default": { | ||
"indent_size": 2, | ||
"wrap_attributes_indent_size": 2 | ||
}, | ||
"description": "Beautify options." | ||
} | ||
} | ||
}, | ||
|
@@ -178,6 +189,11 @@ | |
"command": "mjml.template", | ||
"title": "Template", | ||
"category": "MJML" | ||
}, | ||
{ | ||
"command": "mjml.beautify", | ||
"title": "Beautify", | ||
"category": "MJML" | ||
} | ||
], | ||
"languages": [ | ||
|
@@ -226,6 +242,7 @@ | |
"mjml": "^3.3.5", | ||
"node-fetch": "1.7.3", | ||
"node-mailjet": "^3.2.1", | ||
"webshot": "^0.18.0" | ||
"webshot": "^0.18.0", | ||
"js-beautify": "^1.7.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
"use strict"; | ||
|
||
import * as vscode from "vscode"; | ||
|
||
import * as beautifyJS from "js-beautify"; | ||
|
||
import helper from "./helper"; | ||
|
||
export default class Beautify { | ||
|
||
constructor(subscriptions: vscode.Disposable[]) { | ||
subscriptions.push( | ||
vscode.commands.registerCommand("mjml.beautify", () => { | ||
this.beautify(); | ||
}) | ||
); | ||
} | ||
|
||
private beautify(): void { | ||
if (helper.isMJMLFile(vscode.window.activeTextEditor.document)) { | ||
vscode.window.activeTextEditor.edit((editBuilder: vscode.TextEditorEdit) => { | ||
editBuilder.replace(this.getRange(), this.beautifyHTML()); | ||
}); | ||
} | ||
else { | ||
vscode.window.showWarningMessage("This is not a MJML document!"); | ||
return; | ||
} | ||
} | ||
|
||
private beautifyHTML(): any { | ||
try { | ||
return beautifyJS.html( | ||
vscode.window.activeTextEditor.document.getText(), | ||
vscode.workspace.getConfiguration("mjml").beautify | ||
); | ||
} catch (err) { | ||
vscode.window.showErrorMessage(err); | ||
return; | ||
} | ||
} | ||
|
||
private getRange(): vscode.Range { | ||
let document: vscode.TextDocument = vscode.window.activeTextEditor.document; | ||
|
||
return new vscode.Range( | ||
new vscode.Position(0, 0), | ||
new vscode.Position(document.lineCount - 1, document.lineAt(document.lineCount - 1).text.length) | ||
); | ||
} | ||
|
||
public formatDocument(): vscode.TextEdit[] { | ||
return [vscode.TextEdit.replace(this.getRange(), this.beautifyHTML())]; | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ export default class Helper { | |
return html.html; | ||
} | ||
} | ||
catch (e) { | ||
catch (err) { | ||
return; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.