import { AnnotationGeneratorStrategyAbstract } from './annotation-generator-strategy.abstract';
/** Handle image size annotation */
export class ImageSizeAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
  /**
   * @inheritDoc
   */
  canHandle(targetDto) {
    return targetDto.dtoName === 'RTEImageNode';
  }
  /**
   * Handle annotation.
   *
   * @param {HTMLElement} element - Current elements.
   * @returns {VegaRTEImageAnnotations} - Annotation.
   */
  handle(element) {
    const size = this.getImageSize(element);
    return size ? { size: size } : {};
  }
  /**
   * Determine the image display size based on the width of the current element.
   *
   * @param {HTMLElement} element - current element.
   * @returns {Nullable<VegaRichTextImageEditorSizeType>} -Image size, default 'md'.
   */
  getImageSize(element) {
    if (element.getAttribute('data-size')) {
      return element.getAttribute('data-size');
    }
    return null;
  }
}
