├── .gitignore ├── Notes.sketchplugin └── Contents │ ├── Resources │ └── icon.png │ └── Sketch │ ├── hide.js │ ├── manifest.json │ ├── notes.js │ └── settings.js ├── README.md ├── images ├── cat.png ├── cover.png └── icon.png └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | old-notes.txt 3 | 4 | *.sketch 5 | images/notes-ani.framer 6 | images/notes.gif 7 | -------------------------------------------------------------------------------- /Notes.sketchplugin/Contents/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshdllr/Notes/962e1c665d054000aedabc6d70bed140ae432b23/Notes.sketchplugin/Contents/Resources/icon.png -------------------------------------------------------------------------------- /Notes.sketchplugin/Contents/Sketch/hide.js: -------------------------------------------------------------------------------- 1 | var setTaggedLayersVisible = function(context, visible) { 2 | var command = context.command; // The current command (MSPluginCommand) 3 | var doc = context.document; // the current document (MSDocument) 4 | var page = doc.currentPage(); // the current page (MSPage) 5 | var layers = page.children(); // A flattened array (NSArray) of all layers in `page` 6 | 7 | // Loop through each layer on the page searching for the note attribute 8 | for (var i=0; i<[layers count]; i++) { 9 | var layer = layers[i]; 10 | // test for the "tagged" attribute 11 | if ([command valueForKey:"note" onLayer:layer]) { 12 | // toggle this layer's visiblity 13 | // [layer setIsVisible:visible]; 14 | 15 | layer.setIsVisible(visible); 16 | } 17 | } 18 | }; 19 | 20 | var showNotes = function(context) { 21 | setTaggedLayersVisible(context, true); 22 | }; 23 | 24 | var hideNotes = function(context) { 25 | setTaggedLayersVisible(context, false); 26 | }; -------------------------------------------------------------------------------- /Notes.sketchplugin/Contents/Sketch/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "📝 Notes", 3 | "description" : "Quickly take notes in Sketch", 4 | "author" : "Jason Cashdollar", 5 | "authorEmail" : "jason.cashdollar@gmail.com", 6 | "version" : "2.3", 7 | "identifier" : "com.jasoncashdollar.sketchplugins.notes", 8 | "appcast" : "https://api.sketchpacks.com/v1/plugins/com.jasoncashdollar.sketchplugins.notes/appcast", 9 | "commands" : [ 10 | { 11 | "script" : "notes.js", 12 | "handler" : "newNote", 13 | "shortcut" : "command l", 14 | "identifier": "newNote", 15 | "name" : "New Note" 16 | }, 17 | { 18 | "script" : "hide.js", 19 | "handler" : "hideNotes", 20 | "shortcut" : "", 21 | "identifier": "hideNotes", 22 | "name" : "Hide Notes" 23 | }, 24 | { 25 | "script" : "hide.js", 26 | "handler" : "showNotes", 27 | "shortcut" : "", 28 | "identifier": "showNotes", 29 | "name" : "Show Notes" 30 | }, 31 | { 32 | "script" : "settings.js", 33 | "handler" : "editSettings", 34 | "shortcut" : "", 35 | "identifier": "editSettings", 36 | "name" : "Settings..." 37 | } 38 | ], 39 | "menu": { 40 | "items": [ 41 | "newNote", 42 | "-", 43 | "hideNotes", 44 | "showNotes", 45 | "-", 46 | "editSettings" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Notes.sketchplugin/Contents/Sketch/notes.js: -------------------------------------------------------------------------------- 1 | var kNoteScaleKey = "com.jasoncashdollar.sketchplugins.notes.scale"; 2 | var kNoteColorKey = "com.jasoncashdollar.sketchplugins.notes.color"; 3 | 4 | var newNote = function (context) { 5 | log("starting new note"); 6 | var doc = context.document; 7 | var view = doc.contentDrawView().visibleContentRect(); 8 | var page = doc.currentPage(); 9 | var command = context.command; 10 | 11 | var scale = NSUserDefaults.standardUserDefaults().objectForKey(kNoteScaleKey) || 1; 12 | var colorName = NSUserDefaults.standardUserDefaults().objectForKey(kNoteColorKey) || "Yellow"; 13 | 14 | // could not get switch statement to work here...better done than perfect? 15 | if (colorName == "Yellow") { 16 | var color = MSColor.colorWithRed_green_blue_alpha(255/255, 242/255, 133/255, 1.0); 17 | } else if (colorName == "Blue") { 18 | var color = MSColor.colorWithRed_green_blue_alpha(188/255, 236/255, 255/255, 1.0); 19 | } else if (colorName == "Green") { 20 | var color = MSColor.colorWithRed_green_blue_alpha(199/255, 255/255, 190/255, 1.0); 21 | } else if (colorName == "Red") { 22 | var color = MSColor.colorWithRed_green_blue_alpha(255/255, 176/255, 176/255, 1.0); 23 | } else if (colorName == "Purple") { 24 | var color = MSColor.colorWithRed_green_blue_alpha(236/255, 191/255, 255/255, 1.0); 25 | } 26 | 27 | var width = 200 * scale; 28 | var height = 200 * scale; 29 | var x = Math.round(view.origin.x + view.size.width/2 - width/2); 30 | var y = Math.round(view.origin.y + view.size.height/2 - height/2); 31 | var padding = 10 * scale; 32 | var noteColor = color; 33 | 34 | // the square for the note 35 | var rectangleLayer = MSRectangleShape.alloc().init(); 36 | rectangleLayer.frame().setWidth(width); 37 | rectangleLayer.frame().setHeight(height); 38 | rectangleLayer.cornerRadiusFloat = 2; 39 | 40 | var shapeGroup = MSShapeGroup.alloc().init(); 41 | shapeGroup.frame().setWidth(width); 42 | shapeGroup.frame().setHeight(height); 43 | shapeGroup.frame().setX(x); 44 | shapeGroup.frame().setY(y); 45 | shapeGroup.setName("Paper"); 46 | var styleType = 0; // 0 = fill 47 | var shadowType = 2; 48 | var fill = shapeGroup.style().addStylePartOfType(styleType); 49 | fill.color = noteColor; 50 | shapeGroup.style().addStylePartOfType(shadowType); 51 | shapeGroup.addLayers([rectangleLayer]); 52 | 53 | // the text of the note 54 | var textLayer = MSTextLayer.alloc().init(); 55 | textLayer.frame().setWidth(width - 2*padding); 56 | textLayer.frame().setHeight(height - 2*padding); 57 | textLayer.frame().setX(x + padding); 58 | textLayer.frame().setY(y + padding); 59 | textLayer.setName("Note"); 60 | var fixedBehaviour = 1; 61 | textLayer.setTextBehaviour(fixedBehaviour); 62 | textLayer.setStringValue("Press enter to start typing..."); 63 | textLayer.setFontSize(14 * scale); 64 | 65 | var group = MSLayerGroup.alloc().init(); 66 | group.addLayers( [shapeGroup, textLayer] ); 67 | group.setName("Post-it®"); 68 | page.addLayers( [group] ); 69 | group.fixGeometryWithOptions(0); 70 | // add metadata to the layer 71 | [command setValue:true forKey:"note" onLayer:group]; 72 | 73 | // select text layer 74 | textLayer.select_byExtendingSelection(true, false); 75 | log("end note creation"); 76 | } -------------------------------------------------------------------------------- /Notes.sketchplugin/Contents/Sketch/settings.js: -------------------------------------------------------------------------------- 1 | var kNoteScaleKey = "com.jasoncashdollar.sketchplugins.notes.scale"; 2 | var kNoteColorKey = "com.jasoncashdollar.sketchplugins.notes.color"; 3 | 4 | var editSettings = function(context) { 5 | log("open settings"); 6 | 7 | // create settings window 8 | var settingsWindow = COSAlertWindow.new(); 9 | settingsWindow.setMessageText("Notes Settings"); 10 | settingsWindow.addButtonWithTitle("Save"); 11 | settingsWindow.addButtonWithTitle("Cancel"); 12 | settingsWindow.setIcon(NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path())); 13 | 14 | // add scaling options 15 | settingsWindow.addTextLabelWithValue("Scale Options"); 16 | var scaleOptions = [1, 2, 3]; 17 | var numOptions = scaleOptions.length; 18 | var exportScale = NSUserDefaults.standardUserDefaults().objectForKey(kNoteScaleKey) || 1; 19 | var buttonCell = NSButtonCell.new(); 20 | buttonCell.setTitle("settings-scaleOptions"); 21 | buttonCell.setButtonType(NSRadioButton); 22 | 23 | var scaleOptionsMatrix = NSMatrix.alloc().initWithFrame_mode_prototype_numberOfRows_numberOfColumns(NSMakeRect(0, 0, 300, 22), NSRadioModeMatrix, buttonCell, 1, numOptions); 24 | scaleOptionsMatrix.setAutorecalculatesCellSize(true); 25 | scaleOptionsMatrix.setIntercellSpacing(NSMakeSize(-50,0)); 26 | var cells = scaleOptionsMatrix.cells(); 27 | var scaleOption; 28 | 29 | for (var i = 0; iHello world! 2 | --------------------------------------------------------------------------------