├── .gitignore
├── LICENSE
├── README.md
├── docs
├── ace-jump-font-size.gif
├── ace-jump-font-weight.gif
├── ace-jump-style-color.gif
└── runner-installation.png
├── package.json
├── releases
├── ace-jump-0.1.1.zip
└── com.turbobabr.ace-jump.sketchplugin
│ └── Contents
│ └── Sketch
│ ├── manifest.json
│ └── plugin.js
├── src
├── constants.js
├── focus.js
└── plugin.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | node_modules
3 | .DS_Store
4 | .idea
5 | npm-debug.log
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Andrey Shakhmin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, 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,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sketch Ace Jump
2 |
3 | A small SketchApp plugin that allows to focus on various inspector's fields like font size, font weight and text/fill color using shortcuts.
4 |
5 | ## Install with Sketch Runner
6 | With Sketch Runner, just go to the `install` command and search for `ace jump`. Runner allows you to manage plugins and do much more to speed up your workflow in Sketch. [Download Runner here](http://www.sketchrunner.com).
7 |
8 | 
9 |
10 | ## Manual Installation
11 |
12 | 1. [Download](https://github.com/turbobabr/sketch-ace-jump/raw/master/releases/ace-jump-0.1.1.zip) the plugin.
13 | 2. Unpack the archive and double click on `com.turbobabr.ace-jump.sketchplugin` file to install it into Sketch plugins folder.
14 | 3. Enjoy! :)
15 |
16 | # Usage
17 |
18 | ## Font Size
19 |
20 | Shortcut: ctrl + s
21 |
22 | 
23 |
24 | ## Font Weight
25 |
26 | Shortcut: ctrl + w
27 |
28 | After focusing on font the weight popover, use up/down arrow keys or first letter of desired a weight to select a required item in the list and hit enter to apply it.
29 |
30 | 
31 |
32 | ## Text/Fill Color
33 |
34 | Shortcut: ctrl + shift + c
35 |
36 | Depending on selected layers, command shows a color picker for text color or first visible fill color in `Fills` section.
37 |
38 | 
39 |
40 | ## Feedback
41 |
42 | If you discover any issue or have any suggestions for improvement of the plugin, please [open an issue](https://github.com/turbobabr/sketch-ace-jump/issues) or find me on twitter [@turbobabr](http://twitter.com/turbobabr).
43 |
44 |
45 |
46 | ## License
47 |
48 | The MIT License (MIT)
49 |
50 | Copyright (c) 2017 Andrey Shakhmin
51 |
52 | 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:
53 |
54 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
55 |
56 | 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.
--------------------------------------------------------------------------------
/docs/ace-jump-font-size.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/turbobabr/sketch-ace-jump/2293ce26f902f7b94b08df530bdbfe8092949bc3/docs/ace-jump-font-size.gif
--------------------------------------------------------------------------------
/docs/ace-jump-font-weight.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/turbobabr/sketch-ace-jump/2293ce26f902f7b94b08df530bdbfe8092949bc3/docs/ace-jump-font-weight.gif
--------------------------------------------------------------------------------
/docs/ace-jump-style-color.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/turbobabr/sketch-ace-jump/2293ce26f902f7b94b08df530bdbfe8092949bc3/docs/ace-jump-style-color.gif
--------------------------------------------------------------------------------
/docs/runner-installation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/turbobabr/sketch-ace-jump/2293ce26f902f7b94b08df530bdbfe8092949bc3/docs/runner-installation.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sketch-ace-jump",
3 | "version": "0.1.0",
4 | "description": "Quickly focus on various inspector's fields like font size, font weight and text/fill color using shortcuts.",
5 | "main": "webpack.config.js",
6 | "scripts": {
7 | "build": "webpack",
8 | "develop": "webpack --watch"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/turbobabr/sketch-ace-jump.git"
13 | },
14 | "keywords": [
15 | "sketch",
16 | "extension",
17 | "plugin"
18 | ],
19 | "author": "Andrey Shakhmin",
20 | "license": "MIT",
21 | "bugs": {
22 | "url": "https://github.com/turbobabr/sketch-ace-jump/issues"
23 | },
24 | "homepage": "https://github.com/turbobabr/sketch-ace-jump#readme",
25 | "devDependencies": {
26 | "babel-core": "^6.18.2",
27 | "babel-loader": "^6.2.7",
28 | "babel-plugin-transform-object-rest-spread": "^6.16.0",
29 | "babel-preset-es2015": "^6.18.0",
30 | "babel-preset-stage-0": "^6.16.0",
31 | "lodash": "^4.16.6",
32 | "webpack": "^1.13.3"
33 | },
34 | "dependencies": {
35 | "lodash": "^4.17.2"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/releases/ace-jump-0.1.1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/turbobabr/sketch-ace-jump/2293ce26f902f7b94b08df530bdbfe8092949bc3/releases/ace-jump-0.1.1.zip
--------------------------------------------------------------------------------
/releases/com.turbobabr.ace-jump.sketchplugin/Contents/Sketch/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Ace Jump",
3 | "identifier": "com.turbobabr.ace-jump",
4 | "description": "Quickly focus on various inspector's fields like font size, font weight and text/fill color using shortcuts.",
5 | "version": "0.1.1",
6 | "author": "Andrey Shakhmin",
7 | "homepage": "https://github.com/turbobabr/sketch-ace-jump",
8 | "commands": [
9 | {
10 | "name": "Font Size",
11 | "shortcut": "control s",
12 | "identifier": "TextStyle.fontSize",
13 | "script": "plugin.js",
14 | "handlers": {
15 | "run": "___TextStyle_fontSize_run_handler_",
16 | "actions": {}
17 | }
18 | },
19 | {
20 | "name": "Font Weight",
21 | "shortcut": "control w",
22 | "identifier": "TextStyle.fontWeight",
23 | "script": "plugin.js",
24 | "handlers": {
25 | "run": "___TextStyle_fontWeight_run_handler_",
26 | "actions": {}
27 | }
28 | },
29 | {
30 | "name": "Text/Fill Color",
31 | "shortcut": "control shift c",
32 | "identifier": "Style.color",
33 | "script": "plugin.js",
34 | "handlers": {
35 | "run": "___Style_color_run_handler_",
36 | "actions": {}
37 | }
38 | }
39 | ],
40 | "menu": {
41 | "items": [
42 | "TextStyle.fontSize",
43 | "TextStyle.fontWeight",
44 | "Style.color"
45 | ]
46 | },
47 | "disableCocoaScriptPreprocessor": true
48 | }
--------------------------------------------------------------------------------
/releases/com.turbobabr.ace-jump.sketchplugin/Contents/Sketch/plugin.js:
--------------------------------------------------------------------------------
1 | !function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){(function(e){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}var o=r(1),n=t(o),i=r(2),l=function(e,t){(0,n.default)(e,t)};e({name:"Ace Jump",identifier:"com.turbobabr.ace-jump",description:"Quickly focus on various inspector's fields like font size, font weight and text/fill color using shortcuts.",version:"0.1.1",author:"Andrey Shakhmin",homepage:"https://github.com/turbobabr/sketch-ace-jump",commands:{"TextStyle.fontSize":{name:"Font Size",shortcut:"control-s",run:function(e){l(e,i.InspectorField.FontSize)}},"TextStyle.fontWeight":{name:"Font Weight",shortcut:"control-w",run:function(e){l(e,i.InspectorField.FontWeight)}},"Style.color":{name:"Text/Fill Color",shortcut:"control-shift-c",run:function(e){l(e,i.InspectorField.StyleColor)}}},menu:{items:["TextStyle.fontSize","TextStyle.fontWeight","Style.color"]}})}).call(t,function(){return function(e){function t(e,t){for(var r=-1,o=null==e?0:e.length;++r0},c=function(e,t,r){var o=e.document,n=o.documentWindow();switch(r){case i.JumpAction.MakeFirstResponder:n.makeFirstResponder(t);break;case i.JumpAction.PerformClick:t.performClick(null)}},s=t.Descriptors=(n={},o(n,i.InspectorField.FontSize,{id:i.InspectorField.FontSize,name:"Font Size",controllerClass:l.MSNormalInspector,path:"standardInspectors.layerViewController.layerInspectorControllers",sectionController:l.MSTextLayerSection,subPath:"fontSizeField",action:i.JumpAction.MakeFirstResponder}),o(n,i.InspectorField.FontWeight,{id:i.InspectorField.FontWeight,name:"Font Weight",controllerClass:l.MSNormalInspector,path:"standardInspectors.layerViewController.layerInspectorControllers",sectionController:l.MSTextLayerSection,subPath:"fontWeightPopUpButton",action:i.JumpAction.PerformClick}),o(n,i.InspectorField.StyleColor,{id:i.InspectorField.StyleColor,name:"Text/Fill Color",exec:function(e){var t=e.selection,r=e.document;if(a(t,l.MSTextLayer))u(e,i.InspectorField.TextColor);else if(a(t,l.MSStyledLayer)){var o=r.valueForKeyPath("inspectorController.currentController");if(o.className()!=l.MSNormalInspector)return;var n=o.valueForKeyPath("standardInspectors.fillViewController.stylePartViewControllers");if(n.count()<1||!n.lastObject())return;c(e,n.lastObject().colorButton(),i.JumpAction.PerformClick)}}}),o(n,i.InspectorField.TextColor,{id:i.InspectorField.TextColor,name:"Text Color",controllerClass:l.MSNormalInspector,path:"standardInspectors.layerViewController.layerInspectorControllers",sectionController:"MSTextLayerSection",subPath:"colorPickerButton",action:i.JumpAction.PerformClick}),n),u=function(e,t){var r=e.document,o=s[t];if(o){if(o.exec)return void o.exec(e);var n=r.valueForKeyPath("inspectorController.currentController");if(n.className()==o.controllerClass){var i=function(e){if(!e.sectionController)return n.valueForKeyPath(e.path);var t=n.valueForKeyPath(e.path),r=t.filteredArrayUsingPredicate(NSPredicate.predicateWithFormat("className == '"+e.sectionController+"'")).firstObject();return r?r.valueForKeyPath(e.subPath):null},l=i(o);l&&c(e,l,o.action)}}};t.default=u},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.InspectorField={FontSize:"TextStyle.fontSize",FontWeight:"TextStyle.fontWeight",StyleColor:"Style.color",FillColor:"Style.fillColor",TextColor:"TextStyle.color"},t.JumpAction={MakeFirstResponder:"makeFirstResponder",PerformClick:"performClick"}}]);
--------------------------------------------------------------------------------
/src/constants.js:
--------------------------------------------------------------------------------
1 |
2 | export const InspectorField = {
3 | FontSize: 'TextStyle.fontSize',
4 | FontWeight: 'TextStyle.fontWeight',
5 | StyleColor: 'Style.color',
6 | FillColor: 'Style.fillColor',
7 | TextColor: 'TextStyle.color'
8 | };
9 |
10 | export const JumpAction = {
11 | MakeFirstResponder: 'makeFirstResponder',
12 | PerformClick: 'performClick'
13 | };
14 |
--------------------------------------------------------------------------------
/src/focus.js:
--------------------------------------------------------------------------------
1 |
2 | import { InspectorField, JumpAction } from './constants';
3 |
4 | const ClassName = {
5 | MSTextLayer: 'MSTextLayer',
6 | MSStyledLayer: 'MSStyledLayer',
7 | MSNormalInspector: 'MSNormalInspector',
8 | MSTextLayerSection: 'MSTextLayerSection'
9 | };
10 |
11 | const containsLayersOfType = (list,type) => {
12 | return list.filteredArrayUsingPredicate(NSPredicate.predicateWithFormat(`self isKindOfClass: %@`,NSClassFromString(type))).count() > 0;
13 | };
14 |
15 | const performAction = (context, control,action) => {
16 | const { document } = context;
17 | const window = document.documentWindow();
18 |
19 | switch(action) {
20 | case JumpAction.MakeFirstResponder:
21 | window.makeFirstResponder(control);
22 | break;
23 | case JumpAction.PerformClick:
24 | control.performClick(null);
25 | break;
26 | }
27 | };
28 |
29 | export const Descriptors = {
30 | // Text Style.
31 | [InspectorField.FontSize]: {
32 | id: InspectorField.FontSize,
33 | name: 'Font Size',
34 | controllerClass: ClassName.MSNormalInspector,
35 | path: 'standardInspectors.layerViewController.layerInspectorControllers',
36 | sectionController: ClassName.MSTextLayerSection,
37 | subPath: 'fontSizeField',
38 | action: JumpAction.MakeFirstResponder
39 | },
40 | [InspectorField.FontWeight]: {
41 | id: InspectorField.FontWeight,
42 | name: 'Font Weight',
43 | controllerClass: ClassName.MSNormalInspector,
44 | path: 'standardInspectors.layerViewController.layerInspectorControllers',
45 | sectionController: ClassName.MSTextLayerSection,
46 | subPath: 'fontWeightPopUpButton',
47 | action: JumpAction.PerformClick
48 | },
49 | [InspectorField.StyleColor]: {
50 | id: InspectorField.StyleColor,
51 | name: 'Text/Fill Color',
52 | exec: (context) => {
53 | const { selection, document } = context;
54 | if(containsLayersOfType(selection,ClassName.MSTextLayer)) {
55 | focus(context,InspectorField.TextColor);
56 | } else if(containsLayersOfType(selection,ClassName.MSStyledLayer)) {
57 | const currentController = document.valueForKeyPath('inspectorController.currentController');
58 | if(currentController.className() != ClassName.MSNormalInspector) {
59 | return;
60 | }
61 |
62 | const fillControllers = currentController.valueForKeyPath('standardInspectors.fillViewController.stylePartViewControllers');
63 | if(fillControllers.count()<1 || !fillControllers.lastObject()) {
64 | return;
65 | }
66 |
67 | performAction(context,fillControllers.lastObject().colorButton(),JumpAction.PerformClick);
68 | }
69 | }
70 | },
71 | [InspectorField.TextColor]: {
72 | id: InspectorField.TextColor,
73 | name: 'Text Color',
74 | controllerClass: ClassName.MSNormalInspector,
75 | path: 'standardInspectors.layerViewController.layerInspectorControllers',
76 | sectionController: 'MSTextLayerSection',
77 | subPath: 'colorPickerButton',
78 | action: JumpAction.PerformClick
79 | }
80 | };
81 |
82 | const focus = (context,field) => {
83 | const { document } = context;
84 |
85 | const descriptor = Descriptors[field];
86 | if(!descriptor) {
87 | return;
88 | }
89 |
90 | if(descriptor.exec) {
91 | descriptor.exec(context);
92 | return;
93 | }
94 |
95 | const currentController = document.valueForKeyPath('inspectorController.currentController');
96 | if(currentController.className() != descriptor.controllerClass) {
97 | return;
98 | }
99 |
100 | const findControl = (descriptor) => {
101 | if(!descriptor.sectionController) {
102 | return currentController.valueForKeyPath(descriptor.path);
103 | }
104 |
105 | const sections = currentController.valueForKeyPath(descriptor.path);
106 | const targetSection = sections.filteredArrayUsingPredicate(NSPredicate.predicateWithFormat(`className == '${descriptor.sectionController}'`)).firstObject();
107 | if(!targetSection) {
108 | return null;
109 | }
110 |
111 | return targetSection.valueForKeyPath(descriptor.subPath);
112 | };
113 |
114 | const control = findControl(descriptor);
115 | if(!control) {
116 | return
117 | }
118 |
119 | performAction(context,control,descriptor.action);
120 | };
121 |
122 | export default focus;
--------------------------------------------------------------------------------
/src/plugin.js:
--------------------------------------------------------------------------------
1 | import focus from './focus';
2 | import { InspectorField } from './constants';
3 |
4 | const focusOnControl = (context,id) => {
5 | focus(context,id);
6 | };
7 |
8 | DefineSketchExtension({
9 | name: 'Ace Jump',
10 | identifier: 'com.turbobabr.ace-jump',
11 | description: "Quickly focus on various inspector's fields like font size, font weight and text/fill color using shortcuts.",
12 | version: '0.1.1',
13 | author: 'Andrey Shakhmin',
14 | homepage: 'https://github.com/turbobabr/sketch-ace-jump',
15 | commands: {
16 | 'TextStyle.fontSize': {
17 | name: 'Font Size',
18 | shortcut: 'control-s',
19 | run(context) {
20 | focusOnControl(context,InspectorField.FontSize);
21 | }
22 | },
23 | 'TextStyle.fontWeight': {
24 | name: 'Font Weight',
25 | shortcut: 'control-w',
26 | run(context) {
27 | focusOnControl(context,InspectorField.FontWeight);
28 | }
29 | },
30 | 'Style.color': {
31 | name: 'Text/Fill Color',
32 | shortcut: 'control-shift-c',
33 | run(context) {
34 | focusOnControl(context,InspectorField.StyleColor);
35 | }
36 | }
37 | },
38 | menu: {
39 | items: [
40 | 'TextStyle.fontSize',
41 | 'TextStyle.fontWeight',
42 | 'Style.color'
43 | ]
44 | }
45 |
46 | });
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var webpack = require('webpack');
4 | var path = require('path');
5 | var SketchFusionExtensionPlugin = require('sketch-fusion-extension-plugin-webpack');
6 |
7 | const CONTEXT = path.resolve(__dirname),
8 | createPath = function(nPath) { return path.resolve(CONTEXT, nPath); },
9 | SRC_PATH = createPath('src'),
10 | NODE_MODULES = createPath('node_modules'),
11 | RESOURCES = createPath('resources'),
12 | COMPILER = createPath('compiler');
13 |
14 | module.exports = {
15 | context: CONTEXT,
16 | entry: './src/plugin.js',
17 | output: {
18 | path: 'build',
19 | filename: 'plugin.js'
20 | },
21 | watchOptions: {
22 | aggregateTimeout: 100
23 | },
24 | module: {
25 | loaders: [{
26 | test: /\.js$/,
27 | loader: 'babel',
28 | query: {
29 | presets: ['es2015','stage-0'],
30 | plugins: ['transform-object-rest-spread']
31 | },
32 | include: [SRC_PATH],
33 | exclude: [NODE_MODULES,COMPILER,RESOURCES]
34 | },{ test: /\.json$/, loader: "json" }]
35 | },
36 | plugins:[
37 | new SketchFusionExtensionPlugin({
38 | buildReleaseVersion: true,
39 | autoDeployToSketch: true
40 | }),
41 | new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
42 | ]
43 | };
--------------------------------------------------------------------------------