diff --git a/src/editor/Editor.jsx b/src/editor/Editor.jsx index 25fa188..e108d73 100644 --- a/src/editor/Editor.jsx +++ b/src/editor/Editor.jsx @@ -239,26 +239,6 @@ export default class Editor extends Component { 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. * @param property property key @@ -352,7 +332,7 @@ export default class Editor extends Component { onUpdateBody: this.onUpdateBody, onRemoveBody: this.onRemoveBody, onUpsertBody: this.onUpsertBody, - onRemoveAndAppend: this.onRemoveAndAppend, + onBatchModify: this.onBatchModify, onSetProperty: this.onSetProperty, onSaveAndClose: this.onOk }) diff --git a/src/editor/widgets/WrappedWidget.jsx b/src/editor/widgets/WrappedWidget.jsx index f0bf86a..1da07d2 100644 --- a/src/editor/widgets/WrappedWidget.jsx +++ b/src/editor/widgets/WrappedWidget.jsx @@ -17,6 +17,8 @@ export default class WrappedWidget extends Component { onUpdateBody: (previous, updated, saveImmediately) => props.onUpdateBody(previous, updated, saveImmediately), onUpsertBody: (previous, updated, saveImmediately) => props.onUpsertBody(previous, updated, 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() });