Skip to content

Commit d397384

Browse files
committed
Find and replace in Master Symbol (selection mode only).
1 parent aa91b94 commit d397384

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

Find And Replace.sketchplugin/Contents/Sketch/FindAndReplace.sketchscript

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
var FindAndReplace = function (context) {
1010

1111
var presets, userDefaults, document, selection, textToFind, textToReplace, searchScope, matchRegex, matchRegexStart, matchRegexEnd, matchRegexCase, REPLACE_ALL, READY_TO_SEARCH, CANCELLED, NOT_READY, itemsMatched;
12-
var version = '1.19';
12+
var version = '1.20';
1313

1414
// Initialise
1515
initialise(context);
@@ -268,18 +268,19 @@ var FindAndReplace = function (context) {
268268

269269
case 0:
270270
// Start at the document root
271-
searchInLayer(document);
271+
searchInLayer(document, false);
272272
break;
273273

274274
case 1:
275275
// Search in the current page only
276-
searchInLayer(currentPage);
276+
log(currentPage.name);
277+
searchInLayer(currentPage, false);
277278
break;
278279

279280
case 2:
280281
// Loop through all the selected layers
281282
for (var i = 0; i < [selection count]; i++) {
282-
searchInLayer(selection[i]);
283+
searchInLayer(selection[i], true);
283284
}
284285
break;
285286

@@ -349,9 +350,10 @@ var FindAndReplace = function (context) {
349350

350351
// Do the actual search within the specified layer. Recursive to drill down into sublayers.
351352

352-
function searchInLayer(layer) {
353+
function searchInLayer(layer, inSymbolMaster) {
353354

354355
// Determine the type of layer we're looking at
356+
log([layer class]);
355357

356358
switch ([layer class]) {
357359

@@ -370,7 +372,7 @@ var FindAndReplace = function (context) {
370372
var documentPages = [layer pages];
371373
for (var i = 0; i < [documentPages count]; i++) {
372374
var documentPage = [documentPages objectAtIndex:i];
373-
searchInLayer(documentPage);
375+
searchInLayer(documentPage, false);
374376
}
375377
break;
376378

@@ -381,10 +383,19 @@ var FindAndReplace = function (context) {
381383
var sublayers = [layer layers];
382384
for (var i = 0; i < [sublayers count]; i++) {
383385
var sublayer = [sublayers objectAtIndex: i];
384-
searchInLayer(sublayer);
386+
searchInLayer(sublayer, false);
385387
}
386388
break;
387389

390+
case MSSymbolMaster:
391+
if (inSymbolMaster != true) break;
392+
var sublayers = [layer layers];
393+
for (var i = 0; i < [sublayers count]; i++) {
394+
var sublayer = [sublayers objectAtIndex: i];
395+
searchInLayer(sublayer, inSymbolMaster);
396+
}
397+
break;
398+
388399
case MSSymbolInstance:
389400
searchInSymbols(layer);
390401
break;

Find And Replace.sketchplugin/Contents/Sketch/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "Martin Steven and Thierry Charbonnel",
55
"authorEmail" : "thierry.charbonnel@autreplanete.com",
66
"homepage": "https://github.com/thierryc/Sketch-Find-And-Replace/",
7-
"version": "1.19",
7+
"version": "1.20",
88
"identifier": "cx.ap.sketch-find-and-replace",
99
"icon" : "runner-icon.png",
1010
"updateURL": "https://raw.githubusercontent.com/thierryc/Sketch-Find-And-Replace/master/Find%20And%20Replace.sketchplugin/Contents/Sketch/manifest.json",

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Finds text in selected layer(s) and all layers contained within - and replaces i
66

77
Now works with symbol overrides. 🎉
88

9-
Ready for Sketch 47.
9+
Ready for Sketch 48, 47, 46.
10+
11+
New in 1.20: Find and replace in Master Symbol (selection mode only).
1012

1113
![Find and Replace dialog](./Screenshots/screenshot.png)
1214

appcast.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
<link>https://raw.githubusercontent.com/thierryc/Sketch-Find-And-Replace/master/appcast.xml</link>
66
<description>Finds text in selected layer(s) and all layers contained within - and replaces it with different text. Features partial, case sensitive and full-document matching.</description>
77
<language>en</language>
8+
<item>
9+
<title>1.20</title>
10+
<description>
11+
<![CDATA[
12+
<ul>
13+
<li>Improve find and replace in symbol.</li>
14+
</ul>
15+
]]>
16+
</description>
17+
<pubDate>Tue Jan 8 11:30:00 EDT 2018</pubDate>
18+
<enclosure url="https://github.com/thierryc/Sketch-Find-And-Replace/archive/1.20.zip" type="application/octet-stream" sparkle:version="1.20"/>
19+
</item>
820
<item>
921
<title>1.19</title>
1022
<description>

0 commit comments

Comments
 (0)