Sketch MeaXure Plugin breaked in v 97.2

Hey Sketch guys. For security reasons we are using offline handoff plugin Sketch MeaXure. Which is our only option is breaked in v97.2. Some functions gives an error like below.

We would be very grateful if anyone can update the plugin or help in this regard.

Hi Yunus,

I assume that you have to write to the developer of the plugin.

Indeed, we can’t help with this unfortunately. I will move this topic to the Ask the Community section in case the plugin developer visits the forum.

1 Like

I did a quick research about this error and it seems to be actually coming from the official Sketch JS API rather than the plugin itself.

Pretty easy to reproduce too – run the following commands in the Plugins > Run Script panel:

var sketch = require('sketch/dom')

let style = new sketch.Style()
// now try to assign any text-specific attributes
style.alignment = sketch.Text.Alignment.center;
🤖 A bunch of technical details for developers

The culprit is that most Style class setters are using the following code to re-create an underlying native text style if it doesn’t exists yet in the current style instance:

  let textStyle = _object.textStyle()

  if (!textStyle) {
    textStyle = MSTextStyle.styleWithAttributes(
      MSDefaultTextStyle.defaultTextStyle()
    )
    [...]
  }

(SketchAPI/Source/dom/style/Text.js:58)

and MSTextStyle.styleWithAttributes(...) doesn’t exist anymore since Sketch 97.

A workaround (for plugin developers, that is) is to specify a target layer type when creating Style objects. For instance, in the sample code above:

var sketch = require('sketch/dom')

-let style = new sketch.Style()
+let style = new sketch.Style({}, sketch.Types.Text);
style.alignment = sketch.Text.Alignment.center;

Now, @yeb would you please try the fixed version of the plugin? I’ve applied the aforementioned workaround and also fixed a few other compatibility issues with modern Sketch versions (around Spec Export > Export layer influence rect option, altough I don’t fully understand what the output of this should be, so let me know).

@jonne given that it seems to be a bug in the official Sketch JS API, it makes sense to file a bug report for the dev team. I usually email productsupport@, but I I guess this post would do?

2 Likes

This post will do. I’ll check with the plugin folks internally. Thanks for sharing @rodionovd !

2 Likes

Wow, thank you for your swift reply. All of the features of the plugin work wonderfully. As a team we are grateful for your help. :metal:

1 Like

I’m happy to help! In case you want to build the Sketch 97-compatible version of the plugin yourself, feel free to grab the patched source code from my fork of sketch-meaxure: GitHub - rodionovd/sketch-meaxure at sketch97

1 Like

Hello :wave:

We released a fix in the 98 beta yesterday. Feel free to try it out and let us know if there are any questions!

3 Likes