Contains constants and functions for a Annotation Object.
The structure for a Annotation Object is as follows:
{
payload: <object>,
type: <string>,
uuid: <string>,
}
- Source:
Members
(static, constant) group
A grouping for this object
- Source:
(static, constant) label
A label that can be used when describing this object
- Source:
(static, constant) parentDepth
Describes the number of parents this object has based off schema references. When checking for matches for example, we want to use a schema that is more specific over a more generic schema
- Source:
(static, constant) path :string
Paths for the keys on a Annotation Object
Properties:
Name | Type | Description |
---|---|---|
payload |
string |
An object with custom data describing the annotation. |
namespace |
string |
This is to scope annotations and prevent overwrites from other plugins. The type is usually deteremined by the plugin writing the annotation. |
uuid |
string |
Uniquely identifies each annotation. |
- Source:
(static, constant) publicKey :string
List of keys that are used in the public namespaces
Properties:
Name | Type | Description |
---|---|---|
hidden |
string |
Key that indicates if an event is hidden or not |
important |
string |
Key to toggle important events |
note |
string |
Key used for the main note in the note namespace |
- Source:
(static, constant) publicMatcher
List of matchers that can pull data from common annotations
- Source:
(static, constant) publicNamespace :string
List of namespaces that are available to all plugins
Properties:
Name | Type | Description |
---|---|---|
notes |
string |
Namespace for holding event notes |
visibility |
string |
Namespace for annotations that effect event visibility |
- Source:
Methods
(static) get(alias, data) → {*}
Retrieves a value from the object. You can provide either a path or an alias.
Parameters:
Name | Type | Description |
---|---|---|
alias |
string |
Path or alias |
data |
* |
Data to search |
- Source:
(static) getNamespace(source) → {string}
Returns the namespace
from the Annotation Object.
This is the this is to scope annotations and prevent overwrites from other plugins. The type is usually deteremined by the plugin writing the annotation.
Path is type
.
Parameters:
Name | Type | Description |
---|---|---|
source |
object |
The Annotation Object instance |
- Source:
(static) getPayload(source) → {object}
Returns the payload
from the Annotation Object.
This is the an object with custom data describing the annotation.
Path is payload
.
Parameters:
Name | Type | Description |
---|---|---|
source |
object |
The Annotation Object instance |
- Source:
(static) getPayloadKey(…path, source) → {*}
Returns the data using the specified path from the payload of the Annotation Object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
path |
string |
<repeatable> |
key in object |
source |
object |
The Annotation Object instance |
- Source:
(static) getUuid(source) → {string}
Returns the uuid
from the Annotation Object.
This is the uniquely identifies each annotation.
Path is uuid
.
Parameters:
Name | Type | Description |
---|---|---|
source |
object |
The Annotation Object instance |
- Source:
(static) make(…input) → {object}
Generates a Annotation Object with the const values set. Can be useful in testing. Can provide additional data by providing a flat object of paths and values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
input |
function |
<repeatable> |
Overrides |
- Source:
(static) makeNamespacePath(namespace, keyopt) → {string}
Returns a path using the provided namespace. If the optional key is provided, it will return that key from the payload.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
namespace |
string |
The namespace to reference |
|
key |
string |
<optional> |
Key inside payload |
Example
import { kit, event, annotation } from '@adobe/griffon-toolkit';
const isHidden = annotation.makeNamespacePath('visibility', 'hidden');
// isHidden is annotations[?type=='visibility'].payload.hidden
const hiddenEvent = event.mock({
annotations: [
annotation.mock({
[annotation.path.namespace]: 'visibility',
[annotation.path.payload]: { hidden: true }
})
]
});
console.log(kit.search(isHidden, hiddenEvent)); // [true]
- Source:
(static) mock(…input) → {object}
Generates a Annotation Object with some default values set. Can be useful in testing. Can override defaults and provide additional data by providing a flat object of paths and values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
input |
function |
<repeatable> |
Overrides |
- Source: