import { AnnotationGeneratorStrategyAbstract } from './annotation-generator-strategy.abstract';
import { BOLD_FONT_WEIGHT, BOLD_FONT_WEIGHT_KEYWORD, } from '../../../../../dto/annotations/text-format-default-styles';
/** Handle bold annotation */
export class BoldAnnotationHandler extends AnnotationGeneratorStrategyAbstract {
  /**
   * @inheritDoc
   */
  canHandle(targetDto) {
    return targetDto.dtoName === 'RTETextNode';
  }
  /**
   * Handle annotation.
   *
   * @param {HTMLElement} element - Current elements.
   * @param {VegaRTETextAnnotations} parentAnnotations - Parent annotations.
   * @returns {VegaRTETextAnnotations} - Annotation.
   */
  handle(element, parentAnnotations = {}) {
    return this.isBold(element) || parentAnnotations.bold ? { bold: true } : {};
  }
  /**
   * Is bold element.
   *
   * @param {HTMLElement} element - current element.
   * @returns {boolean} - boolean.
   */
  isBold(element) {
    return (element.nodeName === 'STRONG' ||
      element.nodeName === 'B' ||
      element.style.fontWeight === BOLD_FONT_WEIGHT_KEYWORD ||
      element.style.fontWeight === BOLD_FONT_WEIGHT ||
      element.classList.contains('v-rte--bold'));
  }
}
