Media picker
Library for handling file uploads
yarn add @atlaskit/media-picker
68.0.0
Major Changes
-
#117363
10a0f7f6c2027
- This package'speerDependencies
have been adjusted forreact
and/orreact-dom
to reflect the status of only supporting React 18 going forward. No explicit breaking change to React support has been made in this release, but this is to signify going forward, breaking changes for React 16 or React 17 may come via non-major semver releases.Please refer this community post for more details: https://community.developer.atlassian.com/t/rfc-78-dropping-support-for-react-16-and-rendering-in-a-react-18-concurrent-root-in-jira-and-confluence/87026
Patch Changes
- Updated dependencies
Note: This component is designed for internal Atlassian development.
External contributors will be able to use this component but will not be able to submit issues.
Note:
Don't forget to add these polyfills to your product build if you're using emoji or mentions in the editor and you want to target older browsers:
ChildNode.remove()
(polyfill, browser support)
Media Picker Component Overview
The MediaPicker library is made up of several components which allow the user to select media in different ways.
The following components are React-based:
- DropZone - provides a drag & drop area for the user to drag & drop a local file
- Clipboard - provides copy and paste support for the user
- Browser - provides the native file browser to allow the user to select a local file
Each React component has the following standard props, which allow you to receive events about the uploads.
- onUploadStart?:
(payload: UploadsStartEventPayload) => void
- This event is fired when files begin to upload - onPreviewUpdate?:
(payload: UploadPreviewUpdateEventPayload) => void
- This event is fired when a preview (image) of the files uploaded is available - onError?:
(payload: UploadErrorEventPayload) => void
- This event is fired when errors occur during upload - onEnd?:
(payload: UploadEndEventPayload) => void
- This event is fired when the upload ends
There is also a non-React-based component called MediaPicker which provides a custom picker UI which supports the following sources:
- Local file via native files browser
Note:
We assume you have a valid mediaClientConfig
and authProvider
object setup as per this.
For the sake of brewity, most of the example uses inbuilt helper methods.