import { TextStyleAnnotation } from '../../annotations/text-style-annotation';
import { RTEFilterStylesStrategy } from '../filter-styles-strategy.abstract';
import { Predicate } from '../predicate';
/**
 *
 */
export class ParagraphFilterStylesStrategy extends RTEFilterStylesStrategy {
  constructor() {
    super(...arguments);
    this.stylesToBeFiltered = TextStyleAnnotation.getDefaultStyles('paragraph');
    this.type = 'paragraph';
    this.elementTagName = 'p';
  }
  /**
   * Don't run the filterAnnotations for paragraph heading, title, subtitle, list heading item, list title item, list subtitle item.
   * Already handle it in html-element-to-annotation-generator.ts#removeTextStyleDefaultsFromCustomStyle
   *
   * @inheritDoc
   */
  filterAnnotations(annotations) {
    return annotations;
  }
  /**
   * Determines whether the dto instance is text block and has the same type as the strategy's configured type.
   *
   * @param {RTEBlock | RTENode} blockOrNodeInstance - The block or node instance to check.
   * @returns {boolean} - True if the instance is a text block with the same type as the strategy, false otherwise.
   */
  canFilter(blockOrNodeInstance) {
    return Predicate.isTextBlock(blockOrNodeInstance.dtoName) && blockOrNodeInstance.type === this.type;
  }
  /**
   * @inheritDoc
   */
  canRefill(blockOrNodeClassName, element) {
    const selector = this.classNameToBeAdded
      ? `.${this.classNameToBeAdded}`
      : this.elementTagName;
    return Predicate.isTextBlock(blockOrNodeClassName) && element.matches(selector);
  }
  /**
   * @inheritDoc
   */
  toCssText() {
    return this.buildCssTextForStyles(this.elementTagName, this.classNameToBeAdded);
  }
}
