@atlaskit/pragmatic-drag-and-drop-docs
Version:
This package holds the documentation for Pragmatic drag and drop in one place. It is not intended to be consumed directly by consumers. The package is used by other tools for sharing examples
46 lines (35 loc) • 924 B
text/mdx
order: 1
title: Text
description: Helpers to make working with native text data easier
## `containsText`
Useful to know whether text data (`"text/plain"`) is being dragged. Keep in mind that multiple
pieces of native data can be dragged at once.
```ts
import { containsText } from '@atlaskit/pragmatic-drag-and-drop/external/text';
dropTargetForExternal({
element: myElement,
canDrop: containsText,
});
monitorForExternal({
canMonitor: containsText,
});
```
## `getText`
A helper to extract text data (`"text/plain"`) from drop data. Get text will return `null` when
there is no text data.
```ts
import { getText } from '@atlaskit/pragmatic-drag-and-drop/external/text';
dropTargetForExternal({
element: myElement,
onDrop({ source }) {
const text: string | null = getText({ source });
},
});
monitorForExternal({
onDrop({ source }) {
const text: string | null = getText({ source });
},
});
```