Added onUpsertBody convenience method

This commit is contained in:
Rainer Simon 2021-02-21 08:29:16 +01:00
parent c22c9e2352
commit e2d329810f
1 changed files with 6 additions and 0 deletions

View File

@ -95,6 +95,11 @@ const Editor = props => {
}) })
); );
// Just a convenience shorthand
const onUpsertBody = (maybePrevious, updated) => maybePrevious ?
onUpdateBody(maybePrevious, updated) :
onAppendBody(updated);
const onSetProperty = (property, value) => { const onSetProperty = (property, value) => {
// A list of properties the user is NOT allowed to set // A list of properties the user is NOT allowed to set
const isForbidden = [ '@context', 'id', 'type', 'body', 'target' ].includes(property); const isForbidden = [ '@context', 'id', 'type', 'body', 'target' ].includes(property);
@ -152,6 +157,7 @@ const Editor = props => {
onAppendBody, onAppendBody,
onUpdateBody, onUpdateBody,
onRemoveBody, onRemoveBody,
onUpsertBody,
onSetProperty, onSetProperty,
onSaveAndClose: onOk onSaveAndClose: onOk
}) })