UNPKG

uppy

Version:

Extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:

78 lines (67 loc) 1.77 kB
const Plugin = require('../core/Plugin') const { h } = require('preact') /** * Dummy * A test plugin, does nothing useful */ module.exports = class Dummy extends Plugin { constructor (uppy, opts) { super(uppy, opts) this.type = 'acquirer' this.id = this.opts.id || 'Dummy' this.title = 'Mr. Plugin' // set default options const defaultOptions = {} // merge default options with the ones set by user this.opts = Object.assign({}, defaultOptions, opts) this.strange = <h1>this is strange 1</h1> this.render = this.render.bind(this) this.install = this.install.bind(this) } addFakeFileJustToTest () { const blob = new Blob( ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='], {type: 'image/svg+xml'} ) const file = { source: 'acceptance-test', name: 'test-file', type: 'image/svg+xml', data: blob } this.props.log('Adding fake file blob') this.props.addFile(file).catch(() => { // Ignore }) } render (state) { const bla = <h2>this is strange 2</h2> return ( <div class="wow-this-works"> <input class="UppyDummy-firstInput" type="text" value="hello" /> {this.strange} {bla} {state.dummy.text} </div> ) } install () { this.uppy.setState({ dummy: { text: '123' } }) const target = this.opts.target if (target) { this.mount(target, this) } setTimeout(() => { this.uppy.setState({ dummy: {text: '!!!'} }) }, 2000) } } // module.exports = function (core, opts) { // if (!(this instanceof Dummy)) { // return new Dummy(core, opts) // } // }