All files / app/components/classes/paragraph paragraph.ts

100% Statements 2/2
100% Branches 1/1
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                                            1004x 1004x      
import { SubParagraph } from '../subparagraph/subParagraph';
 
/**
 * Paragraph class.
 *
 * Used to dynamically create `<p>` `</p>` elements with different structures
 * inside, such as `<strong><em>` `</em></strong>` elements, `<br>` elements,
 * `<a/>` elements, or any {@link SubParagraphRoot}.
 *
 * Do note that those elements are designed with the existence of code injection
 * in mind and/or malicious content in mind. For instance, `<a\>` links are
 * designed to be always prefixed by the asset folder path and hence avoid any
 * kind of attacks and injection of link to another domain (or even the same
 * domain but with an unexpected path).
 */
export class Paragraph {
  /**
   * Subparagraph elements. Represents the different elements contained inside
   * the paragraph. Will most likely be a series of `<span>` `</span>` with some
   * other elements in between. See {@link SubParagraph} and
   * {@link SubParagraphRoot} to see the elements suported.
   */
  els: SubParagraph[];
  /**
   * Used to apply style to a paragraph element by specifying which css class it
   * has to have.
   */
  cssClass: string;
 
  /**
   * Paragraph constructor.
   *
   * @param els {@link Subparagraph} elements. Represents the different elements
   *   contained inside the paragraph.
   * @param cssClass Used to apply style to a paragraph element by specifying
   *   which css class it has to have.
   */
  constructor(els: SubParagraph[], cssClass = '') {
    this.els = els;
    this.cssClass = cssClass;
  }
}