import { ImageAnnotation } from '../../annotations/image-annotation';
import { RTEFilterStylesStrategy } from '../filter-styles-strategy.abstract';
import { Predicate } from '../predicate';
/**
 * Filter styles strategy for image node, which defines the styles to be filtered and the conditions for filtering and refilling styles for image nodes.
 */
export class ImageFilterStylesStrategy extends RTEFilterStylesStrategy {
  constructor() {
    super(...arguments);
    this.stylesToBeFiltered = ImageAnnotation.getDefaultStyles();
    this.elementTagName = 'img';
  }
  /**
   * Used for the filterAnnotations method.
   *
   * @returns {boolean} Always `true` — image defaults are emitted as inline styles.
   */
  get alwaysFilter() {
    return true;
  }
  /**
   * @inheritDoc
   */
  canFilter(blockOrNodeInstance) {
    return Predicate.isImageNode(blockOrNodeInstance);
  }
  /**
   * @inheritDoc
   */
  canRefill(_blockOrNodeClassName, element) {
    return element.tagName.toLowerCase() === this.elementTagName;
  }
  /**
   * @inheritDoc
   */
  toCssText() {
    return this.buildCssTextForStyles(this.elementTagName, this.classNameToBeAdded);
  }
}
