Skip to main content

Class: TextElement

Hierarchy​

Constructors​

constructor​

• new TextElement(document, node, captureTextNodes?)

Parameters​

NameType
documentDocument
nodeHTMLElement
captureTextNodes?boolean

Overrides​

RenderedElement.constructor

Defined in​

src/Document/TextElement.ts:26

Properties​

ignoreChildTypes​

â–ª Static Readonly ignoreChildTypes: string[]

Inherited from​

RenderedElement.ignoreChildTypes

Defined in​

src/Document/Element.ts:11


attributes​

• Readonly attributes: Record<string, Property<unknown>> = {}

Inherited from​

RenderedElement.attributes

Defined in​

src/Document/Element.ts:14


styles​

• Readonly styles: Record<string, Property<unknown>> = {}

Inherited from​

RenderedElement.styles

Defined in​

src/Document/Element.ts:15


stylesSpecificity​

• Readonly stylesSpecificity: Record<string, string> = {}

Inherited from​

RenderedElement.stylesSpecificity

Defined in​

src/Document/Element.ts:16


animationFrozen​

• animationFrozen: boolean = false

Inherited from​

RenderedElement.animationFrozen

Defined in​

src/Document/Element.ts:17


animationFrozenValue​

• animationFrozenValue: string = ''

Inherited from​

RenderedElement.animationFrozenValue

Defined in​

src/Document/Element.ts:18


parent​

• parent: Element = null

Inherited from​

RenderedElement.parent

Defined in​

src/Document/Element.ts:19


children​

• children: Element[] = []

Inherited from​

RenderedElement.children

Defined in​

src/Document/Element.ts:20


document​

• Protected Readonly document: Document

Inherited from​

RenderedElement.document

Defined in​

src/Document/Element.ts:23


node​

• Protected Optional Readonly node: HTMLElement

Inherited from​

RenderedElement.node

Defined in​

src/Document/Element.ts:24


captureTextNodes​

• Protected Readonly captureTextNodes: boolean = false

Inherited from​

RenderedElement.captureTextNodes

Defined in​

src/Document/Element.ts:25


type​

• type: string = 'text'

Overrides​

RenderedElement.type

Defined in​

src/Document/TextElement.ts:17


x​

• Protected x: number = 0

Defined in​

src/Document/TextElement.ts:18


y​

• Protected y: number = 0

Defined in​

src/Document/TextElement.ts:19


leafTexts​

• Private leafTexts: TextElement[] = []

Defined in​

src/Document/TextElement.ts:20


textChunkStart​

• Private textChunkStart: number = 0

Defined in​

src/Document/TextElement.ts:21


minX​

• Private minX: number = Number.POSITIVE_INFINITY

Defined in​

src/Document/TextElement.ts:22


maxX​

• Private maxX: number = Number.NEGATIVE_INFINITY

Defined in​

src/Document/TextElement.ts:23


measureCache​

• Private measureCache: number = -1

Defined in​

src/Document/TextElement.ts:24

Methods​

getAttribute​

â–¸ getAttribute(name, createIfNotExists?): Property<unknown>

Parameters​

NameTypeDefault value
namestringundefined
createIfNotExistsbooleanfalse

Returns​

Property<unknown>

Inherited from​

RenderedElement.getAttribute

Defined in​

src/Document/Element.ts:87


getHrefAttribute​

â–¸ getHrefAttribute(): Property<unknown>

Returns​

Property<unknown>

Inherited from​

RenderedElement.getHrefAttribute

Defined in​

src/Document/Element.ts:101


getStyle​

â–¸ getStyle(name, createIfNotExists?, skipAncestors?): Property<unknown>

Parameters​

NameTypeDefault value
namestringundefined
createIfNotExistsbooleanfalse
skipAncestorsbooleanfalse

Returns​

Property<unknown>

Inherited from​

RenderedElement.getStyle

Defined in​

src/Document/Element.ts:114


render​

â–¸ render(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Inherited from​

RenderedElement.render

Defined in​

src/Document/Element.ts:151


applyEffects​

â–¸ Protected applyEffects(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Inherited from​

RenderedElement.applyEffects

Defined in​

src/Document/Element.ts:190


addChild​

â–¸ Protected addChild(childNode): void

Parameters​

NameType
childNodeHTMLElement | Element

Returns​

void

Inherited from​

RenderedElement.addChild

Defined in​

src/Document/Element.ts:220


matchesSelector​

â–¸ Protected matchesSelector(selector): boolean

Parameters​

NameType
selectorstring

Returns​

boolean

Inherited from​

RenderedElement.matchesSelector

Defined in​

src/Document/Element.ts:232


addStylesFromStyleDefinition​

â–¸ addStylesFromStyleDefinition(): void

Returns​

void

Inherited from​

RenderedElement.addStylesFromStyleDefinition

Defined in​

src/Document/Element.ts:248


removeStyles​

â–¸ Protected removeStyles(element, ignoreStyles): [string, string][]

Parameters​

NameType
elementElement
ignoreStylesstring[]

Returns​

[string, string][]

Inherited from​

RenderedElement.removeStyles

Defined in​

src/Document/Element.ts:283


restoreStyles​

â–¸ Protected restoreStyles(element, styles): void

Parameters​

NameType
elementElement
styles[string, string][]

Returns​

void

Inherited from​

RenderedElement.restoreStyles

Defined in​

src/Document/Element.ts:301


isFirstChild​

â–¸ isFirstChild(): boolean

Returns​

boolean

Inherited from​

RenderedElement.isFirstChild

Defined in​

src/Document/Element.ts:307


calculateOpacity​

â–¸ Protected calculateOpacity(): number

Returns​

number

Inherited from​

RenderedElement.calculateOpacity

Defined in​

src/Document/RenderedElement.ts:13


clearContext​

â–¸ clearContext(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Inherited from​

RenderedElement.clearContext

Defined in​

src/Document/RenderedElement.ts:215


setContext​

â–¸ setContext(ctx, fromMeasure?): void

Parameters​

NameTypeDefault value
ctxRenderingContext2Dundefined
fromMeasurebooleanfalse

Returns​

void

Overrides​

RenderedElement.setContext

Defined in​

src/Document/TextElement.ts:40


initializeCoordinates​

â–¸ Protected initializeCoordinates(): void

Returns​

void

Defined in​

src/Document/TextElement.ts:51


getBoundingBox​

â–¸ getBoundingBox(ctx): BoundingBox

Parameters​

NameType
ctxRenderingContext2D

Returns​

BoundingBox

Defined in​

src/Document/TextElement.ts:60


getFontSize​

â–¸ Protected getFontSize(): number

Returns​

number

Defined in​

src/Document/TextElement.ts:85


getTElementBoundingBox​

â–¸ Protected getTElementBoundingBox(ctx): BoundingBox

Parameters​

NameType
ctxRenderingContext2D

Returns​

BoundingBox

Defined in​

src/Document/TextElement.ts:96


getGlyph​

â–¸ getGlyph(font, text, i): GlyphElement

Parameters​

NameType
fontFontElement
textstring
inumber

Returns​

GlyphElement

Defined in​

src/Document/TextElement.ts:107


getText​

â–¸ getText(): string

Returns​

string

Defined in​

src/Document/TextElement.ts:145


getTextFromNode​

â–¸ Protected getTextFromNode(node?): string

Parameters​

NameType
node?ChildNode

Returns​

string

Defined in​

src/Document/TextElement.ts:149


renderChildren​

â–¸ renderChildren(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Overrides​

RenderedElement.renderChildren

Defined in​

src/Document/TextElement.ts:172


renderTElementChildren​

â–¸ Protected renderTElementChildren(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Defined in​

src/Document/TextElement.ts:198


applyAnchoring​

â–¸ Protected applyAnchoring(): void

Returns​

void

Defined in​

src/Document/TextElement.ts:277


adjustChildCoordinatesRecursive​

â–¸ Protected adjustChildCoordinatesRecursive(ctx): void

Parameters​

NameType
ctxRenderingContext2D

Returns​

void

Defined in​

src/Document/TextElement.ts:309


adjustChildCoordinatesRecursiveCore​

â–¸ Protected adjustChildCoordinatesRecursiveCore(ctx, textParent, parent, i): void

Parameters​

NameType
ctxRenderingContext2D
textParentTextElement
parentElement
inumber

Returns​

void

Defined in​

src/Document/TextElement.ts:316


adjustChildCoordinates​

â–¸ Protected adjustChildCoordinates(ctx, textParent, parent, i): TextElement

Parameters​

NameType
ctxRenderingContext2D
textParentTextElement
parentElement
inumber

Returns​

TextElement

Defined in​

src/Document/TextElement.ts:334


getChildBoundingBox​

â–¸ Protected getChildBoundingBox(ctx, textParent, parent, i): BoundingBox

Parameters​

NameType
ctxRenderingContext2D
textParentTextElement
parentElement
inumber

Returns​

BoundingBox

Defined in​

src/Document/TextElement.ts:432


renderChild​

â–¸ Protected renderChild(ctx, textParent, parent, i): void

Parameters​

NameType
ctxRenderingContext2D
textParentTextElement
parentElement
inumber

Returns​

void

Defined in​

src/Document/TextElement.ts:458


measureText​

â–¸ Protected measureText(ctx): number

Parameters​

NameType
ctxRenderingContext2D

Returns​

number

Defined in​

src/Document/TextElement.ts:472


measureTargetText​

â–¸ Protected measureTargetText(ctx, targetText): number

Parameters​

NameType
ctxRenderingContext2D
targetTextstring

Returns​

number

Defined in​

src/Document/TextElement.ts:487


getInheritedAttribute​

â–¸ Protected getInheritedAttribute(name): string

Inherits positional attributes from TextElement parent(s). Attributes are only inherited from a parent to its first child.

Parameters​

NameTypeDescription
namestringThe attribute name.

Returns​

string

The attribute value or null.

Defined in​

src/Document/TextElement.ts:544