├── .gitignore ├── LICENSE ├── Layers └── Toggle Layers.sketchplugin ├── Pages ├── View Next Page.sketchplugin └── View Previous Page.sketchplugin ├── README.md ├── Text └── Split Combine Text.sketchplugin │ └── Contents │ └── Sketch │ ├── combine.cocoascript │ ├── manifest.json │ └── split.cocoascript └── sketchpack.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .git 3 | TODO.md -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Josh Wayne 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Layers/Toggle Layers.sketchplugin: -------------------------------------------------------------------------------- 1 | // Toggle Layers (ctrl alt cmd h) 2 | 3 | var doc = context.document; 4 | var layerCompare = "👀"; // change this to whatever you'd like to match 5 | var layerGroups = doc.currentPage().children(); 6 | 7 | for (var i=0; i b.y) { 27 | return 1; 28 | } 29 | if (a.y < b.y) { 30 | return -1; 31 | } 32 | // a must be equal to b 33 | return 0; 34 | }); 35 | 36 | var lineHeight = [newLayer lineHeight], 37 | newFrame = [newLayer frame], 38 | combinedText = textArray.map(function(elem){ 39 | return elem.text; 40 | }).join("\n"); 41 | 42 | // Bug in Sketch causes lineHeight to return 0 if set to auto. Faking it with magic number. 43 | if (lineHeight == 0) { 44 | lineHeight = [newLayer fontSize] * 1.2; 45 | }; 46 | 47 | [newLayer setStringValue: combinedText]; 48 | [newFrame setY: textArray[0].y]; 49 | [newLayer select:true byExpandingSelection:true] 50 | 51 | // New layer still retains old height info; bug? 52 | newFrame.setHeight(Math.round(lineHeight * textArray.length)); 53 | 54 | }; -------------------------------------------------------------------------------- /Text/Split Combine Text.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "author" : "Josh Wayne", 3 | "commands" : [ 4 | { 5 | "script" : "split.cocoascript", 6 | "handler" : "onRun", 7 | "shortcut" : "", 8 | "name" : "Split Text Lines to Layers", 9 | "identifier" : "split text lines to layers" 10 | }, 11 | { 12 | "script" : "combine.cocoascript", 13 | "handler" : "onRun", 14 | "shortcut" : "", 15 | "name" : "Combine Text Layers", 16 | "identifier" : "combine text layers" 17 | } 18 | ], 19 | "menu" : { 20 | "items" : [ 21 | "split text lines to layers", 22 | "combine text layers" 23 | ], 24 | "title" : "Text" 25 | }, 26 | "identifier" : "com.joshwayne.sketch.split-combine-text", 27 | "version" : "3.0", 28 | "description" : "Simple plugin to split and combine multiple text lines.", 29 | "authorEmail" : "", 30 | "name" : "Split/Combine Text" 31 | } -------------------------------------------------------------------------------- /Text/Split Combine Text.sketchplugin/Contents/Sketch/split.cocoascript: -------------------------------------------------------------------------------- 1 | var onRun = function(context) { 2 | // Split text lines to layers 3 | 4 | var selectedLayers = context.selection, 5 | selectedCount = selectedLayers.count(); 6 | 7 | if (selectedCount == 0) { 8 | log('No layers are selected.'); 9 | } else { 10 | // Loop through selected layers 11 | for (var i=0; i