Tags

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>
ArgumentTypeDescription
idsstring[]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
ArgumentTypeDescription
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
PropertyTypeDescription
dataCreateTagData The tag data, of which label is the only required value. See below for details.

CreateTagData

PropertyTypeDescription
label*stringThe tag's label text.
colorContentColor 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
ArgumentTypeDescription
core*CoreA MindDrop core instance.
tagId*stringThe ID of the tag to update.
data*UpdateTagDataThe changes to apply to the tag. See below for details.

UpdateTagData

PropertyTypeDescription
labelstringThe tag's label text.
colorContentColor 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
ArgumentTypeDescription
core*CoreA MindDrop core instance.
tagId*stringThe ID of the tag to delete.

Loads tags into the store and dispatches a tags:load event.

Tags.load(core: Core, tags: Tag[]): void
ArgumentTypeDescription
core*CoreA 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
ArgumentTypeDescription
core*CoreA MindDrop core instance.
event*TagEventThe event type to listen for. See the tag events section below for available events.
callback*EventListenerCallbackThe 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
ArgumentTypeDescription
core*CoreA MindDrop core instance.
event*TagEventThe event type for which to remove the event listener.
callback*EventListenerCallbackThe callback of the event listener to remove.
NameDataDescription
tags:createTagDispatched when a tag is created.
tags:updateUpdateTagEventDataDispatched when a tag is updated.
tags:deleteTagDispatched when a tag is deleted.
tags:loadTag[]Dispatched when tags are loaded into the store.

UpdateTagEventData

PropertyTypeDescription
before*TagTag data before it was changed.
after*TagUpdated tag data.
changes*TagChangesThe changes made to the tag. See below for details.

TagChanges

PropertyTypeDescription
typestringThe drop type. Determines which component will be used to render it.
colorContentColor The tag's color. See the Color page for available content colors.