A configuration object used to register topic views.
Topics render their content using instances of a special type of view called topic views. Topic views need to be registered using the Topics.registerView
method before they can be used.
Property | Type | Description |
---|---|---|
id* | string | The ID of the topic view. Must be unique accross the app. |
name* | string | The name of the view. Dispalyed to users. |
description* | string | A short, single sentence description of the view. Displayed to users. |
component* | React.ComponentType | The React component rendered by the view. |
onCreate | function | Called when a new instance of the topic view is created. See below for details. |
onDelete | function | Called when an instance of the topic view is deleted. See below for details. |
onAddDrops | function | Called when drops are added, unarchived, or restored to the topic. See below for details. |
onRemoveDrop | function | Called when drops are archived, deleted, or permanently deleted from the topic. See below for details. |
onAddSubtopics | function | Called when subtopics are added, unarchived, or restored to the topic. See below for details. |
onRemoveSubtopics | function | Called when subtopics are archived, deleted, or permanently deleted from the topic. See below for details. |
onInsertData | function | Called when data is inserted into an open topic view instance, usually in the form of a drag and drop or paste event. |
Called when a new instance of the topic view is created. Should return any custom data used to setup the view.
Note that default TopicViewInstance
data such as id
, view
, topic
, createdAt
, etc. are set automatically and should not be returned by this method.
onCreate(core: Core, topic: Topic): object
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
topic* | Topic | The topic for which the view was created. |
Called when an instance of the topic view is deleted. Useful for cleaning up any artifacts created by the view instance.
Note that this method does not need to delete the topic view instance itself, just any data that would be left over.
onDelete(core: Core, viewInstance: ViewInstance): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
viewInstance* | ViewInstance | The deleted view instance. |
Called on all of a topic's views when drops are added, unarchived, or restored to the topic.
onAddDrops(core: Core, viewInstance: ViewInstance, drops: DropMap, metadata: AddDropMetadata): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
viewInstance* | ViewInstance | The view instance. |
drops* | DropMap | The drops which were added to the topic. |
metadata | AddDropsMetadata | Metadata about the event. See below for details. |
Metadata about the event when drops are added to a topic. Contains the ID of the view instance into which the drop was added (or null
if not added by a view) and any other data added by the view which added the drop.
Property | Type | Description |
---|---|---|
viewInstance* | string | null | The ID of the view instance into which the drop was inserted.null if the drop was not inserted into a view. |
Additionally, the metadata object can contain values added by the view which added the drop.
Called on all of a topic's views when drops are archived, deleted, or permanently deleted from the topic.
onRemoveDrops(core: Core, topic: Topic, viewInstance: ViewInstance, drops: DropMap): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
topic* | Topic | The topic from which the drop was removed. |
viewInstance* | ViewInstance | The view instance. |
drops* | DropMap | The drops which were removed from the topic. |
Called on all view instances when subtopics are added, unarchived, or restored into a topic.
onAddSubtopics(core: Core, viewInstance: ViewInstance, subtopics: TopicMap): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
viewInstance* | ViewInstance | The view instance. |
subtopics* | TopicMap | The topics which were added as subtopics to the topic. |
Called on all view instances when subtopics are removed, unarchived, or restored from a topic.
onRemoveSubtopics(core: Core, viewInstance: ViewInstance, subtopics: TopicMap): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
viewInstance* | ViewInstance | The view instance. |
subtopics* | TopicMap | The topics which were removed as subtopics from the topic. |
Called when data is inserted into an open topic view instance, usually in the from of a drag and drop or paste event. Only called on the affected view.
Note that this method is only called when raw data such as text or files are inserted. If the data consists of drops or topics, onAddDrops
or onAddTopics
are called instead.
onInsertData(core: Core, viewInstance: ViewInstance, data: DataInsert): void
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
viewInstance* | ViewInstance | The view instance. |
data* | DataInsert | The inserted data. |