فهرست منبع

Plugin architecture updated according to recent discussions

Artur Paikin 9 سال پیش
والد
کامیت
2d6af3e838
1فایلهای تغییر یافته به همراه39 افزوده شده و 18 حذف شده
  1. 39 18
      ARCHITECTURE.md

+ 39 - 18
ARCHITECTURE.md

@@ -7,34 +7,55 @@
 4. Then the processed stuff goes into ```upload``` which uploads everything to Transloadit
 4. Then the processed stuff goes into ```upload``` which uploads everything to Transloadit
 
 
 ### Plugins
 ### Plugins
-1. We should be able to register a plugin with something like:
-```javascript
-  transloadit.plugin('dragndrop', function(options) {
-    console.log('dragging and dropping here');
-  });
-```
-or:
+1. Plugins should be registered like this:
 ```javascript
 ```javascript
   transloadit.use(dragndrop, {
   transloadit.use(dragndrop, {
     selector: '.drop'
     selector: '.drop'
   });
   });
 ```
 ```
-2. ?
+```dragndrop``` here is function that we pass as an argument.
+*For reference, see [Markdown-It](https://github.com/markdown-it/markdown-it/blob/master/lib/index.js#L459).*
+
+2. Settings and handlers should be chainable and set like this:
+```javascript
+transloadit
+  .set({ wait: true })
+  .use(transloaditModal, {some: 'config'})
+  .use(dragdrop, {target: transloaditModal})
+  .use(instagram, {some: 'config'})
+  .on('progress', handleProgress)
+  .on('error', handleError);
+```
+
+3. In ```transloadit-js``` everything is a plugin: a modal dialog, drag & drop, Instagram . We take the general approach from the new Babel and PostCSS — almost barebones by default, each chunk of functionality exists in as separate plugin — easier to pick and choose exactly what you need to get a lightweight solution for production, but also easier to work on and avoid merge conflicts.
+
+4. Presets with basic plugins like modal & dragndrop. This should let people who just want to get it working as quickly as possible get started in seconds:
+    ```javascript
+    transloadit
+      .set({ wait: true })
+      .use(transloaditBasic, {some: 'config'})
+    ```
+
+    *See [```es2015-preset```](https://babeljs.io/docs/plugins/preset-es2015/) for Babel and [```PreCSS```](https://github.com/jonathantneal/precss#plugins) for PostCSS.*
+
+5. Users should be able to set themes and style settings in config: ```.use(myTheme)```.
+
+6. Would be cool if you could use whatever drag & drop library you wanted (DropZone) with our wrapper.
 
 
 ### Usage
 ### Usage
 ```javascript
 ```javascript
 import transloadit   from 'transloadit';
 import transloadit   from 'transloadit';
 import dragndrop     from 'transloadit-dragndrop';
 import dragndrop     from 'transloadit-dragndrop';
 import dropbox       from 'transloadit-dropbox';
 import dropbox       from 'transloadit-dropbox';
+import instagram     from 'transloadit-instagram';
+import modal         from 'transloadit-modal';
 
 
-transloadit([
-  dragndrop(),
-  dropbox({
-    folder: '/media',
-    allowSmth: true
-  })
-])
-.then(function (result) {
-  console.log(`Done processing: ${result}`);
-});
+transloadit
+  .set({ wait: true })
+  .use(modal, {some: 'config'})
+  .use(dragdrop, {target: transloaditModal})
+  .use(instagram, {some: 'config'})
+  .on('progress', handleProgress)
+  .on('error', handleError)
+  .on('done', handleResult);
 ```
 ```