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