diff --git a/scripts/index.ts b/scripts/index.ts index 6badf08d29..f5124062ad 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -29,6 +29,7 @@ import {httpRequestJsonLocal} from 'core/helpers/network'; import {store} from 'core/data'; import {registerGlobalKeybindings} from 'core/keyboard/keyboard'; import {maybeDisplayInvalidInstanceConfigurationMessage} from 'validate-instance-configuration'; +import {registerLegacyExtensionCompatibilityLayer} from 'register-legacy-extension-compatibility-layer'; let body = angular.element('body'); @@ -152,6 +153,8 @@ export function startApp( registerAuthoringReactWidgets(); registerAuthoringReactFields(); } + + registerLegacyExtensionCompatibilityLayer(); }); }); }, diff --git a/scripts/register-legacy-extension-compatibility-layer.tsx b/scripts/register-legacy-extension-compatibility-layer.tsx new file mode 100644 index 0000000000..8503d49f6f --- /dev/null +++ b/scripts/register-legacy-extension-compatibility-layer.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import {IExtensionActivationResult} from 'superdesk-api'; +import {registerInternalExtension} from 'core/helpers/register-internal-extension'; +import ng from 'core/services/ng'; + +interface ILegacyExtensionPoint { + type: string; + componentClass: React.ComponentType; + data: unknown; + onInit: unknown; + props: {[key: string]: unknown}; +} + +export function registerLegacyExtensionCompatibilityLayer() { + const extensionActivationResult: IExtensionActivationResult = { + contributions: { + publishingSections: (ng.get('extensionPoints').get('authoring:publish') as Array) + .map((api) => { + const Component = api.componentClass; + + return { + component: function LegacyExtensionCompatibilityLayerComponentWrapper(props) { + return ( + + ); + }, + }; + }), + }, + }; + + registerInternalExtension('extensionCompatibilityLayer', extensionActivationResult); +}