Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocElement

Hierarchy

Index

Properties

Static SINGLES

SINGLES: TMPTag[] = ...

Readonly attributes

attributes: Record<string, string | number>

boiler

boiler: TMPElement[] = []

children

children: TMPNode[]

Readonly tagName

tagName: TMPTag

Methods

align

  • Set the alignment of the text.

    example
    const formatted = tb().align(Align.Center, "center content moment");
    

    Parameters

    Returns DocElement

alpha

  • Set the opacity of the text.

    example
    const formatted = tb().alpha("AA");
    

    Parameters

    • opacity: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

bold

clone

  • Deep clone the tree.

    example
    const formatted = tb(color("blue"), italics())
      .text("Deep clone!!!");
    
    const clone = formatted.clone();
    

    Returns TMPElement

color

  • color(clr: string | [number, number, number, number], ...content: TMPNode[]): DocElement
  • Set the colour of the text

    example
    const formatted = tb().color("ff0000ff", "Red text.");
    

    Or using RGBA:

    const formatted = tb().color([255, 0, 0, 255], "RGBA red text.");
    

    Parameters

    • clr: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns DocElement

font

  • Change the font face of the text.

    example
    const formatted = tb().font("Comic Sans MS", "funeral service.");
    

    Parameters

    • face: string
    • Rest ...content: TMPNode[]

    Returns DocElement

getAttributes

  • getAttributes(): string
  • Get the representation of the element attributes as a string.

    Returns string

getBoilerClose

  • getBoilerClose(): string
  • Get the representation of the closing boilerplate tags for the document.

    Returns string

getBoilerOpen

  • getBoilerOpen(): string
  • Get the representation of the opening boilerplate tags for the document.

    Returns string

getClosing

  • getClosing(): string
  • Get the representation of the element closing tag as a string.

    Returns string

getInner

  • getInner(): string
  • Get the inner representation of the element structure as a string.

    Returns string

getOuter

  • getOuter(): string
  • Get the outer representation of the element structure as a string.

    Returns string

getTag

  • getTag(): string
  • Get the representation of the element tag as a string.

    Returns string

highlight

  • highlight(color: string | [number, number, number, number], ...content: TMPNode[]): void
  • Change the background colour of the text.

    example
    const formatted = tb().highlight("00ff00aa", "This text has a green background.");
    

    Or using RGBA:

    const formatted = tb().highlight([0, 255, 0, 255], "This text has a green background.");
    

    Parameters

    • color: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns void

indent

  • Change the left indentation of the text.

    example
    const formatted = tb().indent("5em", "I am indented by 5.");
    

    Parameters

    • indentation: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

italics

  • Make the text italic.

    example
    const formatted = tb().italics("italic text....");
    

    Parameters

    Returns DocElement

link

  • link(resource: string, ...content: TMPNode[]): boolean
  • Create a link to a resource (Not necessarily related to anything).

    example
    const formatted = tb().link("https://google.com", "click here to get tracked.");
    

    Parameters

    • resource: string
    • Rest ...content: TMPNode[]

    Returns boolean

lnheight

  • lnheight(height: string | number, ...content: TMPNode[]): boolean
  • Change the line height of the text.

    example
    const formatted = tb().indent("2em", "I have huge line spacing like a boss.");
    

    Parameters

    • height: string | number
    • Rest ...content: TMPNode[]

    Returns boolean

lnindent

  • lnindent(indentation: string | number, ...content: TMPNode[]): boolean
  • Change only the indentation for the first line of the text.

    example
    const formatted = tb().indent("2em", "Only this line is indented, any other line will not be indented as displayed by this long piece of text.");
    

    Parameters

    • indentation: string | number
    • Rest ...content: TMPNode[]

    Returns boolean

lowercase

  • Force the text to be rendered as lowercase.

    example
    const formatted = tb().lowercase("THIS TEXT WILL BE IN LOWERCASE."):
    

    Parameters

    Returns DocElement

margin

  • margin(amount: string | number, ...content: TMPNode[]): void
  • Change the margin of the text.

    example
    const formatted = tb().margin("5em", "Margin text."):
    

    Parameters

    • amount: string | number
    • Rest ...content: TMPNode[]

    Returns void

mark

  • mark(color: string | [number, number, number, number], ...content: TMPNode[]): void
  • Change the background colour of the text.

    example
    const formatted = tb().mark("00ff00aa", "This text has a green background.");
    

    Or using RGBA:

    const formatted = tb().mark([0, 255, 0, 255], "This text has a green background.");
    

    Parameters

    • color: string | [number, number, number, number]
    • Rest ...content: TMPNode[]

    Returns void

mono

  • Force the text to be rendered monospace.

    example
    const formatted = tb().mono("1em", "console.log('Code block.').");
    

    Parameters

    • spacing: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

nbspace

  • Stop spaces from breaking up text.

    example
    const formatted = tb().nbspace("This text does not B R E A K U P")
    

    Parameters

    Returns DocElement

nextpage

  • Move to the next page.

    example
    const formatted = tb().text("This text").nextpage().text("goes across two pages");
    

    Returns DocElement

pos

  • Change the position of the text on the x axis.

    example
    const formatted = tb().pos("50%", "I am in the middle of the box.");
    

    Parameters

    • x: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

s

  • Create a line through the text.

    example
    const formatted = tb().s("Nevermind");
    

    Parameters

    Returns DocElement

size

  • Change the size of the font.

    example
    const formatted = tb().size("150%", "This text is rather large.");
    

    Parameters

    • size: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

smallcaps

  • Force the text to be rendered as small caps.

    example
    const formatted = tb().smallcaps("This Text Will Be In Small Caps"):
    

    Parameters

    Returns DocElement

space

  • Create a space of a specified size.

    example
    const formatted = tb().text("Huge").space("5em").text("space");
    

    Parameters

    • space: string | number

    Returns DocElement

spacing

  • Change the spacing relative to normal character spacing.

    example
    const formatted = tb().spacing("0.5em", "Spaced out text moment.");
    

    Parameters

    • space: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

st

  • Create a line through the text.

    example
    const formatted = tb().st("Nevermind");
    

    Parameters

    Returns DocElement

strike

  • Create a line through the text.

    example
    const formatted = tb().strike("Nevermind");
    

    Parameters

    Returns DocElement

strikethrough

  • Create a line through the text.

    example
    const formatted = tb().strikethrough("Nevermind");
    

    Parameters

    Returns DocElement

subscript

  • Create a text in subscript.

    example
    const formatted = tb().text("log").subscript("2").text("(8) = 3");
    

    Parameters

    Returns DocElement

superscript

  • Create a text in superscript.

    example
    const formatted = tb().text("6").superscript("2").text(" = 36");
    

    Parameters

    Returns DocElement

text

  • Create a text element.

    example
    const formatted = tb().text("text element like a boss");
    

    Parameters

    • node: TMPNode
    • parse: boolean = false

    Returns DocElement

toString

  • toString(): string
  • Get the representation of the element structure as a string.

    Returns string

underline

  • Create a underline underneath the text.

    example
    const formatted = tb().underline("Important text");
    

    Parameters

    Returns DocElement

uppercase

  • Force the text to be rendered as uppercase.

    example
    const formatted = tb().uppercase("this text will be in lowercase."):
    

    Parameters

    Returns DocElement

voffset

  • Change the vertical offset of the text.

    example
    const formatted = tb().voffset("5em", "This text is high up.").voffset(" and this one is low down.");
    

    Parameters

    • offset: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

width

  • Change the maximum width of the text before wrapping.

    example
    const formatted = tb().width("25%", "This text doesn't go that far :(");
    

    Parameters

    • width: string | number
    • Rest ...content: TMPNode[]

    Returns DocElement

Constructors

constructor

Generated using TypeDoc