Limit annotations to badge type

This commit is contained in:
Nick O'Leary 2021-06-24 17:59:32 +01:00
parent 844bf29de1
commit 3255e11cfc
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 4 additions and 1 deletions

View File

@ -61,7 +61,7 @@ RED.view.annotations = (function() {
* @param {type} opts - annotations options * @param {type} opts - annotations options
* *
* opts: { * opts: {
* type: "badge"|"annotation" * type: "badge"
* class: "", * class: "",
* element: function(node), * element: function(node),
* show: string|function(node), * show: string|function(node),
@ -69,6 +69,9 @@ RED.view.annotations = (function() {
* } * }
*/ */
function register(id, opts) { function register(id, opts) {
if (opts.type !== 'badge') {
throw new Error("Unsupported annotation type: "+opts.type);
}
annotations[id] = opts annotations[id] = opts
RED.hooks.add("viewAddNode.annotation-"+id, function(evt) { RED.hooks.add("viewAddNode.annotation-"+id, function(evt) {
if (opts.filter && !opts.filter(evt.node)) { if (opts.filter && !opts.filter(evt.node)) {