Hi, pretty new to sketch plugins. I'm trying to create a new text layer according to the Sketch Developer API, but can't seem to get it to work.
Everything works until my UI message "Program gets here", but doesn't work after that.
Here's my code:
var sketch = require('sketch')
// documentation: https://developer.sketchapp.com/reference/api/
// var sketch = context.api()
const doc = sketch.getSelectedDocument()
export default function() {
const selection = doc.selectedLayers
selection.forEach((selected) => {
var artboardName = selected.name
var artboardWidth = selected.width
// sketch.UI.message("Program gets here")
var newText = new Text({
text: 'artboardName',
alignment: Text.Alignment.center
// parent: selected[0].getParentArtboard(),
// frame: {x: 10, y: 10, width: 200, height: 90}
})
sketch.UI.message("Doesn't get here")
})
}
Thanks for the help!