-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.js
41 lines (32 loc) · 847 Bytes
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*!
* CSScomb mixin for Chocolat
* Copyright(c) 2012 Nicholas Penree <[email protected]>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var Comb = require('csscomb');
var COMPATIBLE_SCOPES = [
'plain.text',
'css.source',
'less.source',
'sass.source'
];
/**
* Hook up menu items.
*/
Hooks.addMenuItem('Actions/CSS/Sort via CSScomb', 'control-shift-c', function() {
var output = '', err = '', sel, text, scope;
Recipe.run(function(recipe) {
sel = (!recipe.selection.length)? new Range(0, recipe.length) : recipe.selection;
text = recipe.textInRange(sel);
scope = Document.current().rootScope();
if (!text || COMPATIBLE_SCOPES.indexOf(scope) === -1) {
Alert.beep();
return;
}
recipe.replaceTextInRange(sel, new Comb().processString(text));
return undefined;
});
});