import { ActionHandlerInterceptor } from '../../../dto/action-handle-strategies/action-handle-interceptor.abstract';
import { methodPlaceholder } from 'vega-slimmer/core';
import { RTETableCellBlock } from '../dto/table-cell-block';
/**
 * Interceptor to prevent insertion of non-cell blocks into a table row.
 */
export class PreventRowInsertInterceptor extends ActionHandlerInterceptor {
  /**
   * Prevent insertion if any of the children to be inserted is not a table cell block.
   *
   * @param {InsertChildrenBeforeAction} action - the action to be intercepted
   * @returns {boolean} - true if the insertion should be intercepted, false otherwise
   */
  canIntercept(action) {
    return action.childrenToBeInserted.some((item) => !(item instanceof RTETableCellBlock));
  }
  /**
   * @inheritDoc
   */
  intercept() {
    methodPlaceholder();
  }
}
