MCPcopy
hub / github.com/midrender/revideo / updateLayout

Method updateLayout

packages/2d/src/lib/components/TxtLeaf.ts:141–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139 }
140
141 protected override updateLayout() {
142 this.applyFont();
143 this.applyFlex();
144
145 // Make sure the text is aligned correctly even if the text is smaller than
146 // the container.
147 if (this.justifyContent.isInitial()) {
148 this.element.style.justifyContent =
149 this.styles.getPropertyValue('text-align');
150 }
151
152 const wrap =
153 this.styles.whiteSpace !== 'nowrap' && this.styles.whiteSpace !== 'pre';
154
155 if (wrap) {
156 this.element.innerText = '';
157
158 if (TxtLeaf.segmenter) {
159 for (const word of TxtLeaf.segmenter.segment(this.text())) {
160 this.element.appendChild(document.createTextNode(word.segment));
161 }
162 } else {
163 for (const word of this.text().split('')) {
164 this.element.appendChild(document.createTextNode(word));
165 }
166 }
167 } else if (this.styles.whiteSpace === 'pre') {
168 this.element.innerText = '';
169 for (const line of this.text().split('\n')) {
170 this.element.appendChild(document.createTextNode(line + '\n'));
171 }
172 } else {
173 this.element.innerText = this.text();
174 }
175 }
176}
177
178/**

Callers

nothing calls this directly

Calls 5

applyFlexMethod · 0.95
applyFontMethod · 0.80
isInitialMethod · 0.65
segmentMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected