-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
description_text field react (#4194)
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
scripts/apps/authoring-react/field-adapters/description_text.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {IArticle, IAuthoringFieldV2, IFieldAdapter, IEditor3Config} from 'superdesk-api'; | ||
import {gettext} from 'core/utils'; | ||
import {retrieveStoredValueEditor3Generic, storeEditor3ValueBase} from '.'; | ||
|
||
export const DESCRIPTION_TEXT_FIELD_ID = 'description_text'; | ||
|
||
export const description_text: 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: DESCRIPTION_TEXT_FIELD_ID, | ||
name: gettext('Description'), | ||
fieldType: 'editor3', | ||
fieldConfig, | ||
}; | ||
|
||
return fieldV2; | ||
}, | ||
|
||
retrieveStoredValue: (item: IArticle, authoringStorage) => retrieveStoredValueEditor3Generic( | ||
DESCRIPTION_TEXT_FIELD_ID, | ||
item, | ||
authoringStorage, | ||
), | ||
|
||
storeValue: (value, item, config) => { | ||
const result = storeEditor3ValueBase( | ||
DESCRIPTION_TEXT_FIELD_ID, | ||
item, | ||
value, | ||
config, | ||
); | ||
|
||
const articleUpdated = {...result.article}; | ||
|
||
articleUpdated.description_text = result.stringValue; | ||
|
||
return articleUpdated; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters