Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed behavior so now symbol instances are renamed to the last portion of a symbol master name after the "/" #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ To find your plugins directory...

# Changelog

* **2.4.1** - Now all instances of symbol(s) are renamed to last to portion after last '/'.
* **2.4** - Added new function to rename all instances of selected symbol(s).
* **2.3** - Added new function to rename all instances on all pages, except Symbols page. Added fix for when the master for an instance is missing.
* **2.2** - Added appcast plugin support for Sketch 45 and later. Added new function to rename all instances on current page. New shortcuts.
Expand Down
13 changes: 11 additions & 2 deletions Symbol Instance Renamer.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"icon" : "icon-sr.png",
"handler" : "renamePages"
},
{
"name" : "Rename All Instances of Selected Symbol(s) to Portion After Last '/'",
"shortcut" : "cmd option shift k",
"identifier" : "renamePages",
"description" : "Rename All Instances of Selected Symbol(s) to Portion After Last '/'",
"script" : "script.cocoascript",
"icon" : "icon-sr.png",
"handler" : "renameLastSlashPages"
},
{
"name" : "Rename All Instances on All Pages (Except Symbols Page)",
"shortcut" : "cmd option shift x",
Expand Down Expand Up @@ -58,8 +67,8 @@
]
},
"identifier" : "com.sonburn.sketchplugins.symbol-instance-renamer",
"version" : "2.4",
"description" : "Rename symbol instances to the name of their master.",
"version" : "2.4.1",
"description" : "Rename symbol instances to the name of their master (Last portion after "/").",
"authorEmail" : "[email protected]",
"name" : "Symbol Instance Renamer",
"appcast" : "https://raw.githubusercontent.com/sonburn/symbol-instance-renamer/master/appcast.xml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ var renamePages = function(context) {
context.document.showMessage(count + strRenameSuccess);
}

var renameLastSlashPages = function(context) {
var pages = context.document.pages(),
loop = pages.objectEnumerator(),
page,
count = 0;

while (page = loop.nextObject()) {
count = count + renameInstancesOnPage(page);
}

context.document.showMessage(count + strRenameSuccess);
}

var renamePagesExceptSymbols = function(context) {
var pages = context.document.pages(),
loop = pages.objectEnumerator(),
Expand Down Expand Up @@ -94,8 +107,11 @@ function renameInstancesOnPage(page) {
}

function renameInstance(instance) {
if (instance.name() != instance.symbolMaster().name().trim()) {
instance.setName(instance.symbolMaster().name());
var str = instance.symbolMaster().name().trim();
var str_array = str.split("/");
var simple_name = str_array[str_array.length - 1];
if (instance.name() != simple_name.trim()) {
instance.setName(simple_name);
return true;
} else return false;
}
4 changes: 2 additions & 2 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<description>Rename all symbol instances to the name of their master.</description>
<language>en</language>
<item>
<title>Version 2.4</title>
<title>Version 2.4.1</title>
<description>
<![CDATA[
<ul>
<li>Added new function to rename all instances of selected symbol(s).</li>
<li>Added new function to rename all instances of selected symbol(s) to portion after last '/'.</li>
</ul>
]]>
</description>
Expand Down