manovotny that's currently not possible, neither with the Action API nor with any other system.
What format would you like to add?
ale, I was looking to add a .js format, along with a plugin, that would wrap the SVG in some code.
Quick update: I just uploaded this sample plugin, might be useful if you're working with the Action API: https://github.com/bomberstudios/sketch-action-api-tester
Anyone knows if there a (hidden) "rename layer" action?
FrancisVega noted, thanks for the request
Just throwing in my vote for some additional actions around symbols, e.g. SymbolOverrideChanged
romannurik good one, will add a note for that too
romannurik just ran into this again... Would be really useful for anyone building a design system on Sketch :-)
romannurik This event would be really helpful. I don't want to complicated my plugin by Sizzling methods. Seems like that is the only option so far.
Any other easy alternatives? @ale
ale Any update on this?
ale I think it'd be useful for the DocumentSaved action to also return a reference to the document in its actionContext. That way we could add custom "post-save hook" behaviors which reference data from the document.
jpencola I agree, and IIRC, we've added that in v43, which is currently in beta.
Why is actions scoped to a per-command level?
matt_sven not sure I'm following, can you elaborate?
ale Actions are at the commands[index].handlers.actions level... but I get it now, I think - it allows for different functions to be called from different scripts.
ale I can't seem to get any of the actions around layer property changes to be called. Any thoughts on why that may be. I've tested with a wildcard * handler and also specific actions like AddShadow but they don't seem to show up in the wildcard or be called explicitly.
WCByrne I'll investigate
WCByrne ok, found the issue. Apparently, the actions are not triggered when using the Inspector, but they are when you use the menus, toolbar buttons or keyboard shortcuts.
That's definitely a bug, and we'll fix that as soon as possible.
ale Thanks for looking into that. It was a bit difficult to discover the actions with incomplete documentation and them not firing as expected.
That said, while I wait, is there any action that will fire when anything about a layer changes?
ale Action request: it would be really useful to have a "ParentChanged" and "SiblingChanged" actions available. I'm working on a couple of plugins that would be greatly simplified (and optimised) if those actions existed...
Seems like SelectionChanged can sometimes be unreliable... testing by quickly selecting between two different layers. The context.actionContext.newSelection sometimes returns an empty array, whereas context.actionContext.document.selectedLayers().layers() returns the correct, actual selection.
Thanks for explaining it Ale.
I have some questions about InsertImage action:
InsertImage actionContext has only action and document properties. Any plans to add to the context any information about inserted image? Actually I'm looking for file URL of the original image, but at least ID of a new MSBitmapLayer might be helpful too.
Seems there is a thing with InsertImage.finish action. I expected that InsertImage.begin is for a time when a user just hit Insert Image menu option and that InsertImage.finish is for a time when selected image inserted. But seems InsertImage.finish happened just after InsertImage.begin. For example, if I hit Insert -> Image -> Cancel, I still get both actions at the console. Could you please check timing?
As I can see for now the action is only for inserting images via Insert -> Image menu. What about drug-and-drop inserted images?