Skip to content

Commit

Permalink
Use sketchObject properties for name and frame to fix problem with no…
Browse files Browse the repository at this point in the history
… mapped wrapper for MSSymbolInstance
  • Loading branch information
perrysmotors committed May 10, 2017
1 parent 0a29af5 commit 6c5414f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions CopyFramerCode.sketchplugin/Contents/Sketch/copy-framer-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function onRun(context) {
if (selection.isEmpty) {
sketch.message("Select one or more layers to copy");
return false;
} else {
sketch.message("Copying @ " + scale + "x");
}

selection.iterate(function(layer) {
Expand All @@ -40,7 +38,12 @@ function onRun(context) {
clipboardText = clipboardText + framerLayerProperties(framerLayers[i]) + '\n';
}

clipboard.set(clipboardText);
if (clipboardText != "") {
sketch.message("Copying @ " + scale + "x");
clipboard.set(clipboardText);
} else {
sketch.message("Fail :(");
}

}

Expand All @@ -56,7 +59,7 @@ var processLayerRecursively = function(layer, parent) {

framerObject.layerType = "Layer";

var name = camelize(layer.name);
var name = camelize(sketchObject.name());
name = uniqueLayerName(name);
framerObject.name = name;

Expand All @@ -69,11 +72,11 @@ var processLayerRecursively = function(layer, parent) {
framerObject.y = sketchObject.absoluteRect().rulerY() * scale;
} else {
framerObject.parent = parent;
framerObject.x = layer.frame.x * scale;
framerObject.y = layer.frame.y * scale;
framerObject.x = sketchObject.frame().x() * scale;
framerObject.y = sketchObject.frame().y() * scale;
}

var isFlattenedGroup = (layer.name.slice(-1) == "*");
var isFlattenedGroup = (sketchObject.name().slice(-1) == "*");

if (layer.isGroup) {
if (isFlattenedGroup) {
Expand Down
2 changes: 1 addition & 1 deletion CopyFramerCode.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "Copy Framer Code",
"identifier" : "com.gilesperry.copy-framer-code",
"version" : "2.0",
"version" : "2.0.1",
"compatibleVersion": 44,
"description" : "Copy layers to the clipboard as Framer code.",
"homepage": "https://github.com/perrysmotors/copy-framer-code",
Expand Down

0 comments on commit 6c5414f

Please sign in to comment.