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.
This PR introduces a new api that can be used to add custom annotations to nodes.
This initial implementation provides support for one type of annotation - 'badges'.
Badges are ~10px square icons shown in the top-right corner of the node. The existing node-changed (blue dot) and node-warning (orange triangle) indicators have been reimplemented using this new API.
The flow debugger will use this api to add a badge to indicate if a node is currently paused or not.
The flow linter will use this api to highlight nodes that have linter errors.
This is how the node-changed badge is defined:
RED.view.annotations.register
is called with two args - a string identifier for the annocation and an options object.In the options object, the following properties can be provided:
type
- the type of annotation. Currentlybadge
is the only supported typeclass
- a css class name to apply to the annotationelement
- a function this is called to generate the annotation for the provided node. It should return an SVG element.show
- used whenever the node is redrawn to determine if the badge should be shown. If set to a string, this is expected to be the name of a node property that will used as a boolean to determine the badge visibility. If set to a function, it will be called (with the node instance passed in) and expected to return a boolean.filter
- a function this is called to determine if the annotation should be added to the provided node.RED.view.annotations.unregister
is also defined to remove the annotation. It is passed theid
that was passed to theregister
call.