|
@@ -72,6 +72,16 @@ module.exports = class Plugin {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * Called when plugin is mounted, whether in DOM or into another plugin.
|
|
|
+ * Needed because sometimes plugins are mounted separately/after `install`,
|
|
|
+ * so this.el and this.parent might not be available in `install`.
|
|
|
+ * This is the case with @uppy/react plugins, for example.
|
|
|
+ */
|
|
|
+ onMount () {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* Check if supplied `target` is a DOM element or an `object`.
|
|
|
* If it’s an object — target is a plugin, and we search `plugins`
|
|
@@ -107,6 +117,7 @@ module.exports = class Plugin {
|
|
|
|
|
|
this.el = preact.render(this.render(this.uppy.getState()), targetElement)
|
|
|
|
|
|
+ this.onMount()
|
|
|
return this.el
|
|
|
}
|
|
|
|
|
@@ -127,9 +138,11 @@ module.exports = class Plugin {
|
|
|
}
|
|
|
|
|
|
if (targetPlugin) {
|
|
|
- const targetPluginName = targetPlugin.id
|
|
|
- this.uppy.log(`Installing ${callerPluginName} to ${targetPluginName}`)
|
|
|
+ this.uppy.log(`Installing ${callerPluginName} to ${targetPlugin.id}`)
|
|
|
+ this.parent = targetPlugin.id
|
|
|
this.el = targetPlugin.addTarget(plugin)
|
|
|
+
|
|
|
+ this.onMount()
|
|
|
return this.el
|
|
|
}
|
|
|
|