使用Sketch Plugin API,有没有一种方法可以在文档首次打开时强制该文档中的所有图层检查其尺寸(...并更新)?令我惊讶的是,Sketch似乎默认不执行此操作。
参考Action API,我尝试按照以下示例操作以在文档打开时触发某些操作,但是我什么都没看到。
使用skpm创建一个插件,该插件一旦更新,将如下所示:
manifest.json
{
"compatibleVersion": 3,
"bundleVersion": 1,
"icon": "icon.png",
"commands": [
{
"script" : "my-action-listener.js",
"name" : "My Action Listener",
"handlers" : {
"actions": {
"OpenDocument": "onOpenDocument"
}
},
"identifier" : "my-action-listener-identifier"
}]
}
my-action-listener.js
export function onOpenDocument(context) {
context.actionContext.document.showMessage('Document Opened')
//refresh all of the layers here
}