Skip to content

Commit

Permalink
Updating to fix symbol overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
seanriceaz committed Jul 28, 2017
1 parent 52e19bf commit 5f9e83d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Uses OSX's built-in spelling features and dictionary to do this.

## Change Log

### 1.3.0 Bug fix to support text within symbol overrides
### 1.2.2 Checking auto-updating functionality
### 1.2.1 Add auto-update support
### 1.2.0 Bug fix (removing a deprecated function) and adding scrolling text view
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Spell Check Whole Page",
"identifier": "com.tallwave.spellcheckwholepage",
"version": "1.2.2",
"version": "1.3.0",
"Appcast": "https://raw.githubusercontent.com/Tallwave/sketch-spellcheck-all-layers/master/appcast.xml",
"description": "Spell Check the entire page",
"authorEmail": "info@tallwave.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ function onRun(context) {
// Filter layers using NSPredicate
var scope = (typeof containerLayer !== 'undefined') ? [containerLayer children] : [[doc currentPage] children],
predicate = NSPredicate.predicateWithFormat("(className == %@)", "MSTextLayer"),
layers = [scope filteredArrayUsingPredicate:predicate];
symbolPredicate = NSPredicate.predicateWithFormat("(className == %@)", "MSSymbolInstance"),
layers = [scope filteredArrayUsingPredicate:predicate],
symbols = [scope filteredArrayUsingPredicate:symbolPredicate];

// Deselect current selection
//[[doc currentPage] deselectAllLayers]
Expand Down Expand Up @@ -49,36 +51,32 @@ function onRun(context) {
var madeAChange = false;
if(overrides){
var mutableOverrides = NSMutableDictionary.dictionaryWithDictionary(overrides);
for( var k = 0; k < mutableOverrides.count(); k++){
var thisOverride = NSMutableDictionary.dictionaryWithDictionary(mutableOverrides.objectForKey(k));
for( var l = 0; l< thisOverride.allKeys().count(); l++){
thisID = thisOverride.allKeys()[l];
if ( thisOverride[thisID].className().indexOf('String')>=0){
//WHERE THE MAGIC HAPPENS! WE'VE FOUND A STRING!
var spellingResult = spellcheckThis(thisOverride[thisID], context);
//Do text replacement if we updated anything
if (spellingResult.madeAChange){
madeAChange = true;
// Update the mutable dictionary -- Basically, these are temporary object copies that we can make changes to, then apply them over the actual "immutable" overrides
thisOverride.setObject_forKey(spellingResult.corrected,thisID);
mutableOverrides.setObject_forKey(thisOverride,k);
}
stopChecking = spellingResult.stopChecking;
misspellingcount = misspellingcount + spellingResult.misspellingcount;
if(stopChecking){
//If the user hits "Done", stop checking--set all the for variables to their exit conditions
j=instances.count();
k=mutableOverrides.count();
l=thisOverride.allKeys().count();
}
for( var l = 0; l< mutableOverrides.allKeys().count(); l++){
thisID = mutableOverrides.allKeys()[l];
if ( mutableOverrides[thisID].className().indexOf('String')>=0){
//WHERE THE MAGIC HAPPENS! WE'VE FOUND A STRING!
var spellingResult = spellcheckThis(mutableOverrides[thisID], context);
//Do text replacement if we updated anything
if (spellingResult.madeAChange){
madeAChange = true;
// Update the mutable dictionary -- Basically, these are temporary object copies that we can make changes to, then apply them over the actual "immutable" overrides
mutableOverrides.setObject_forKey(spellingResult.corrected,thisID);
}
stopChecking = spellingResult.stopChecking;
misspellingcount = misspellingcount + spellingResult.misspellingcount;
if(stopChecking){
//If the user hits "Done", stop checking--set all the for variables to their exit conditions
j=instances.count();
k=mutableOverrides.count();
l=mutableOverrides.allKeys().count();
}
}
}
}
// apply the overrides to the symbol instance
if (madeAChange){
// apply the overrides to the symbol instance
instances[j].applyOverrides_allSymbols_(mutableOverrides,false);
instances[j].overrides = mutableOverrides;
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
<link>http://sparkle-project.org/files/sparkletestcast.xml</link>
<description>Spell Check Whole Page Sketch Plugin</description>
<language>en</language>
<item>
<title>Version 1.3.0</title>
<description>
<![CDATA[
<ul>
<li>Fixing spellchecking on layer overrides</li>
</ul>
]]>
</description>
<pubDate>Thu, 27 Jul 2017 00:00:00 +0000</pubDate>
<enclosure url="https://github.com/tallwave/sketch-spellcheck-all-layers/archive/master.zip" sparkle:version="1.3.0" />
</item>
<item>
<title>Version 1.2.2</title>
<description>
Expand All @@ -14,6 +26,7 @@
</ul>
]]>
</description>
<pubDate>Thu, 20 Jul 2017 00:00:00 +0000</pubDate>
<enclosure url="https://github.com/Tallwave/sketch-spellcheck-all-layers/archive/v1.2.2.zip" sparkle:version="1.2.2" />
</item>
<item>
Expand All @@ -25,6 +38,7 @@
</ul>
]]>
</description>
<pubDate>Thu, 13 Jul 2017 00:00:00 +0000</pubDate>
<enclosure url="https://github.com/Tallwave/sketch-spellcheck-all-layers/archive/v1.2.1.zip" sparkle:version="1.2.1" />
</item>

Expand Down

0 comments on commit 5f9e83d

Please sign in to comment.