Editor API/props change to support #57
This commit is contained in:
parent
ae467dcc09
commit
ce12712517
|
@ -134,7 +134,7 @@ const Editor = props => {
|
||||||
// Current annotation is either a selection (if it was created from
|
// Current annotation is either a selection (if it was created from
|
||||||
// scratch just now) or an annotation (if it existed already and was
|
// scratch just now) or an annotation (if it existed already and was
|
||||||
// opened for editing)
|
// opened for editing)
|
||||||
if (currentAnnotation.bodies.length === 0 && !props.config.allowEmpty) {
|
if (currentAnnotation.bodies.length === 0 && !props.allowEmpty) {
|
||||||
if (currentAnnotation.isSelection)
|
if (currentAnnotation.isSelection)
|
||||||
onCancel();
|
onCancel();
|
||||||
else
|
else
|
||||||
|
@ -151,8 +151,8 @@ const Editor = props => {
|
||||||
props.onAnnotationDeleted(props.annotation);
|
props.onAnnotationDeleted(props.annotation);
|
||||||
|
|
||||||
// Use default comment + tag widget unless host app overrides
|
// Use default comment + tag widget unless host app overrides
|
||||||
const widgets = props.config.widgets ?
|
const widgets = props.widgets ?
|
||||||
props.config.widgets.map(getWidget) : DEFAULT_WIDGETS;
|
props.widgets.map(getWidget) : DEFAULT_WIDGETS;
|
||||||
|
|
||||||
const isReadOnlyWidget = w => w.type.disableDelete ?
|
const isReadOnlyWidget = w => w.type.disableDelete ?
|
||||||
w.type.disableDelete(currentAnnotation, {
|
w.type.disableDelete(currentAnnotation, {
|
||||||
|
@ -163,9 +163,9 @@ const Editor = props => {
|
||||||
|
|
||||||
const hasDelete = currentAnnotation &&
|
const hasDelete = currentAnnotation &&
|
||||||
// annotation has bodies or allowEmpty,
|
// annotation has bodies or allowEmpty,
|
||||||
(currentAnnotation.bodies.length > 0 || props.config.allowEmpty) &&
|
(currentAnnotation.bodies.length > 0 || props.allowEmpty) && // AND
|
||||||
!props.readOnly && // we are not in read-only config,
|
!props.readOnly && // we are not in read-only mode AND
|
||||||
!currentAnnotation.isSelection && // this is not a selection, and
|
!currentAnnotation.isSelection && // this is not a selection AND
|
||||||
!widgets.some(isReadOnlyWidget); // every widget is deletable
|
!widgets.some(isReadOnlyWidget); // every widget is deletable
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue