Преглед изворни кода

Move `target` parameter to option in transloadit.pick.

Renée Kooi пре 6 година
родитељ
комит
34ed3061b0

+ 1 - 1
examples/transloadit/index.html

@@ -58,7 +58,7 @@
       </form>
 
       <hr>
-      <h2>transloadit.modal()</h2>
+      <h2>transloadit.pick()</h2>
 
       <p>
         <button onclick="openModal()">Open</button>

+ 1 - 1
examples/transloadit/main.js

@@ -34,7 +34,7 @@ window.formUppy = formUppy
  */
 
 function openModal () {
-  transloadit.modal('body', {
+  transloadit.pick({
     restrictions: {
       allowedFileTypes: ['.png']
     },

+ 3 - 1
packages/@uppy/transloadit-preset/src/pick.js

@@ -5,7 +5,9 @@ const addProviders = require('./addProviders')
 
 const CANCEL = {}
 
-function pick (target, opts = {}) {
+function pick (opts = {}) {
+  const target = opts.target || document.body
+
   const pluginId = 'pick'
   const uppy = createUppy(opts, {
     allowMultipleUploads: false

+ 2 - 2
website/src/docs/transloadit-preset-picker.md

@@ -9,7 +9,7 @@ order: 11
 Show a modal UI that allows users to pick files from their device and from the web. It uploads files to Transloadit for processing.
 
 ```js
-const resultPromise = transloadit.pick(target, {
+const resultPromise = transloadit.pick({
   params: {
     auth: { key: '' },
     template_id: ''
@@ -23,7 +23,7 @@ const resultPromise = transloadit.pick(target, {
  - `failed` - An array containing data about files that failed to upload
  - `transloadit` - An array of Assembly statuses
 
-## `target`
+## `options.target`
 
 DOM element or CSS selector to place the modal element in. `document.body` is usually fine in this case because the modal is absolutely positioned on top of everything anyway.