Dummy.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const Plugin = require('../core/Plugin')
  2. const html = require('yo-yo')
  3. // const yo = require('yo-yo')
  4. /**
  5. * Dummy
  6. * A test plugin, does nothing useful
  7. */
  8. module.exports = class Dummy extends Plugin {
  9. constructor (uppy, opts) {
  10. super(uppy, opts)
  11. this.type = 'acquirer'
  12. this.id = this.opts.id || 'Dummy'
  13. this.title = 'Mr. Plugin'
  14. // set default options
  15. const defaultOptions = {}
  16. // merge default options with the ones set by user
  17. this.opts = Object.assign({}, defaultOptions, opts)
  18. this.strange = html`<h1>this is strange 1</h1>`
  19. this.render = this.render.bind(this)
  20. this.install = this.install.bind(this)
  21. }
  22. addFakeFileJustToTest () {
  23. const blob = new Blob(
  24. ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='],
  25. {type: 'image/svg+xml'}
  26. )
  27. const file = {
  28. source: 'acceptance-test',
  29. name: 'test-file',
  30. type: 'image/svg+xml',
  31. data: blob
  32. }
  33. this.props.log('Adding fake file blob')
  34. this.props.addFile(file)
  35. }
  36. render (state) {
  37. const bla = html`<h2>this is strange 2</h2>`
  38. return html`
  39. <div class="wow-this-works">
  40. <input class="UppyDummy-firstInput" type="text" value="hello" onload=${(el) => {
  41. el.focus()
  42. }} />
  43. ${this.strange}
  44. ${bla}
  45. ${state.dummy.text}
  46. </div>
  47. `
  48. }
  49. install () {
  50. this.uppy.setState({dummy: {text: '123'}})
  51. const target = this.opts.target
  52. if (target) {
  53. this.mount(target, this)
  54. }
  55. setTimeout(() => {
  56. this.uppy.setState({dummy: {text: '!!!'}})
  57. }, 2000)
  58. }
  59. }
  60. // module.exports = function (core, opts) {
  61. // if (!(this instanceof Dummy)) {
  62. // return new Dummy(core, opts)
  63. // }
  64. // }