@aionbuilders/nabu 0.1.5 → 0.1.6
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/CHANGELOG.md +12 -2
- package/dist/behaviors/text/text.behavior.svelte.d.ts +15 -10
- package/dist/behaviors/text/text.behavior.svelte.js +41 -50
- package/dist/blocks/BlockList.svelte +12 -2
- package/dist/blocks/BlockList.svelte.d.ts +5 -1
- package/dist/blocks/nabu.svelte.js +14 -11
- package/dist/blocks/region/Region.svelte +19 -10
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.1.6 (2026-11-15)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Two browser fixes: IME compositions in Firefox, and typing in long documents on WebKit. No API change.
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Firefox: the text froze after an IME composition in an empty block.** Firefox puts the composed text in a new text node, and Svelte went on updating the old one: what was typed next reached the model but not the screen, and the caret jumped to the start. The block's render now goes back as Svelte left it when a composition ends, and the model shows the composed text through it. This covers every browser and every text block, including code blocks.
|
|
9
|
+
- **WebKit: typing in the middle of a long document with nested regions took ~400 ms per key.** In a large document every region body was skipped off screen with `content-visibility: auto`, and WebKit pays on every frame for such boxes nested inside each other. Only the innermost region bodies are skipped now, never one inside another. On a 90,000-word novel (parts, chapters, scenes), a key in the middle takes 22 ms instead of ~390 ms on WebKitGTK, and Chromium does not change.
|
|
10
|
+
- **Composed text ignored the bold you had switched on, and could show twice.** A composition now gets the same marks as typed text: the marks you switched on, and the rule for mark edges. At the end of a bold run, the composed text showed both in the run and after it.
|
|
11
|
+
|
|
12
|
+
### Tests
|
|
13
|
+
- `bun run test:consumer` packs the package as npm would publish it, installs the tarball in a fresh SvelteKit app, builds it and checks on Chromium, Firefox and WebKit that the editor boots and takes typing on an SSR, a client-only, a lazy and a server-built page. It catches what only a consumer sees (a change to how Loro's WASM is loaded broke a client-only route on WebKit while every other test was green).
|
|
14
|
+
- A `firefox` Playwright project (`tests/e2e/firefox`) drives compositions on the real browser. Run `bunx playwright install firefox` once. `core` still runs on Chromium only.
|
|
15
|
+
- `tests/e2e/large-docs-auto-boxes.spec.ts` checks that no skipped box is ever inside another. A `perf-webkit` project, run on demand, types in the middle of a 90,000-word novel and fails above 60 ms per key at the median.
|
|
6
16
|
|
|
7
17
|
## 0.1.5 (2026-11-04)
|
|
8
18
|
|
|
@@ -71,20 +71,19 @@ export class TextBehavior {
|
|
|
71
71
|
*/
|
|
72
72
|
modelOffset(node: Node, offset: number, element?: HTMLElement | null): number;
|
|
73
73
|
/**
|
|
74
|
-
* IME composition starts.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* additions at the end. No filler: nothing to do.
|
|
74
|
+
* IME composition starts. The browser owns the DOM until it ends, and what it does there is not known to Svelte: it may put the
|
|
75
|
+
* composed text in a NEW text node (Firefox, in an empty block), swap a node for a `<br>`, or write it into a run the model
|
|
76
|
+
* will not give it to (the end of a bold run). Remember the render so {@link TextBehavior#restoreAfterComposition} can put it back.
|
|
77
|
+
* Nested blocks and UI are not this block's render: the walk stops at them.
|
|
79
78
|
*/
|
|
80
79
|
snapshotForComposition(): void;
|
|
81
80
|
/**
|
|
82
|
-
* End of a composition
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
81
|
+
* End of a composition, BEFORE the composed text reaches the model: the render goes back as Svelte left it, and the model shows
|
|
82
|
+
* the composed text through it on the next render, in the run it really belongs to. Without this Svelte updates nodes that are
|
|
83
|
+
* no longer in the page (the DOM freezes while the model moves on), or the text shows twice.
|
|
84
|
+
* If the model changed meanwhile (a programmatic edit), Svelte has already rendered over the snapshot: it stays as it is.
|
|
86
85
|
*/
|
|
87
|
-
restoreAfterComposition(
|
|
86
|
+
restoreAfterComposition(): void;
|
|
88
87
|
/**
|
|
89
88
|
* @param {InputEvent} event
|
|
90
89
|
* @param {ReturnType<TextBehavior["getSelection"]>} [selection]
|
|
@@ -93,6 +92,12 @@ export class TextBehavior {
|
|
|
93
92
|
public handleBeforeInput(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): any;
|
|
94
93
|
/** @param {InputEvent} event @param {ReturnType<TextBehavior["getSelection"]>} [selection] */
|
|
95
94
|
handleInsertText(event: InputEvent, selection?: ReturnType<TextBehavior["getSelection"]>): true | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* The marks of a run the user just typed or composed at `[from, from + length)`: the cursor's pending stored marks, then the rule
|
|
97
|
+
* for mark edges.
|
|
98
|
+
* @param {number} from @param {number} length
|
|
99
|
+
*/
|
|
100
|
+
markTypedRun(from: number, length: number): void;
|
|
96
101
|
/**
|
|
97
102
|
* Make the run just typed at `[from, from + length)` follow Nabu's rule for mark edges (see mark-edges.js): it keeps a mark only
|
|
98
103
|
* when the character before and the one after both carry it. The corrections are made now, so they belong to the same commit
|
|
@@ -154,65 +154,48 @@ export class TextBehavior {
|
|
|
154
154
|
return this.nabu.composing ? at : Math.min(at, this.text.length);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
/** The render of
|
|
158
|
-
#emptySnapshot = null;
|
|
159
|
-
|
|
160
|
-
/** Svelte's own nodes around a trailing render filler when an IME composition started: its text nodes and the filler with its place. @type {{ texts: Set<Node>, filler: Element, parent: Node, next: Node | null } | null} */
|
|
157
|
+
/** The render of the block when an IME composition started: its elements with their children, its text nodes with their text, and the model text it shows. @type {{ text: string, children: Map<Node, Node[]>, data: Map<Text, string> } | null} */
|
|
161
158
|
#compositionSnapshot = null;
|
|
162
159
|
|
|
163
160
|
/**
|
|
164
|
-
* IME composition starts.
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* additions at the end. No filler: nothing to do.
|
|
161
|
+
* IME composition starts. The browser owns the DOM until it ends, and what it does there is not known to Svelte: it may put the
|
|
162
|
+
* composed text in a NEW text node (Firefox, in an empty block), swap a node for a `<br>`, or write it into a run the model
|
|
163
|
+
* will not give it to (the end of a bold run). Remember the render so {@link TextBehavior#restoreAfterComposition} can put it back.
|
|
164
|
+
* Nested blocks and UI are not this block's render: the walk stops at them.
|
|
169
165
|
*/
|
|
170
166
|
snapshotForComposition() {
|
|
171
167
|
const element = this.block.element;
|
|
172
168
|
this.#compositionSnapshot = null;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
if (!element) return;
|
|
170
|
+
/** @type {Map<Node, Node[]>} */
|
|
171
|
+
const children = new Map([[element, [...element.childNodes]]]);
|
|
172
|
+
/** @type {Map<Text, string>} */
|
|
173
|
+
const data = new Map();
|
|
174
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, {
|
|
175
|
+
acceptNode: (n) => n.nodeType === Node.ELEMENT_NODE && (/** @type {Element} */ (n).hasAttribute('data-block-id') || /** @type {Element} */ (n).hasAttribute('data-nabu-ui')) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT,
|
|
176
|
+
});
|
|
177
|
+
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
|
|
178
|
+
if (n.nodeType === Node.TEXT_NODE) data.set(/** @type {Text} */ (n), /** @type {Text} */ (n).data);
|
|
179
|
+
else children.set(n, [...n.childNodes]);
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
-
if (!element || !filler?.parentNode) return;
|
|
182
|
-
const texts = new Set();
|
|
183
|
-
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
184
|
-
for (let n = walker.nextNode(); n; n = walker.nextNode()) texts.add(n);
|
|
185
|
-
this.#compositionSnapshot = { texts, filler, parent: filler.parentNode, next: filler.nextSibling };
|
|
181
|
+
this.#compositionSnapshot = { text: this.text, children, data };
|
|
186
182
|
}
|
|
187
183
|
|
|
188
184
|
/**
|
|
189
|
-
* End of a composition
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
185
|
+
* End of a composition, BEFORE the composed text reaches the model: the render goes back as Svelte left it, and the model shows
|
|
186
|
+
* the composed text through it on the next render, in the run it really belongs to. Without this Svelte updates nodes that are
|
|
187
|
+
* no longer in the page (the DOM freezes while the model moves on), or the text shows twice.
|
|
188
|
+
* If the model changed meanwhile (a programmatic edit), Svelte has already rendered over the snapshot: it stays as it is.
|
|
193
189
|
*/
|
|
194
|
-
restoreAfterComposition(
|
|
190
|
+
restoreAfterComposition() {
|
|
195
191
|
const snap = this.#compositionSnapshot;
|
|
196
192
|
this.#compositionSnapshot = null;
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Canceled in an empty block: the render text node (not a browser <br>) with its text, as Svelte left it.
|
|
202
|
-
element.replaceChildren(...empty.nodes);
|
|
203
|
-
empty.nodes.forEach((n, i) => { if (n.nodeType === Node.TEXT_NODE && /** @type {Text} */ (n).data !== empty.data[i]) /** @type {Text} */ (n).data = empty.data[i]; });
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (!snap || !element) return;
|
|
207
|
-
/** @type {Node[]} */
|
|
208
|
-
const stray = [];
|
|
209
|
-
const walker = document.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
210
|
-
for (let n = walker.nextNode(); n; n = walker.nextNode()) if (!snap.texts.has(n)) stray.push(n);
|
|
211
|
-
for (const br of element.querySelectorAll('br')) if (br !== snap.filler) stray.push(br);
|
|
212
|
-
for (const n of stray) n.parentNode?.removeChild(n);
|
|
213
|
-
if (!composedText && !snap.filler.isConnected) {
|
|
214
|
-
snap.parent.insertBefore(snap.filler, snap.next?.parentNode === snap.parent ? snap.next : null);
|
|
193
|
+
if (!snap || this.text !== snap.text) return;
|
|
194
|
+
for (const [parent, nodes] of snap.children) {
|
|
195
|
+
const now = parent.childNodes;
|
|
196
|
+
if (now.length !== nodes.length || nodes.some((n, i) => n !== now[i])) /** @type {Element} */ (parent).replaceChildren(...nodes);
|
|
215
197
|
}
|
|
198
|
+
for (const [node, data] of snap.data) if (node.data !== data) node.data = data;
|
|
216
199
|
}
|
|
217
200
|
|
|
218
201
|
/**
|
|
@@ -323,18 +306,26 @@ export class TextBehavior {
|
|
|
323
306
|
|
|
324
307
|
if (!selection.isCollapsed) this.delete({index: selection.from, length: selection.to - selection.from}, selection);
|
|
325
308
|
this.insert(selection.from, textToInsert);
|
|
326
|
-
|
|
309
|
+
this.markTypedRun(selection.from, textToInsert.length);
|
|
310
|
+
this.block.commit();
|
|
311
|
+
tick().then(() => this.nabu.selection.setCursor(this.block, selection.from + textToInsert.length));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The marks of a run the user just typed or composed at `[from, from + length)`: the cursor's pending stored marks, then the rule
|
|
316
|
+
* for mark edges.
|
|
317
|
+
* @param {number} from @param {number} length
|
|
318
|
+
*/
|
|
319
|
+
markTypedRun(from, length) {
|
|
327
320
|
const stored = this.nabu.storedMarks;
|
|
328
|
-
if (stored &&
|
|
329
|
-
const range = { from
|
|
321
|
+
if (stored && length) {
|
|
322
|
+
const range = { from, to: from + length, isCollapsed: false };
|
|
330
323
|
for (const [name, on] of Object.entries(stored)) {
|
|
331
324
|
if (on) this.applyMark(name, true, range);
|
|
332
325
|
else this.removeMark(name, range);
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
|
-
this.settleMarkEdges(
|
|
336
|
-
this.block.commit();
|
|
337
|
-
tick().then(() => this.nabu.selection.setCursor(this.block, selection.from + textToInsert.length));
|
|
328
|
+
this.settleMarkEdges(from, length, stored);
|
|
338
329
|
}
|
|
339
330
|
|
|
340
331
|
/**
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* after the other, with no markup of their own. A long one (`CHUNK_ON` blocks and more) is rendered in chunks of ~64 blocks, each
|
|
8
8
|
* in a wrapper that the browser may skip while it is off screen (`content-visibility: auto`), which is what keeps a keystroke
|
|
9
9
|
* in a 10,000-block document within a frame (see chunks.js for the why and the how).
|
|
10
|
-
*
|
|
10
|
+
* `chunked` (bindable, read only for the parent) reports whether the list is rendered in chunks: a region body that is, leaves
|
|
11
|
+
* the skipping to its chunks (Region.svelte).
|
|
12
|
+
* @type {{ blocks: import('./block.svelte.js').Block[], chunked?: boolean }}
|
|
11
13
|
*/
|
|
12
|
-
let { blocks } = $props();
|
|
14
|
+
let { blocks, chunked: isChunked = $bindable(false) } = $props();
|
|
13
15
|
|
|
14
16
|
// Hysteresis: switches on at CHUNK_ON blocks, off under CHUNK_OFF. (Plain variable on purpose: it is only read back by this derived.)
|
|
15
17
|
let was = false;
|
|
@@ -18,6 +20,8 @@
|
|
|
18
20
|
return was && supportsChunking();
|
|
19
21
|
});
|
|
20
22
|
|
|
23
|
+
$effect.pre(() => { isChunked = chunked; });
|
|
24
|
+
|
|
21
25
|
// The chunks of the last render, to hand back the unchanged ones as they were.
|
|
22
26
|
let memo = new Map();
|
|
23
27
|
const chunks = $derived.by(() => {
|
|
@@ -42,6 +46,12 @@
|
|
|
42
46
|
overflow-clip-margin: var(--nb-clip-margin, 3rem);
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
/* Never nested (see the large documents note in region/Region.svelte: WebKit pays for it on every keystroke): a chunk inside a chunk
|
|
50
|
+
(a region body of 500 blocks among the blocks of a chunk) is left visible, the outer one already skips what it holds. */
|
|
51
|
+
.nabu-chunk :global(.nabu-chunk) {
|
|
52
|
+
content-visibility: visible;
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
@media print {
|
|
46
56
|
.nabu-chunk { content-visibility: visible; }
|
|
47
57
|
}
|
|
@@ -5,13 +5,17 @@ type BlockList = {
|
|
|
5
5
|
};
|
|
6
6
|
declare const BlockList: import("svelte").Component<{
|
|
7
7
|
blocks: import("./block.svelte.js").Block[];
|
|
8
|
-
|
|
8
|
+
chunked?: boolean;
|
|
9
|
+
}, {}, "chunked">;
|
|
9
10
|
/**
|
|
10
11
|
* A list of sibling blocks: the root of the editor, the body of a region. Short lists are rendered as they are, one block
|
|
11
12
|
* after the other, with no markup of their own. A long one (`CHUNK_ON` blocks and more) is rendered in chunks of ~64 blocks, each
|
|
12
13
|
* in a wrapper that the browser may skip while it is off screen (`content-visibility: auto`), which is what keeps a keystroke
|
|
13
14
|
* in a 10,000-block document within a frame (see chunks.js for the why and the how).
|
|
15
|
+
* `chunked` (bindable, read only for the parent) reports whether the list is rendered in chunks: a region body that is, leaves
|
|
16
|
+
* the skipping to its chunks (Region.svelte).
|
|
14
17
|
*/
|
|
15
18
|
type $$ComponentProps = {
|
|
16
19
|
blocks: import("./block.svelte.js").Block[];
|
|
20
|
+
chunked?: boolean;
|
|
17
21
|
};
|
|
@@ -1480,11 +1480,10 @@ export class Nabu {
|
|
|
1480
1480
|
if (this.#readonly && !this.#composing) return;
|
|
1481
1481
|
this.#composing = false;
|
|
1482
1482
|
const composedIn = this.#compositionStartBlock?.behaviors?.get('text');
|
|
1483
|
-
const composedBlock = this.#compositionStartBlock;
|
|
1484
1483
|
this.#composingBlock = null;
|
|
1485
1484
|
restoreEmptyBlocks(this.#swappedEmpties);
|
|
1486
1485
|
this.#swappedEmpties = [];
|
|
1487
|
-
/** @type {any} */ (composedIn)?.restoreAfterComposition?.(
|
|
1486
|
+
/** @type {any} */ (composedIn)?.restoreAfterComposition?.(); // before the model catches up: no duplicate of the composed text
|
|
1488
1487
|
try {
|
|
1489
1488
|
this.#syncComposition(e);
|
|
1490
1489
|
} finally {
|
|
@@ -1492,11 +1491,6 @@ export class Nabu {
|
|
|
1492
1491
|
}
|
|
1493
1492
|
this.selection.normalize(); // a dead caret must not survive the composition
|
|
1494
1493
|
this.#revealSoon();
|
|
1495
|
-
// A canceled composition in an EMPTY block: its render is back (restoreAfterComposition), so is the caret.
|
|
1496
|
-
if (!(e.data || '') && composedBlock && composedBlock.element?.isConnected && !composedIn?.text) {
|
|
1497
|
-
this.selection.setCursor(composedBlock, 0);
|
|
1498
|
-
tick().then(() => { if (!this.#composing && composedBlock.element?.isConnected && !composedIn?.text) this.selection.setCursor(composedBlock, 0); });
|
|
1499
|
-
}
|
|
1500
1494
|
}
|
|
1501
1495
|
|
|
1502
1496
|
/** @param {CompositionEvent} e */
|
|
@@ -1519,10 +1513,6 @@ export class Nabu {
|
|
|
1519
1513
|
const behavior = block.behaviors?.get('text');
|
|
1520
1514
|
if (!behavior) return;
|
|
1521
1515
|
|
|
1522
|
-
// Canceled composition (Escape) fires compositionend with e.data === ''.
|
|
1523
|
-
const composedText = e.data || '';
|
|
1524
|
-
if (!composedText) return;
|
|
1525
|
-
|
|
1526
1516
|
// Where the composition began NOW: the Loro cursors followed every edit of this text made meanwhile (P-101).
|
|
1527
1517
|
if (anchor) {
|
|
1528
1518
|
const moved = resolveOffset(this.doc, anchor, behavior.container.length);
|
|
@@ -1530,7 +1520,20 @@ export class Nabu {
|
|
|
1530
1520
|
}
|
|
1531
1521
|
startOffset = Math.max(0, Math.min(startOffset, behavior.container.length));
|
|
1532
1522
|
|
|
1523
|
+
// Canceled composition (Escape) fires compositionend with e.data === ''. The render is back (restoreAfterComposition), and the
|
|
1524
|
+
// caret with it, unless the user went to another block.
|
|
1525
|
+
const composedText = e.data || '';
|
|
1526
|
+
if (!composedText) {
|
|
1527
|
+
const at = startOffset;
|
|
1528
|
+
this.selection.sync();
|
|
1529
|
+
if (this.selection.anchorBlock !== block) return;
|
|
1530
|
+
this.selection.setCursor(block, at);
|
|
1531
|
+
tick().then(() => { if (!this.#composing && block.element?.isConnected && this.selection.anchorBlock === block) this.selection.setCursor(block, at); });
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1533
1535
|
behavior.insert(startOffset, composedText);
|
|
1536
|
+
behavior.markTypedRun?.(startOffset, composedText.length); // the same marks as if it had been typed
|
|
1534
1537
|
block.commit();
|
|
1535
1538
|
const caret = startOffset + composedText.length;
|
|
1536
1539
|
tick().then(() => {
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
// A large document (Nabu.svelte sets `data-nabu-large` on the root): the body is skipped by the browser while off screen, see the style below.
|
|
13
13
|
const large = $derived(block.nabu.blocks.size >= LARGE_DOC);
|
|
14
|
+
// A LEAF body (no region among its direct children) is the only one the browser may skip, see the style below. Reactive: a region
|
|
15
|
+
// dropped into the body, or the last one taken out, flips it. A body rendered in chunks (reported by its BlockList) leaves it to them.
|
|
16
|
+
const leaf = $derived(!block.children.some((child) => child.type === 'region'));
|
|
17
|
+
let chunked = $state(false);
|
|
14
18
|
const region = $derived(Regions.get(block.nabu).of(block));
|
|
15
19
|
const level = $derived(Math.min(6, Math.max(1, region?.level ?? 1)));
|
|
16
20
|
// The label template applied with an EMPTY title ("1.", "1.1", "Chapter 2"): the editable title follows it.
|
|
@@ -83,22 +87,27 @@
|
|
|
83
87
|
data-block-type="region"
|
|
84
88
|
data-nabu-isolated
|
|
85
89
|
data-placeholder={block.placeholder}
|
|
86
|
-
><RichText delta={block.delta} /></div><span class="nabu-region-rule" data-nabu-ui contenteditable="false" aria-hidden="true">{#if pending}<span class="nabu-region-drain"></span>{/if}</span></div><div class="nabu-region-body" style:--nb-region-blocks={large ? block.weight : undefined}><BlockList blocks={block.children} /></div>{#if endText}<!-- Never a caret stop (not editable, not selectable) and not read as text: a separator named by the same sentence. --><div class="nabu-region-end" data-region-end data-nabu-ui contenteditable="false" role="separator" aria-label={endText}><span class="nabu-region-end-rule" aria-hidden="true"></span><span class="nabu-region-end-text" aria-hidden="true">{endText}</span></div>{/if}</div>
|
|
90
|
+
><RichText delta={block.delta} /></div><span class="nabu-region-rule" data-nabu-ui contenteditable="false" aria-hidden="true">{#if pending}<span class="nabu-region-drain"></span>{/if}</span></div><div class="nabu-region-body" data-region-leaf={leaf && !chunked ? '' : undefined} style:--nb-region-blocks={large ? block.weight : undefined}><BlockList blocks={block.children} bind:chunked /></div>{#if endText}<!-- Never a caret stop (not editable, not selectable) and not read as text: a separator named by the same sentence. --><div class="nabu-region-end" data-region-end data-nabu-ui contenteditable="false" role="separator" aria-label={endText}><span class="nabu-region-end-rule" aria-hidden="true"></span><span class="nabu-region-end-text" aria-hidden="true">{endText}</span></div>{/if}</div>
|
|
87
91
|
|
|
88
92
|
<style>
|
|
89
93
|
/* ── Large documents ── In a large document (`data-nabu-large`, 800 blocks) the body of a region is skipped by the browser while it is off screen
|
|
90
94
|
(`content-visibility: auto`): its layout, paint and selection bookkeeping no longer grow with the size of the document, which is
|
|
91
95
|
what keeps a keystroke within a frame at 10,000 blocks. Until it has been shown once its height is an estimate (its number of
|
|
92
|
-
blocks times --nb-block-estimate, 72px); `auto` then remembers the real one. A small document is left exactly as it was.
|
|
93
|
-
:global(.nabu-editor[data-nabu-large]) .nabu-region-body {
|
|
94
|
-
content-visibility: auto;
|
|
95
|
-
contain-intrinsic-block-size: auto calc(var(--nb-region-blocks, 16) * var(--nb-block-estimate, 72px));
|
|
96
|
-
/* ...and what it contains may hang out of its box (the margin rail of a sub-region): paint containment would clip it. */
|
|
97
|
-
overflow-clip-margin: var(--nb-clip-margin, 3rem);
|
|
98
|
-
}
|
|
96
|
+
blocks times --nb-block-estimate, 72px); `auto` then remembers the real one. A small document is left exactly as it was.
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
Never nested: an `auto` box must neither contain nor sit inside another one. WebKit pays for the nesting on every keystroke
|
|
99
|
+
(a novel of nested parts > chapters > scenes, caret mid-document: ~380 ms per key at 90,000 words with every body `auto`; 34-40 ms
|
|
100
|
+
with every body visible; 23-26 ms at 90k and 28-30 ms at 150k with `auto` on the LEAF bodies only, flat with the size; `auto` on the
|
|
101
|
+
non-leaf bodies only is as slow as all of them; Chromium is at 9-12 ms either way). So only a leaf body (`data-region-leaf`: no region
|
|
102
|
+
among its children, not itself rendered in chunks, whose `.nabu-chunk` boxes are the `auto` ones then) is skipped, and not when it already
|
|
103
|
+
sits inside a chunk, which skips what it holds. (BlockList.svelte keeps chunks out of chunks the same way.) */
|
|
104
|
+
@media not print {
|
|
105
|
+
:global(.nabu-editor[data-nabu-large] .nabu-region-body[data-region-leaf]:not(.nabu-chunk .nabu-region-body)) {
|
|
106
|
+
content-visibility: auto;
|
|
107
|
+
contain-intrinsic-block-size: auto calc(var(--nb-region-blocks, 16) * var(--nb-block-estimate, 72px));
|
|
108
|
+
/* ...and what it contains may hang out of its box (the margin rail of a sub-region): paint containment would clip it. */
|
|
109
|
+
overflow-clip-margin: var(--nb-clip-margin, 3rem);
|
|
110
|
+
}
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
/* ── Margin rail: the region that holds the caret (data-region-caret), from its seam to the end of its body ── */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aionbuilders/nabu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"predev": "npm run api:model:ensure",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"build:e2e": "npm run api:model && VITE_NABU_E2E=1 vite build",
|
|
19
19
|
"test:e2e": "playwright test",
|
|
20
20
|
"test:e2e:dev": "NABU_E2E_DEV=1 playwright test",
|
|
21
|
+
"test:consumer": "node scripts/consumer-smoke.js",
|
|
21
22
|
"test": "bun run test:unit && bun run test:e2e"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|