| 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 | /** |