MCPcopy Create free account
hub / github.com/SplootCode/splootcode / getStringPreHeight

Function getStringPreHeight

packages/editor/src/layout/layout_constants.ts:36–47  ·  view source on GitHub ↗
(text: string, maxWidth: number)

Source from the content-addressed store, hash-verified

34}
35
36export function getStringPreHeight(text: string, maxWidth: number) {
37 let pre: HTMLPreElement = getStringPreHeight['pre']
38 if (!pre) {
39 pre = document.createElement('pre')
40 pre.classList.add('string-node', 'measurement')
41 pre.style.maxWidth = MAX_STRING_WIDTH + 'px'
42 document.body.appendChild(pre)
43 getStringPreHeight['pre'] = pre
44 }
45 pre.textContent = text
46 return pre.getBoundingClientRect().height
47}
48
49export function stringWidth(s: string) {
50 return getTextWidth(s, "16px 'Karla'")

Callers 1

stringLiteralDimensionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected