Fix #plugin action not working in modern versions of Sketch#286
Open
rodionovd wants to merge 1 commit intodataliterate:masterfrom
Open
Fix #plugin action not working in modern versions of Sketch#286rodionovd wants to merge 1 commit intodataliterate:masterfrom
#plugin action not working in modern versions of Sketch#286rodionovd wants to merge 1 commit intodataliterate:masterfrom
Conversation
Author
|
Linking #220 |
rodionovd
commented
Feb 16, 2024
| // run the command | ||
| NSApp.delegate().runPluginCommand(command) | ||
| if (NSApp.delegate().runPluginCommand_fromMenu_context_) { | ||
| NSApp.delegate().runPluginCommand_fromMenu_context_(command, null, {}) |
Author
There was a problem hiding this comment.
In theory we might use the context argument here to pass the same command params as we do via userInfo, but it will suffer from the same serialization limitations, so I wouldn't bother.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Getting this action working again is key to unlock workflows like this one: https://forum.sketch.com/t/populate-color-from-json-file/2465
P.S. The official documentation lacks practical examples so here's how the
#pluginaction is supposed to be used:Let's say you have the following plugin installed that you want to invoke on one of your template layers based on some condition:

Let's also assume that you have the following template layer structure:

Now, to invoke the plugin on the Rectangle layer, rename the latter as follows:
Notes
Your
{condition}might be as simple as justtrue(e.g.#plugin[true, My Plugin > My Action]) if you want to always invoke the plugin no matter what's in your data. It may also reference other variables in your data: see examples.You may pass arguments to a plugin by including them in a layer name:
In order to access those arguments in your plugin, use the following:
As you can see, argument are passed to the plugin as an array of strings.