An interface for describing drop types.
Property | Type | Description |
---|---|---|
type* | string | The drop type. |
name* | string | The name of the drop type. Displayed to users. |
description* | string | A short description of the drop type. Displayed to users. |
dataTypes | string[] | The data types from which this kind of drop can be created. Omit if this drop type does not support data. |
fileTypes | string[] | The file types from which this kind of drop can be created. Omit if this drop type does not support files. |
multiFile | boolean | If true , indicates that this drop type supports multiple files at once. |
requiresData | boolean | If true , this drop type requires a data for creation. If both requiresData and requiresFile are true, either one will satisfy the condition. |
requiresFile | boolean | If true , this drop type requires a file for creation. If both requiresData and requiresFile are true, either one will satisfy the condition. |
create* | function | Called to create a new drop of this type. See below for details. |
insertData | function | Called when data is dropped or pasted onto the drop. Omit if updating the drop using data is not supported. See below for more details. |
Called to create a new drop of this type. Should return an object containing the drop type as well as any custom data used by the drop.
For example, imagine a web bookmark drop which has a url
and title
property. The create
method should return an object defining these properties:
{
type: 'bookmark',
url: 'https://minddrop.app',
title: "MindDrop - Your mind's visual workspace",
}
A FileReference
must be created for any files from the data which need to be preserved using the Files.create
method.
If a drop cannot be created due to invalid or missing data, a InvalidDropDataError
should be thrown.
A promise resolving to the drop's data can be returned if an asyncronous action is required to create it.
create(core: Core, data?: DataInsert): CreateDropData | Promise<CreateDropData>
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
data | DataInsert | A Note that this function can be called without data if neither |
Called when data is dropped or pasted onto the drop. Omit if updating the drop in this way is not supported. Must return a promise which resolves to the updated drop (or original drop if it was not updated).
Should make use of the Drops.update
method in order to update the drop.
A FileReference
must be created for any files from the data which need to be preserved using the Files.create
method.
insertData(core: Core, drop: Drop, data: DataInsert): Promise<Drop>;
Argument | Type | Description |
---|---|---|
core* | Core | A MindDrop core instance. |
drop* | Drop | The drop into which the data was inserted. |
data* | DataInsert | The data dropped or pasted onto the drop. |