ntk 3.7.1 → 3.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/text/layout.js +6 -1
- package/package.json +1 -1
package/lib/text/layout.js
CHANGED
|
@@ -47,7 +47,12 @@ export class TextLayout {
|
|
|
47
47
|
// ---- normalize spans, resolve fonts eagerly ----
|
|
48
48
|
// unknown span fields ride along untouched (widgets attach markers like
|
|
49
49
|
// MarkdownView's _deco/_href and read them back from line runs)
|
|
50
|
-
|
|
50
|
+
// An empty span list is a legitimate thing to lay out — MarkdownView
|
|
51
|
+
// reaches it for a blank paragraph while a document is being typed —
|
|
52
|
+
// and every line still needs a style to take its metrics from, so
|
|
53
|
+
// stand one in rather than crashing on the first empty line.
|
|
54
|
+
const given = typeof content === 'string' ? [{ text: content }] : content;
|
|
55
|
+
const spans = (given.length ? given : [{ text: '' }]).map((s) => {
|
|
51
56
|
const merged = {
|
|
52
57
|
...s,
|
|
53
58
|
text: String(s.text ?? ''),
|