scripts/apps/authoring-react/field-adapters/usageterms.ts
import {IArticle, IAuthoringFieldV2, IFieldAdapter, IEditor3Config} from 'superdesk-api';
import {gettext} from 'core/utils';
import {retrieveStoredValueEditor3Generic, storeEditor3ValueBase} from '.';
export const usageterms: IFieldAdapter<IArticle> = {
getFieldV2: (fieldEditor, fieldSchema) => {
const fieldConfig: IEditor3Config = {
editorFormat: [],
minLength: fieldSchema?.minlength,
maxLength: fieldSchema?.maxlength,
cleanPastedHtml: fieldEditor?.cleanPastedHTML,
singleLine: true,
disallowedCharacters: [],
};
const fieldV2: IAuthoringFieldV2 = {
id: 'usageterms',
name: gettext('Terms of use'),
fieldType: 'editor3',
fieldConfig,
};
return fieldV2;
},
retrieveStoredValue: (item: IArticle, authoringStorage) => retrieveStoredValueEditor3Generic(
'usageterms',
item,
authoringStorage,
),
storeValue: (value, item, config) => {
const result = storeEditor3ValueBase(
'usageterms',
item,
value,
config,
);
const articleUpdated = {...result.article};
articleUpdated.usageterms = result.stringValue;
return articleUpdated;
},
};