ContentState.js
API
Classes
- ContentStateError
-
This is the custom Error class we're assuming we'll throw on parse errors.
Functions
-
expandAnnotation(annotation) ⇒
Object
-
Given a contentState annotation, add back in the context if it's missing. Given a mimimal target-only contentState, assume that it's a target and wrap it in the annotation.
- validateAnnotation(annotation)
-
Given an annotation, confirm that it has the correct context and that it has a target property. Will throw errors if it is not.
-
isContentStateAnnotation(annotation) ⇒
Boolean
-
Inspect the motivation of an annotation and see if it contains the "contentState" motivation.
-
encodeLink(url, annotation) ⇒
string
-
Helper function to create a full link that includes the annotation param.
-
parseURL(url) ⇒
Object
-
Extract the annotation information from a full URL
Object
expandAnnotation(annotation) ⇒ Given a contentState annotation, add back in the context if it's missing. Given a mimimal target-only contentState, assume that it's a target and wrap it in the annotation.
Kind: global function
Returns: Object
- the annotation with any transformations applied
Param | Type | Description |
---|---|---|
annotation | Object |
the annotation to expand |
validateAnnotation(annotation)
Given an annotation, confirm that it has the correct context and that it has a target property. Will throw errors if it is not.
Kind: global function
Param | Type | Description |
---|---|---|
annotation | Object |
the annotation to expand |
Boolean
isContentStateAnnotation(annotation) ⇒ Inspect the motivation of an annotation and see if it contains the "contentState" motivation.
Kind: global function
Returns: Boolean
- true if it's a contentState Annotation, false if not.
Param | Type | Description |
---|---|---|
annotation | Object |
the annotation to inspect |
string
encodeLink(url, annotation) ⇒ Helper function to create a full link that includes the annotation param.
Kind: global function
Returns: string
- The augmented URL
Param | Type | Description |
---|---|---|
url | string |
The URL that should have a contentState param added. |
annotation | Object |
The annotation Object |
Object
parseURL(url) ⇒ Extract the annotation information from a full URL
Kind: global function
Returns: Object
- The annotation data and manifest value
Param | Type | Description |
---|---|---|
url | String |
The URL to parse |