An interface for retrieving and managing tags.
Hooks provide access to tags from inside React components. Unlike resources accessed using static methods, hooks will cause the component to rerender when the data changes.
Returns a { [id]: Tag }
map of tags matching the provided IDs.
useTags ( ids: string [ ] ) : Record< string , Tag>
Argument Type Description ids
string[]
The IDs of the tags to retrieve.
Retrieves tags by ID. If provided a single ID string, returns the tag or null
if not found. If provided an array of IDs, returns an array of the corresponding tags.
Tags. get ( id: string | string [ ] ) : Tag | Tag[ ] | null
Argument Type Description tagId*
string | string[]
The ID(s) of the tag(s) to retrieve.
Creates a new tag and dispatches a tags:create
event. Returns the new tag.
Tags. create ( core: Core, data: CreateTagData) : Tag
Property Type Description data
CreateTagData
The tag data, of which label
is the only required value. See below for details.
CreateTagData
Property Type Description label*
string
The tag's label text. color
ContentColor
The tag's color. The default color is 'blue'
. See the Color page for available content colors.
Updates a tag and dispatches a tags:update
event. Returns the updated tag.
Tags. update ( core: Core, tagId: string , data: UpdateTagData) : Tag
Argument Type Description core*
Core
A MindDrop core instance. tagId*
string
The ID of the tag to update. data*
UpdateTagData
The changes to apply to the tag. See below for details.
UpdateTagData
Property Type Description label
string
The tag's label text. color
ContentColor
The tag's color. See the Color page for available content colors.
Deletes a tag and dispatches a tags:delete
event.
Tags. delete ( core: Core, tagId: string ) : void
Argument Type Description core*
Core
A MindDrop core instance. tagId*
string
The ID of the tag to delete.
Loads tags into the store and dispatches a tags:load
event.
Tags. load ( core: Core, tags: Tag[ ] ) : void
Argument Type Description core*
Core
A MindDrop core instance. tags*
Tag[]
The tags to load into the store.
Adds tag specific event listeners. Equivalent to calling addEventListener
directly on core
, but provides more advanced type definitions.
Tags. addEventListener ( core: Core, event: TagEvent, callback: EventListenerCallback) : void
Argument Type Description core*
Core
A MindDrop core instance. event*
TagEvent
The event type to listen for. See the tag events section below for available events. callback*
EventListenerCallback
The callback fired when the event occurs. See the tag events section below for the data passed to the callback.
Removes tag specific event listeners. Equivalent to calling removeEventListener
directly on core
, but provides more advanced type definitions.
Tags. removeEventListener ( core: Core, event: TagEvent, callback: EventListenerCallback) : void
Argument Type Description core*
Core
A MindDrop core instance. event*
TagEvent
The event type for which to remove the event listener. callback*
EventListenerCallback
The callback of the event listener to remove.
Name Data Description tags:create
Tag
Dispatched when a tag is created. tags:update
UpdateTagEventData
Dispatched when a tag is updated. tags:delete
Tag
Dispatched when a tag is deleted. tags:load
Tag[]
Dispatched when tags are loaded into the store.
UpdateTagEventData
Property Type Description before*
Tag
Tag data before it was changed. after*
Tag
Updated tag data. changes*
TagChanges
The changes made to the tag. See below for details.
TagChanges
Property Type Description type
string
The drop type. Determines which component will be used to render it. color
ContentColor
The tag's color. See the Color page for available content colors.