Skip to content

Latest commit

 

History

History
253 lines (153 loc) · 6.74 KB

README.md

File metadata and controls

253 lines (153 loc) · 6.74 KB

@contentful/dam-app-base

@contentful/dam-app-base

Index

Interfaces

Type aliases

Functions

Type aliases

AdditionalData

Ƭ AdditionalData: { primary: string; secondary: string }

Object containing additional data about the asset to display as primary and secondary information in the "more details" section


Asset

Ƭ Asset: Record<string, any>

Object containing data about the asset. Shape and values are DAM service specific.


CompatibleFields

Ƭ CompatibleFields: Record<string, Field[]>


Config

Ƭ Config: Record<string, any>

Object containing all information configured on the app configuration page.


CustomUpdateStateValueFn

Ƭ CustomUpdateStateValueFn: ( context: { currentValue: Asset[]; result: Asset[]; config: Config; }, updateStateValue: (value: Asset[]) => void ) => Promise<void>;

Async function that takes in context about the current field value, the result from the dialog, and the app config. It also accepts a function to update the field state, and this should be called in the function to update the field


DeleteFn

Ƭ DeleteFn: (index: number) => void


DisabledPredicateFn

Ƭ DisabledPredicateFn: (currentValue: Asset[], config: Config) => boolean

Function that should return true when the button should be disabled.

param Currently selected assets

param App configuration

returns true, if the button in the field location should be disabled. false, if the button should be enabled


GetAdditionalDataFn

Ƭ GetAdditionalDataFn: (asset: Asset) => AdditionalData

Function that return an object that represents the primary and secondary data that should be displayed in the "more details" section of the asset card


OpenDialogFn

Ƭ OpenDialogFn: (sdk: FieldExtensionSDK, currentValue: Asset[], config: Config) => Promise<Asset[]>

Function that gets called when app wants to open a dialog. Should return an updated list of assets as a Promise.

You probably want to call sdk.openCurrentApp.

example

async function openDialog(sdk, currentValue, config) {
  return await sdk.dialogs.openCurrentApp({
    parameters: { config, currentValue },
  });
}

param (https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/)

param List of currently selected assets

param App configuration

returns Promise containing a list of selected assets


RenderDialogFn

Ƭ RenderDialogFn: (sdk: DialogExtensionSDK) => void

Function that gets called within the Iframe when the app is rendered in a dialog location.

example

function renderDialog(sdk) {
  const config = sdk.parameters.invocation;

  const container = document.createElement('div');
  container.innerHTML = `<iframe src="https://example.com/dam?folder=${config.folder}" width="400" height="650" style="border:none;"/>`;
  document.body.appendChild(container);
}

param (https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/)


SelectedFields

Ƭ SelectedFields: Record<string, string[] | undefined>


ThumbnailFn

Ƭ ThumbnailFn: (asset: Asset, config: Config) => [string, string | undefined]

Returns the url of the thumbnail of an asset.

param Asset

param App configuration

returns Tuple containing (1) the url and (2) the text represantation of the asset (optional)


ValidateParametersFn

Ƭ ValidateParametersFn: (parameters: Record<string, any>) => string | null

Custom code that validates installation parameters that is run before saving.

param Object containg the entered parameters.

returns string containing an error message. null if the parameters are valid.

Functions

editorInterfacesToSelectedFields

editorInterfacesToSelectedFields(eis: EditorInterface[], appId?: string): Record<string, undefined | string[]>

Parameters:

Name Type
eis EditorInterface[]
appId? string

Returns: Record<string, undefined | string[]>


getCompatibleFields

getCompatibleFields(contentTypes: ContentType[]): Record<string, Field[]>

Parameters:

Name Type
contentTypes ContentType[]

Returns: Record<string, Field[]>


selectedFieldsToTargetState

selectedFieldsToTargetState(contentTypes: ContentType[], selectedFields: Record<string, undefined | string[]>): object

Parameters:

Name Type
contentTypes ContentType[]
selectedFields Record<string, undefined | string[]>

Returns: object

Name Type
EditorInterface {}

setup

setup(integration: Integration): void

Parameters:

Name Type
integration Integration

Returns: void