ICIJ / datashare-client

Frontend interface for Datashare, a self-hosted search engine for documents.
https://datashare.icij.org
GNU Affero General Public License v3.0
32 stars 17 forks source link

feat: allow widgets settings to use a factory function or a class #298

Closed pirhoo closed 1 year ago

pirhoo commented 1 year ago

PR description

This PR aims at letting plugin define their own widgets (https://github.com/ICIJ/datashare/issues/1148).

API

The new API can be used as follow (using the same registerWidget method):

core.registerWidget({
  name: 'test',
  type(WidgetEmpty) {
    return class WidgetTest extends WidgetEmpty {
      get component() {
        return {
          name: 'WidgetTest',
          template: '<div>WidgetTest</div>'
        }
      }
    }
  }
})