import { InsertChildrenAfterAction } from '../../actions/insert-children-after-block';
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
/**
 * Insert image to list block strategy.
 */
export class ListInsertImageStrategy extends ActionHandleStrategy {
  /**
   * Insert image block at behind of the list item block.
   *
   * @param {InsertImageToBlockAction} action - The insert image action instance.
   * @param {RTEListBlock} target - The list block.
   */
  handleAction(action, target) {
    const imageBlock = action.imageBlockToBeInserted;
    if (target.parent['type'] !== 'list-item') {
      target.parent.apply(new InsertChildrenAfterAction(target, imageBlock));
    }
    else {
      target.parent.apply(action);
    }
  }
}
