Skip to content

Commit

Permalink
cleaned up code. switched alert to UI message.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewfiorillo committed Nov 7, 2018
1 parent 800c6cf commit e8bd124
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Character Count.sketchplugin/Contents/Sketch/count.js
@@ -1,19 +1,17 @@
var UI = require('sketch/ui')

function count(context) {

var app = NSApplication.sharedApplication(),
text = context.selection.firstObject(),
count;
var count, text = context.selection.firstObject()

if (!text || text.class() != "MSTextLayer") {
app.displayDialog("Select a text layer!");
return;
UI.message("Select a text layer!"); return
} else if (text.isEditingText()) {
count = text.editingDelegate().textView().selectedRange().length;
count = text.editingDelegate().textView().selectedRange().length
} else {
count = text.stringValue().length();
count = text.stringValue().length()
}

app.displayDialog(count);
UI.message(`✏️ Character Count: ${count}`)

}

0 comments on commit e8bd124

Please sign in to comment.