14 KiB
| type | order | title |
|---|---|---|
| api | 1 | Generated API Docs |
Uppy Core & Plugins
Core
Main Uppy core
Parameters
optsobject general options, like locales, to show modal or not to show
actions
Registers listeners for all global actions, like:
file-add, file-remove, upload-progress, reset
getPlugin
Find one Plugin by name
Parameters
stringname descriptionname
getState
Gets current state, making sure to make a copy of the state object and pass that,
instead of an actual reference to this.state
iteratePlugins
Iterate through all used plugins
Parameters
functionmethod descriptionmethod
log
Logs stuff to console, only if debug is set to true. Silent in production.
Parameters
msg
Returns (String|Object) to log
resetState
Reset state to defaultState, used when Modal is closed, for example
run
Runs a waterfall of runType plugin packs, like so: All preseters(data) --> All acquirers(data) --> All uploaders(data) --> done
runType
Runs all plugins of the same type in parallel
Parameters
Returns Promise of all methods
setState
Updates state
Parameters
objectnewStatenewState
updateAll
Iterate on all plugins and run update on them. Called when state changes
use
Registers a plugin with Core
Parameters
PluginClass objectoptionsObject object that will be passed to Plugin lateropts
Returns Object self for chaining
Utils
A collection of small utility functions that help with dom manipulation, adding listeners, promises and other good things.
Parameters
methods
addListenerMulti
Adds multiple listeners to to a DOM element
Equvalent to jQuery’s $form.on('drag dragstart dragend dragover dragenter dragleave drop').
Parameters
elString selectoreventsString to add, likedrag dragstart dragend dragover dragenter dragleave dropcbrequestCallback
Returns String
promiseWaterfall
Runs a waterfall of promises: calls each task, passing the result from the previous one as an argument. The first task is run with an empty array.
Parameters
methodsarray of Promises to run waterfall on
Returns Promise of the final task
DragDrop
src/plugins/DragDrop.js:10-196
Drag & Drop plugin
checkDragDropSupport
src/plugins/DragDrop.js:93-109
Checks if the browser supports Drag & Drop, not supported on mobile devices, for example.
Returns Boolean true if supported, false otherwise
Dummy
Dummy
flatten
Shallow flatten nested arrays.
Parameters
arr
generateFileID
Takes a fileName and turns it into fileID, by converting to lowercase, removing extra characters and adding unix timestamp
Parameters
fileNameString
Plugin
Boilerplate that all Plugins share - and should not be used directly. It also shows which methods final plugins should implement/override, this deciding on structure.
Parameters
Returns (array|string) files or success/fail message
getTarget
Check if supplied target is a string or an object.
If object (that means its a plugin), search plugins for
a plugin with same name and return its target.
Parameters
Translator
Translates strings with interpolation & pluralization support.Extensible with custom dictionaries and pluralization functions.
Borrows heavily from and inspired by Polyglot https://github.com/airbnb/polyglot.js,
basically a stripped-down version of it. Differences: pluralization functions are not hardcoded
and can be easily added among with dictionaries, nested objects are used for pluralization
as opposed to |||| delimeter
Usage example: translator.translate('files_chosen', {smart_count: 3})
Parameters
optsobject
interpolate
Takes a string with placeholder variables like %{smart_count} file selected
and replaces it with values from options {smart_count: 5}
Parameters
phrasestring that needs interpolation, with placeholdersoptionsobject with values that will be used to replace placeholders
Returns string interpolated
Meta
- license: https://github.com/airbnb/polyglot.js/blob/master/LICENSE taken from https://github.com/airbnb/polyglot.js/blob/master/lib/polyglot.js#L299
translate
Public translate method
Parameters
Returns string translated (and interpolated)
Modal
Modal
Present
Present
ProgressBar
src/plugins/ProgressBar.js:7-62
Progress bar
qsa
querySelectorAll that returns a normal array instead of fileList
Parameters
selectorcontext
Tus10
Tus resumable file uploader
run
Add files to an array of upload() calles, passing the current and total file count numbers
Parameters
Returns Promise of parallel uploads Promise.all(uploaders)
upload
Create a new Tus upload
Parameters
fileobject for use with uploadcurrentinteger file in a queuetotalinteger number of files in a queue
Returns Promise
Spinner
Spinner
then
src/plugins/GoogleDrive.js:78-108
Leave this here