import { Predicate } from '../predicate';
import { HeadingFilterStylesStrategy } from '../text-block/heading-filter-styles-strategy';
/**
 * Filters the default heading styles from customStyle when parsing an RTEListItemBlock that is supposed to be a heading.
 */
export class ListHeadingItemBlockFilterStylesStrategy extends HeadingFilterStylesStrategy {
  constructor(level) {
    super(level);
    this.classNameToBeAdded = `v-rte-h${level}`;
    this.elementTagName = 'li';
  }
  /**
   * Check the important font-size and line-height for list item block are default styles, and the block is a list item block.
   *
   * @inheritDoc
   */
  canFilter(blockOrNodeInstance) {
    return (Predicate.isListItemBlock(blockOrNodeInstance.constructor.name) &&
      this.isBlockOrNodeStylesMatchFilterStyles(blockOrNodeInstance, ['fontSize', 'lineHeight']));
  }
  /**
   * @inheritDoc
   */
  canRefill(blockOrNodeClassName, element) {
    return (Predicate.isListItemBlock(blockOrNodeClassName) &&
      element.matches(this.elementTagName) &&
      element.classList.contains(this.classNameToBeAdded));
  }
}
