/* * Sample plugin code for Adobe XD. * * Visit http://adobexdplatform.com/ for API docs and more sample code. */ var {Rectangle, Color} = require("scenegraph"); function createRectangle(selection) { var textNode = selection.items[0]; var bounds = textNode.boundsInParent; console.log(bounds); const padding = 10; var shape = new Rectangle(); shape.width = bounds.width + 2*padding; shape.height = bounds.height + 2*padding; shape.stroke = new Color("blue"); selection.insertionParent.addChild(shape); shape.placeInParentCoordinates( {x: 0, y: 0}, {x: bounds.x - padding, y: bounds.y - padding} ); } module.exports = { commands: { myPluginCommand: createRectangle } };