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