Learn how Scrivito CMS can help you deliver amazing digital experiences
See Scrivito CMS in action

createWidgetClass(definition)

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

Scrivito.createWidgetClass generates a widget class using the given definition.

Analogously to an object class, a widget class defines the properties of its instances.

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

Please note that 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.

Params

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);