|
|
@@ -66,19 +66,26 @@ export default class RemoveOperation extends MoveOperation {
|
|
|
* @protected
|
|
|
* @type {Boolean}
|
|
|
*/
|
|
|
- get _insertHolderElement() {
|
|
|
+ get _needsHolderElement() {
|
|
|
if ( this.delta ) {
|
|
|
+ // Let's look up all operations from this delta in the same order as they are in the delta.
|
|
|
for ( let operation of this.delta.operations ) {
|
|
|
+ // We are interested only in `RemoveOperation`s.
|
|
|
if ( operation instanceof RemoveOperation ) {
|
|
|
+ // If the first `RemoveOperation` in the delta is this operation, this operation
|
|
|
+ // needs to insert holder element in the graveyard.
|
|
|
if ( operation == this ) {
|
|
|
return true;
|
|
|
} else if ( operation._holderElementOffset == this._holderElementOffset ) {
|
|
|
+ // If there is a `RemoveOperation` in this delta that "points" to the same holder element offset,
|
|
|
+ // that operation will already insert holder element at that offset. We should not create another holder.
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // By default `RemoveOperation` needs holder element, so set it so, if the operation does not have delta.
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -104,7 +111,7 @@ export default class RemoveOperation extends MoveOperation {
|
|
|
* @inheritDoc
|
|
|
*/
|
|
|
_execute() {
|
|
|
- if ( this._insertHolderElement ) {
|
|
|
+ if ( this._needsHolderElement ) {
|
|
|
const graveyard = this.targetPosition.root;
|
|
|
const holderElement = new Element( '$graveyardHolder' );
|
|
|
|