import { ElementToRTEImageBlockStrategyAbstract } from './element-to-rte-image-block-strategy.abstract';
/** Transform img in span or other inline element to image block DTO */
export class SpanImageToRTEImageBlockStrategy extends ElementToRTEImageBlockStrategyAbstract {
  /**
   * Can be handle.
   *
   * @param {HTMLElement[]} elementsArray - Current elements.
   * @param {number} currentIndex - Current element index.
   * @returns {number} - can be handled element count.
   */
  canHandle(elementsArray, currentIndex) {
    const element = elementsArray[currentIndex];
    return element.nodeType === Node.ELEMENT_NODE &&
      element.textContent === '' &&
      element.querySelector('img')
      ? 1
      : 0;
  }
  /**
   * Parse to a image block.
   *
   * @param {HTMLElement[]} elementsArray - Current elements.
   * @param {VegaRTETransformOptions} [options] - Options for transformation.
   * @returns {Nullable<RTEContentBlock>} - Image block.
   */
  handle(elementsArray, options) {
    const element = elementsArray[0].querySelector('img');
    return this.createRTEImageBlock(element, options);
  }
  /* istanbul ignore next */
  /**
   * Append child blocks.
   */
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  appendChildBlocks() { }
  /**
   * Should continue process to child elements.
   *
   * @returns {boolean} - boolean.
   */
  shouldProceedToElementChildren() {
    return false;
  }
}
