Permalink
Please sign in to comment.
Showing
with
37 additions
and 36 deletions.
- +1 −3 .gitignore
- +11 −8 README.md
- +1 −1 iconfont.sketchplugin/Contents/Sketch/{add.cocoascript → add.js}
- +1 −1 iconfont.sketchplugin/Contents/Sketch/{add_grid.cocoascript → add_grid.js}
- +2 −2 iconfont.sketchplugin/Contents/Sketch/const/{export.cocoascript → export.js}
- +1 −1 iconfont.sketchplugin/Contents/Sketch/const/{import.cocoascript → import.js}
- +2 −2 iconfont.sketchplugin/Contents/Sketch/const/{install.cocoascript → install.js}
- 0 iconfont.sketchplugin/Contents/Sketch/const/{library.cocoascript → library.js}
- +0 −1 iconfont.sketchplugin/Contents/Sketch/const/remove.cocoascript
- +1 −0 iconfont.sketchplugin/Contents/Sketch/const/remove.js
- +1 −1 iconfont.sketchplugin/Contents/Sketch/{convert.cocoascript → convert.js}
- +1 −1 iconfont.sketchplugin/Contents/Sketch/{learn.cocoascript → learn.js}
- +8 −8 iconfont.sketchplugin/Contents/Sketch/manifest.json
- +7 −7 iconfont.sketchplugin/Contents/Sketch/structure.json
| @@ -1,4 +1,2 @@ | ||
| .DS_Store | ||
| -iconfont.sketchplugin/Contents/Sketch/manifest.json | ||
| -/iconfont.sketchplugin/Contents/Sketch/manifest.json | ||
| -iconfont.sketchplugin/Contents/Resources/bundle/* | ||
| +iconfont.sketchplugin/Contents/Resources/bundle/* |
File renamed without changes.
| @@ -1 +0,0 @@ | ||
| -@import "library.cocoascript";var onRun = function(context) { var plugin = context.plugin var doc = context.document var fileManager = NSFileManager.defaultManager() var scriptFullPath = context.scriptPath var directoryPlugin = [[scriptFullPath stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] var resources = [directoryPlugin stringByDeletingLastPathComponent] + "/Resources" // 1. Create Window var wrapper = Library.Widgets.window("Remove Font", "Select font to remove") // 2. Fetch fonts.json file var json = Library.fetch.json("fonts.json",plugin) var fonts = [json objectForKey:@"fonts"] // 3. create a combobox to select font which wants to remove var selectbox = [[NSComboBox alloc] initWithFrame:NSMakeRect(90,175,220,24)] selectbox.addItemsWithObjectValues(fonts) selectbox.setItemHeight(20.0) selectbox.selectItemAtIndex(0) selectbox.setEditable(false) wrapper.main.addSubview(selectbox) // 4. create a remove button var submit = [[NSButton alloc] initWithFrame:NSMakeRect(350, 150, 200, 50)] submit.setTitle("") submit.setAction("callAction:") submit.setWantsLayer(true) submit.setCOSJSTargetFunction(function(sender) { wrapper.window.orderOut(nil) NSApp.stopModalWithCode(NSOKButton) }) // 4.1. create a layer for remove button var submit_text = CATextLayer.layer() submit_text.setBackgroundColor(NSColor.blackColor()) submit_text.setForegroundColor(CGColorCreateGenericRGB(215/255, 159/255, 0/255, 1.0)) submit_text.setFontSize(18) submit_text.contentsScale = NSScreen.mainScreen().backingScaleFactor() submit_text.string = "- Remove this font" submit.setLayer(submit_text) wrapper.main.addSubview(submit) var response = NSApp.runModalForWindow(wrapper.window) // if is the response is ok, remove the font if (response == NSOKButton) { selected_font = selectbox.objectValueOfSelectedItem() font = fonts[selected_font] // // 4. Remove the json file of the font // full_path = resources + "/bundle/" + font.path [fileManager removeItemAtPath:full_path error:nil] // // 5. Remove the font from fonts.json file // properties = Library.fetch.json("fonts.json",plugin) if ([properties isKindOfClass:[NSDictionary class]]) { dict = [[NSMutableDictionary alloc] initWithDictionary:properties] list = [[NSMutableDictionary alloc] initWithDictionary:[dict objectForKey:@"fonts"]] [list removeObjectForKey:@""+selected_font] dict[@"fonts"] = list } // 6. Write new data to fonts.json Library.create.file(dict,resources + "/fonts.json") // // 7. Remove the font commands from manifest.json // var manifestPath = directoryPlugin + "/manifest.json" var data = [NSData dataWithContentsOfFile:manifestPath] manifest = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil] // 9. Remove the command from manifest.json commands = [manifest objectForKey:@"commands"] for (i = 0; i < commands.length(); i++) { var item = commands[i] // if (selected_font == item.name) { if ([selected_font isEqualToString:@""+item.name]) { if (![commands removeObject:item]) { log('first remove command does not work') } menuid = item.identifier menu = [manifest objectForKey:@"menu"] items = [menu objectForKey:@"items"] first = [items objectAtIndex:0] if (![[first objectForKey:@"items"] removeObject:@""+menuid]) { log('second remove command does not work') } } } log([manifest objectForKey:@"commands"].length()) // manifest commands if ([manifest objectForKey:@"commands"].length() <= 6) { items = ["install","import"] menu = [manifest objectForKey:@"menu"] [menu setValue:items forKeyPath:@"items"]; } // 11. Write new data to manifest file Library.create.file(manifest,manifestPath) doc.showMessage(selected_font + " is deleted from the plugin.") }}; |
0 comments on commit
312d084