allow registered widget controls to be reused

This commit is contained in:
Shawn Erquhart 2017-06-30 17:59:36 -04:00
parent 72a661d132
commit aebf28b881

View File

@ -22,7 +22,10 @@ export default {
return _registry.previewStyles;
},
registerWidget(name, control, preview) {
_registry.widgets[name] = { control, preview };
// A registered widget control can be reused by a new widget, allowing
// multiple copies with different previews.
const newControl = typeof control === 'string' ? _registry.widgets[control].control : control;
_registry.widgets[name] = { control: newControl, preview };
},
getWidget(name) {
return _registry.widgets[name];