Added onUpsertBody convenience method
This commit is contained in:
parent
c22c9e2352
commit
e2d329810f
|
@ -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
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue