Measurable Success «10 Checkpoints for Future-Proof Enterprise CMS» White Paper
Measurable Success - White Paper

createWidgetClass(options)

Creates a CMS widget type without adding it to the registry of CMS widget types.

const TextWidget = Scrivito.createWidgetClass({
  attributes: {
    text: 'html',
  },
  
  onlyInside: 'BlogArticlePage',
});

Scrivito.createWidgetClass does not automatically add the generated class to the registry of CMS types. Instead, it is considered an „abstract class“. An abstract class is useful:

  • as a superclass for specialized CMS widget types
  • for overloading an API method before registering the final type using Scrivito.provideWidgetClass.

Example

Create a an abstract class named BaseClass and an ImageWidget subclass.

const BaseClass = Scrivito.createWidgetClass({
  attributes: {
    blob: 'binary',
  },
});

class ImageWidget extends BaseClass {
  myMethod() {
    return 'cool';
  }
}

Scrivito.provideWidgetClass('ImageWidget', ImageWidget);