Skip to content

Commit

Permalink
v2.5
Browse files Browse the repository at this point in the history
1. Export layer influence rect
2. Emoji support
3. CSS Rem 16px
  • Loading branch information
utom committed Mar 9, 2017
1 parent a4f64b8 commit 4e38569
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 48 deletions.
2 changes: 1 addition & 1 deletion HOW-TO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Installing Plugins

1. [Download the ZIP file with the Measure](https://github.com/forestlin1212/sketch-measure/archive/master.zip) and unzip;
1. [Download the ZIP file with the Measure](https://github.com/utom/sketch-measure/archive/master.zip) and unzip;
2. Open the `Sketch Measure.sketchplugin`;


Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Layer's influence rect includes the area of shadows and outside borders, it's exactly the same size with the exported image.

                                      Regular rect                                                         Influence rect

![regular-rect](https://pic4.zhimg.com/v2-c1792b8300fca0cdc90b564a27b8da8b_b.png)
![influence-rect](https://pic3.zhimg.com/v2-a639e906f8fea576da8d9a8cc1cc752a_b.png)

Expand All @@ -23,7 +23,7 @@ Make it fun to create specs for developers and teammates. **Sketch 41.* support*
![Logo](http://utom.design/logo@2x.png)

## Installing Plugins
1. [Download the ZIP file](https://github.com/forestlin1212/sketch-measure/archive/master.zip) and unzip
1. [Download the ZIP file](https://github.com/utom/sketch-measure/archive/master.zip) and unzip
2. Open `Sketch Measure.sketchplugin`

## New UI
Expand All @@ -50,7 +50,9 @@ To create your own custom shortcuts, go to Keyboard in your System Preferences a

##Contributors
* Author [@utom](http://utom.design)
* [@cute](http://liguangming.com) ([SketchI18N](https://github.com/cute/SketchI18N)) and [@esseak](https://github.com/esseak)
* [@cute](http://liguangming.com) ([SketchI18N](https://github.com/cute/SketchI18N))
* [@forestlin1212](https://github.com/forestlin1212)
* [@ashung](https://github.com/Ashung) ([Automate-Sketch](https://github.com/Ashung/Automate-Sketch))
* [@mkl87](https://github.com/mkl87), [@Skykai521](https://github.com/Skykai521), [@whyfind](https://github.com/whyfind) and [@Nora](https://www.behance.net/liyinuo)
* @Kai and [@Zih-Hong](http://zihhonglin.com)
* And [Other](https://github.com/utom/sketch-measure/contributors)
Expand Down
57 changes: 21 additions & 36 deletions Sketch Measure.sketchplugin/Contents/Sketch/library/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,19 @@ SM.extend({
// return str.replace(/\&/g, "&amp;").replace(/\"/g, "&quot;").replace(/\'/g, "&#39;").replace(/\</g, "&lt;").replace(/\>/g, '&gt;');
},
emojiToEntities: function(str) {
var emojiRanges = [
"\ud83c[\udf00-\udfff]", // U+1F300 to U+1F3FF
"\ud83d[\udc00-\ude4f]", // U+1F400 to U+1F64F
"\ud83d[\ude80-\udeff]" // U+1F680 to U+1F6FF
];
var self = this,
emojiRegExp = new RegExp("(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])", "g");
return str.replace(
new RegExp(emojiRanges.join("|"), "g"),
emojiRegExp,
function(match) {
var c = encodeURIComponent(match).split("%"),
h = ((parseInt(c[1], 16) & 0x0F))
+ ((parseInt(c[2], 16) & 0x1F) << 12)
+ ((parseInt(c[3], 16) & 0x3F) << 6)
+ (parseInt(c[4], 16) & 0x3F);
return "&#" + h.toString() + ";";
var u = "";
for (var i = 0; i < match.length; i++) {
if( !(i%2) ){
u += "&#" + match.codePointAt(i)
}
}

return u;
});
},
toSlug: function(str){
Expand Down Expand Up @@ -2327,31 +2326,18 @@ SM.extend({
var layer = this.selection[i],
slice = layer;

if(optionKey && !this.is(layer, MSSliceLayer)){
if(!optionKey && !this.is(layer, MSSliceLayer)){
slice = MSSliceLayer.sliceLayerFromLayer(layer);

var layerRect = this.getRect(layer),
sliceRect = this.getRect(slice);
var msRect = MSRect.rectWithUnionOfRects([
MSRect.alloc().initWithRect(slice.absoluteRect().rect()),
MSRect.alloc().initWithRect(layer.absoluteRect().rect())
]);

if(layerRect.width > sliceRect.width){
sliceRect.setX(layerRect.x);
sliceRect.setWidth(layerRect.width);
}

if(layerRect.height > sliceRect.height){
sliceRect.setY(layerRect.y);
sliceRect.setHeight(layerRect.height);
}
slice.absoluteRect().setRect(msRect.rect());

if(this.is(layer, MSLayerGroup)){
var sliceCopy = slice.copy();
layer.addLayers([sliceCopy]);

var sliceCopyRect = this.getRect(sliceCopy);
sliceCopyRect.setX(sliceRect.x);
sliceCopyRect.setY(sliceRect.y);
this.removeLayer(slice);
slice = sliceCopy;
slice.moveToLayer_beforeLayer(layer, layer.firstLayer());
slice.exportOptions().setLayerOptions(2);
}
}
Expand All @@ -2362,7 +2348,7 @@ SM.extend({
size.setName("");
size.setScale(1);

if(!optionKey || this.is(layer, MSSliceLayer)){
if(optionKey || this.is(layer, MSSliceLayer)){
layer.setIsSelected(0);
layer.setIsSelected(1);
}
Expand Down Expand Up @@ -2835,7 +2821,7 @@ SM.extend({
return this.SMPanel({
url: this.pluginSketch + "/panel/export.html",
width: 320,
height: 577,
height: 597,
data: data,
callback: function( data ){
var allData = self.allData;
Expand Down Expand Up @@ -3132,7 +3118,6 @@ SM.extend({
} // fixed for v40

var exportLayerRect;
log(this.configs);
if(this.configs.exportInfluenceRect == true && layerType != "text"){
// export the influence rect.(include the area of shadows and outside borders...)
var influenceCGRect = layer.absoluteInfluenceRect();
Expand All @@ -3147,7 +3132,7 @@ SM.extend({
// export the default rect.
exportLayerRect = layer.absoluteRect();
}

var layerData = {
objectID: this.toJSString( layer.objectID() ),
type: layerType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
"identifier": "com.utom.measure",
"homepage": "http://utom.design/measure/",
"version": "2.4.2",
"version": "2.5",
"description" : "Make it a fun to create spec for developers and teammates",
"authorEmail" : "utombox@gmail.com",
"name" : "Sketch Measure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
},
"identifier": "com.utom.measure",
"homepage": "http://utom.design/measure/",
"version": "2.4.2",
"version": "2.5",
"description" : "Make it a fun to create spec for developers and teammates",
"authorEmail" : "utombox@gmail.com",
"name" : "Sketch Measure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
},
"identifier": "com.utom.measure",
"homepage": "http://utom.design/measure/",
"version": "2.4.2",
"version": "2.5",
"description" : "Make it a fun to create spec for developers and teammates",
"authorEmail" : "utombox@gmail.com",
"name" : "Sketch Measure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
},
checkedOption = function(){
if($('input[name=export-option]:checked').length > 0){
$('input[name=order]').attr('disabled', false);
$('input[name=order]').attr('disabled', false);
}
else{
$('input[name=order]').attr('disabled', true);
Expand Down Expand Up @@ -247,7 +247,7 @@
'</label>',
'</div>',
//export influence rect option
'<div class="item">',
'<div class="item" style="margin-top:10px;">',
'<label>',
'<div class="checkbox">',
'<input id="export-influenceRect" type="checkbox" name="export-influenceRect" value="0">',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if($('#' + id).length <= 0) return 'custom';

return id;

},
getScaleWidthUnit = function( id ){
if (id == 'custom') return false;
Expand Down Expand Up @@ -75,6 +75,7 @@
'<li class="sub-title">' + _('Web View') + '</li>',
'<li><label id="rem-12"><input type="radio" name="resolution-type" value="rem-12"><span>' + _('CSS Rem') + ' 12px</span></label></li>',
'<li><label id="rem-14"><input type="radio" name="resolution-type" value="rem-14"><span>' + _('CSS Rem') + ' 14px</span></label></li>',
'<li><label id="rem-16"><input type="radio" name="resolution-type" value="rem-16"><span>' + _('CSS Rem') + ' 16px</span></label></li>',
'</ul>',
'</div>',
'</div>',
Expand Down Expand Up @@ -119,7 +120,7 @@
if(!scaleWidthUnit) return false;
$('input[name=scale]').val(scaleWidthUnit.scale);
$('input[name=unit]').val(scaleWidthUnit.unit);
});
});

checkResolution(id);
$('#' + data.colorFormat).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@
name: 'CSS Rem 14px',
unit: 'rem',
scale: 14
},
{
name: 'CSS Rem 16px',
unit: 'rem',
scale: 16
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion Sketch Measure.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
"identifier": "com.utom.measure",
"homepage": "http://utom.design/measure/",
"version": "2.4.2",
"version": "2.5",
"description" : "Make it a fun to create spec for developers and teammates",
"authorEmail" : "utombox@gmail.com",
"name" : "Sketch Measure"
Expand Down

0 comments on commit 4e38569

Please sign in to comment.