import { createStyleMapFromElement } from '../../../../../helpers/utils';
import { AnnotationGeneratorStrategyAbstract } from './annotation-generator-strategy.abstract';
/** Handle custom style annotation */
export class CustomStyleAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
  /**
   * Can be handle.
   *
   * @param {RTEDtoClassPrototype} targetDto - Target DTO.
   * @param {HtmlElementToAnnotationGenerateOptions} [options] - Options for annotation generator.
   * @returns {boolean} - .
   */
  canHandle(targetDto, options) {
    return !options.skipCustomAnnotations && !!targetDto;
  }
  /**
   * Handle annotation.
   *
   * @param {HTMLElement} element - Current elements.
   * @returns {VegaRTETextAnnotations} - Annotation.
   */
  handle(element) {
    const styles = createStyleMapFromElement(element);
    return Object.keys(styles).length > 0 ? { customStyle: styles } : {};
  }
}
