Skip to content

Commit aee317c

Browse files
committed
update to new plugin bundle
1 parent 11366c5 commit aee317c

11 files changed

+115
-40
lines changed

Align bottom to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align horizontal center to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align left to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align right to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align top to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align vertical and horizontal center to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

Align vertical center to key object.sketchplugin

Lines changed: 0 additions & 4 deletions
This file was deleted.

utility.js renamed to AlignTo.sketchplugin/Contents/Sketch/align.cocoascript

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,43 @@
44
* Version: 1.0
55
*/
66

7+
function alignBottom(context){
8+
align("bottom", context)
9+
}
10+
11+
function alignTop(context){
12+
align("top", context)
13+
}
14+
15+
function alignLeft(context){
16+
align("left", context)
17+
}
18+
19+
function alignRight(context){
20+
align("right", context)
21+
}
22+
23+
function alignCenter(context){
24+
align("center", context)
25+
}
26+
27+
function alignHorizontalCenter(context){
28+
align("horizontal center", context)
29+
}
30+
31+
function alignVerticalCenter(context){
32+
align("vertical center", context)
33+
}
34+
35+
736

8-
function align(direction){
9-
if([selection count] < 2){
37+
function align(direction, context){
38+
var selection = context.selection
39+
if(selection.count() < 2){
1040
[doc showMessage:"Please select 2 or more layers."]
1141
}else {
1242
var layers = []
13-
for (var i=0; i < [selection count]; i++){
43+
for (var i=0; i < selection.count(); i++){
1444
layerName = selection[i].name()
1545
layers.push(layerName)
1646
}
@@ -99,13 +129,13 @@ function createSelect(msg, items, selectedItemIndex){
99129
[accessory selectItemAtIndex:selectedItemIndex]
100130

101131
var alert = [[NSAlert alloc] init]
102-
[alert setMessageText:msg]
103-
[alert addButtonWithTitle:'OK']
104-
[alert addButtonWithTitle:'Cancel']
105-
[alert setAccessoryView:accessory]
132+
[alert setMessageText:msg]
133+
[alert addButtonWithTitle:'OK']
134+
[alert addButtonWithTitle:'Cancel']
135+
[alert setAccessoryView:accessory]
106136

107-
var responseCode = [alert runModal]
108-
var sel = [accessory indexOfSelectedItem]
137+
var responseCode = [alert runModal]
138+
var sel = [accessory indexOfSelectedItem]
109139

110-
return [responseCode, sel]
140+
return [responseCode, sel]
111141
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "Align To",
3+
"description": "Plugin that align layer relative to more options for Bohemian Coding's Sketch 3",
4+
"author": "Lucien Lee",
5+
"email": "lucien@lucienlee.cc",
6+
"homepage": "https://github.com/LucienLee/AlignTo",
7+
"version": 1.9,
8+
"identifier": "cc.lucienlee.sketch.align.to",
9+
"compatibleVersion": "3.3.2",
10+
"bundleVersion": 1,
11+
"commands": [
12+
{
13+
"name": "Align top to key object",
14+
"identifier": "top",
15+
"shortcut": "cmd option control t",
16+
"script": "align.cocoascript",
17+
"handler": "alignTop"
18+
},
19+
{
20+
"name": "Align bottom to key object",
21+
"identifier": "bottom",
22+
"shortcut": "cmd option control b",
23+
"script": "align.cocoascript",
24+
"handler": "alignBottom"
25+
},
26+
{
27+
"name": "Align left to key object",
28+
"identifier": "left",
29+
"shortcut": "cmd option control l",
30+
"script": "align.cocoascript",
31+
"handler": "alignLeft"
32+
},
33+
{
34+
"name": "Align right to key object",
35+
"identifier": "right",
36+
"shortcut": "cmd option control r",
37+
"script": "align.cocoascript",
38+
"handler": "alignRight"
39+
},
40+
{
41+
"name": "Align vertical center to key object",
42+
"identifier": "verticalCenter",
43+
"shortcut": "cmd option control v",
44+
"script": "align.cocoascript",
45+
"handler": "alignVerticalCenter"
46+
},
47+
{
48+
"name": "Align horizontal center to key object",
49+
"identifier": "horizontalCenter",
50+
"shortcut": "cmd option control h",
51+
"script": "align.cocoascript",
52+
"handler": "alignHorizontalCenter"
53+
},
54+
{
55+
"name": "Align vertical and horizontal center to key object",
56+
"identifier": "center",
57+
"shortcut": "cmd option control c",
58+
"script": "align.cocoascript",
59+
"handler": "alignCenter"
60+
}
61+
],
62+
"menu": {
63+
"items": [
64+
"top",
65+
"verticalCenter",
66+
"bottom",
67+
"left",
68+
"horizontalCenter",
69+
"right",
70+
"center"
71+
]
72+
}
73+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ Select all layers you want to align, then select `Plugins ▸ AlignTo` in the Sk
4848
- Align vertical and horzonial center relative to key object: `CMD` + `Option` + `Ctrl` + `a`
4949

5050
###Change Shortcut
51-
Open `AlignTo` directory, then open any `*.sketchplugin` file with text editor. Change shortcut you want in the first line.
51+
Open `AlignTo` directory, then open `manifest.json` file with text editor. Change shortcut you want in the command lists.
5252

5353
![change shortcut](./img/shortcut.png)
5454

5555

5656
#Feedback
5757

58-
If you discover any issues or have questions regarding usage, please send a message to [lkiral7903@gmail.com](mailto:lkiral7903@gmail.com)
58+
If you discover any issues or have questions regarding usage, please send a message to [lkiral7903@gmail.com](mailto:lucien@lucienlee.cc)

0 commit comments

Comments
 (0)