How to use the contentful-ui-extensions-sdk.init function in contentful-ui-extensions-sdk

To help you get started, we’ve selected a few contentful-ui-extensions-sdk examples, based on popular ways it is used in public projects.

github contentful / create-contentful-extension / packages / contentful-extension-scripts / template / javascript-sidebar / src / index.js View on Github external
onClick={this.onButtonClick}>
        Click on me to open dialog extension
      </Button>
    );
  }
}

export const initialize = sdk => {
  if (sdk.location.is(locations.LOCATION_DIALOG)) {
    ReactDOM.render(<DialogExtension sdk={sdk} />, document.getElementById('root'));
  } else {
    ReactDOM.render(<SidebarExtension sdk={sdk} />, document.getElementById('root'));
  }
};

init(initialize);

/**
 * By default, iframe of the extension is fully reloaded on every save of a source file.
 * If you want to use HMR (hot module reload) instead of full reload, uncomment the following lines
 */
// if (module.hot) {
//   module.hot.accept();
// }
github contentful / extensions / lib / shared-dam-app / src / index.tsx View on Github external
export function setup(integration: Integration) {
  init(sdk => {
    const root = document.getElementById('root');

    if (sdk.location.is(locations.LOCATION_DIALOG)) {
      integration.renderDialog(sdk as DialogExtensionSDK);
    }

    if (sdk.location.is(locations.LOCATION_ENTRY_FIELD)) {
      render(
        <Field
          sdk={sdk as FieldExtensionSDK}
          cta={integration.cta}
          logo={integration.logo}
          makeThumbnail={integration.makeThumbnail}
          openDialog={integration.openDialog}
          isDisabled={integration.isDisabled}
        />,