├── README.md └── Select Parent Artboards.sketchplugin └── Contents └── Sketch ├── manifest.json └── script.cocoascript /README.md: -------------------------------------------------------------------------------- 1 | # Select Parent Artboards 2 | 3 | This Sketch plugin selects the parent artboards of the current selection when you press **⌃⌘A**. 4 | 5 | ## Installation 6 | 7 | [Download](https://github.com/nefaurk/select-parent-artboards/archive/master.zip) and extract the contents of this repository. Then double-click the `Select Parent Artboards.sketchplugin` bundle to install the plugin. 8 | 9 | ## Change Log 10 | 11 | ##### v1.2: 2017-12-13 12 | 13 | - Fixing an issue where selecting a symbol wouldn't work 14 | 15 | ##### v1.1: 2017-6-28 16 | 17 | - Sketch 45 compatibility 18 | 19 | ##### v1.0: 2016-1-26 20 | 21 | - Initial release 22 | 23 | ## License 24 | 25 | The MIT License (MIT) 26 | 27 | Copyright (c) 2016 Nefaur Khandker 28 | 29 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 30 | 31 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 32 | 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /Select Parent Artboards.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Select Parent Artboards", 3 | "description" : "Selects the parent artboards of the current selection", 4 | "author" : "Nefaur Khandker", 5 | "authorEmail" : "nefaurk@gmail.com", 6 | "homepage": "http://github.com/nefaurk/select-parent-artboards", 7 | "version" : "1.2", 8 | "identifier" : "com.nefaurk.sketch-plugins.selectParentArtboards", 9 | "appcast": "https://nefaurk.github.io/sketch-plugins/appcast/select-parent-artboards.xml", 10 | "compatibleVersion": "48.1", 11 | "commands" : [ 12 | { 13 | "script" : "script.cocoascript", 14 | "handler" : "selectParentArtboards", 15 | "shortcut" : "cmd ctrl a", 16 | "name" : "Select Parent Artboards", 17 | "identifier" : "selectParentArtboards" 18 | } 19 | ], 20 | "menu": { 21 | "title" : "Select Parent Artboards", 22 | "isRoot" : true, 23 | "items": [ 24 | "selectParentArtboards" 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Select Parent Artboards.sketchplugin/Contents/Sketch/script.cocoascript: -------------------------------------------------------------------------------- 1 | // Helper functions: 2 | 3 | var artboardForItem = function(document, item) { 4 | if (item.isArtboard) { 5 | return item; 6 | } else if (item.sketchObject != null && item.sketchObject.className() == "MSSymbolInstance") { 7 | var parent = item.sketchObject.parentGroup(); 8 | var container = document.wrapObject(parent); 9 | return artboardForItem(document, container); 10 | } else if (item.container != null) { 11 | return artboardForItem(document, item.container); 12 | } else { 13 | return null; 14 | } 15 | }; 16 | 17 | 18 | // Handlers: 19 | 20 | var selectParentArtboards = function(context) { 21 | var sketch = context.api(); 22 | var document = sketch.selectedDocument; 23 | var selection = document.selectedLayers; 24 | var page = document.selectedPage; 25 | 26 | var artboardsToSelect = []; 27 | selection.iterate(function(item) { 28 | var artboard = artboardForItem(document, item); 29 | if (artboard != null) { 30 | artboardsToSelect.push(artboard); 31 | } 32 | }); 33 | selection.clear(); 34 | 35 | for (var i = 0; i < artboardsToSelect.length; i++) { 36 | var artboard = artboardsToSelect[i]; 37 | artboard.addToSelection(); 38 | } 39 | } 40 | --------------------------------------------------------------------------------