Breaking change: Dropped onRemoveAndAppend in favour of onBatchModify
This commit is contained in:
parent
0b3edd41d5
commit
1dc7cc73e3
|
@ -239,26 +239,6 @@ export default class Editor extends Component {
|
||||||
this.updateCurrentAnnotation({ body: updatedBodies }, saveImmediately);
|
this.updateCurrentAnnotation({ body: updatedBodies }, saveImmediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* For convenience: removes and appends one or more bodies
|
|
||||||
* in one go, optionally saving immediately.
|
|
||||||
*/
|
|
||||||
onRemoveAndAppend = (bodyOrBodiesToRemove, bodyOrBodiesToAppend, saveImmediately) => {
|
|
||||||
// Shorthand
|
|
||||||
const toArray = body => Array.isArray(body) ? body : [ body ];
|
|
||||||
|
|
||||||
const toRemove = toArray(bodyOrBodiesToRemove);
|
|
||||||
const toAppend = toArray(bodyOrBodiesToAppend).map(b =>
|
|
||||||
({ ...b, ...this.creationMeta(b) }));
|
|
||||||
|
|
||||||
this.updateCurrentAnnotation({
|
|
||||||
body: [
|
|
||||||
...this.state.currentAnnotation.bodies.filter(b => !toRemove.includes(b)),
|
|
||||||
...toAppend
|
|
||||||
]
|
|
||||||
}, saveImmediately);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the given property value at the top level of the annotation.
|
* Sets the given property value at the top level of the annotation.
|
||||||
* @param property property key
|
* @param property property key
|
||||||
|
@ -352,7 +332,7 @@ export default class Editor extends Component {
|
||||||
onUpdateBody: this.onUpdateBody,
|
onUpdateBody: this.onUpdateBody,
|
||||||
onRemoveBody: this.onRemoveBody,
|
onRemoveBody: this.onRemoveBody,
|
||||||
onUpsertBody: this.onUpsertBody,
|
onUpsertBody: this.onUpsertBody,
|
||||||
onRemoveAndAppend: this.onRemoveAndAppend,
|
onBatchModify: this.onBatchModify,
|
||||||
onSetProperty: this.onSetProperty,
|
onSetProperty: this.onSetProperty,
|
||||||
onSaveAndClose: this.onOk
|
onSaveAndClose: this.onOk
|
||||||
})
|
})
|
||||||
|
|
|
@ -17,6 +17,8 @@ export default class WrappedWidget extends Component {
|
||||||
onUpdateBody: (previous, updated, saveImmediately) => props.onUpdateBody(previous, updated, saveImmediately),
|
onUpdateBody: (previous, updated, saveImmediately) => props.onUpdateBody(previous, updated, saveImmediately),
|
||||||
onUpsertBody: (previous, updated, saveImmediately) => props.onUpsertBody(previous, updated, saveImmediately),
|
onUpsertBody: (previous, updated, saveImmediately) => props.onUpsertBody(previous, updated, saveImmediately),
|
||||||
onRemoveBody: (body, saveImmediately) => props.onRemoveBody(body, saveImmediately),
|
onRemoveBody: (body, saveImmediately) => props.onRemoveBody(body, saveImmediately),
|
||||||
|
onBatchModify: (diffs, saveImmediately) => props.onBatchModify(diffs, saveImmediately),
|
||||||
|
onSetProperty: (property, value) => props.onSetProperty(property, value),
|
||||||
onSaveAndClose: () => props.onSaveAndClose()
|
onSaveAndClose: () => props.onSaveAndClose()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue