Skip to content

Commit 4dc17ca

Browse files
committed
Sketch 45 compatibility
- #3 - #4
1 parent 29d9a44 commit 4dc17ca

3 files changed

Lines changed: 29 additions & 24 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ This Sketch plugin selects the parent artboards of the current selection when yo
88

99
## Change Log
1010

11+
##### v1.1: 2017-6-28
12+
13+
- Sketch 45 compatibility
14+
1115
##### v1.0: 2016-1-26
1216

1317
- Initial release

Select Parent Artboards.sketchplugin/Contents/Sketch/manifest.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
2+
"name" : "Select Parent Artboards",
3+
"description" : "Selects the parent artboards of the current selection",
24
"author" : "Nefaur Khandker",
5+
"authorEmail" : "nefaurk@gmail.com",
6+
"homepage": "http://github.com/nefaurk/select-parent-artboards",
7+
"version" : "1.1",
8+
"identifier" : "com.nefaurk.sketch-plugins.selectParentArtboards",
9+
"appcast": "https://nefaurk.github.io/sketch-plugins/appcast/select-parent-artboards.xml",
10+
"compatibleVersion": "45",
311
"commands" : [
412
{
513
"script" : "script.cocoascript",
@@ -15,10 +23,5 @@
1523
"items": [
1624
"selectParentArtboards"
1725
]
18-
},
19-
"identifier" : "com.nefaurk.sketch-plugins.selectParentArtboards",
20-
"version" : "1.0",
21-
"description" : "Selects the parent artboards of the current selection",
22-
"authorEmail" : "nefaurk@gmail.com",
23-
"name" : "Select Parent Artboards"
24-
}
26+
}
27+
}
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Helper functions:
22

3-
var artboardForObject = function(object) {
4-
if (object.isKindOfClass(MSArtboardGroup)) {
5-
return object;
6-
} else if (object.parentGroup() != null) {
7-
return artboardForObject(object.parentGroup());
3+
var artboardForItem = function(item) {
4+
if (item.isArtboard) {
5+
return item;
6+
} else if (item.container != null) {
7+
return artboardForItem(item.container);
88
} else {
99
return null;
1010
}
@@ -14,24 +14,22 @@ var artboardForObject = function(object) {
1414
// Handlers:
1515

1616
var selectParentArtboards = function(context) {
17-
var selection = context.selection;
18-
var doc = context.document;
19-
var page = doc.currentPage();
20-
var artboards = page.artboards();
21-
17+
var sketch = context.api();
18+
var document = sketch.selectedDocument;
19+
var selection = document.selectedLayers;
20+
var page = document.selectedPage;
21+
2222
var artboardsToSelect = [];
23-
var selectionLoop = selection.objectEnumerator();
24-
var object;
25-
while (object = selectionLoop.nextObject()) {
26-
var artboard = artboardForObject(object);
23+
selection.iterate(function(item) {
24+
var artboard = artboardForItem(item);
2725
if (artboard != null) {
2826
artboardsToSelect.push(artboard);
2927
}
30-
}
31-
page.deselectAllLayers();
28+
});
29+
selection.clear();
3230

3331
for (var i = 0; i < artboardsToSelect.length; i++) {
3432
var artboard = artboardsToSelect[i];
35-
artboard.select_byExpandingSelection(true, true);
33+
artboard.addToSelection();
3634
}
3735
}

0 commit comments

Comments
 (0)