feat(pdf): typed-text tool (Windows-Ink friendly)
Some checks failed
CI / Windows build (push) Has been cancelled
Some checks failed
CI / Windows build (push) Has been cancelled
Add a text-annotation tool to the PDF editor. With the text tool a
pen-tap, or a mouse double-click, drops a text box at that normalized
page point and focuses a real Flutter TextField — so the OS IME and the
Windows-Ink handwriting panel feed it (device-validated). Tapping an
existing box re-opens it; clearing it deletes it.
- SidecarText {nx, ny, text, fontSize (page-relative), color} per page,
glued under zoom; stored in the sidecar `texts` field (back-compat
missing -> none), saved via scheduleTextsSave and loaded on open.
- Rendered in pageOverlaysBuilder at the scaled position.
PDF editor only for now (note text later). analyze clean, 397 tests.
This commit is contained in:
@@ -161,6 +161,48 @@ void main() {
|
||||
after.dispose();
|
||||
});
|
||||
|
||||
test('typed-text annotations persist + restore on reopen', () async {
|
||||
final repo = await SidecarRepository.open(src, debounce: _fast);
|
||||
repo.scheduleTextsSave(2, const [
|
||||
SidecarText(
|
||||
id: 'tx1',
|
||||
nx: 0.2,
|
||||
ny: 0.3,
|
||||
text: 'glued note',
|
||||
fontSize: 0.04,
|
||||
color: 0xFF112233,
|
||||
),
|
||||
]);
|
||||
await repo.flush();
|
||||
repo.dispose();
|
||||
|
||||
final after = await SidecarRepository.open(src, debounce: _fast);
|
||||
final t = after.loadedTexts[2]!.single;
|
||||
expect(t.id, 'tx1');
|
||||
expect(t.nx, 0.2);
|
||||
expect(t.ny, 0.3);
|
||||
expect(t.text, 'glued note');
|
||||
expect(t.fontSize, 0.04);
|
||||
expect(t.color, 0xFF112233);
|
||||
after.dispose();
|
||||
});
|
||||
|
||||
test('clearing all text on a page removes the page entry (empty-on-blur)',
|
||||
() async {
|
||||
final repo = await SidecarRepository.open(src, debounce: _fast);
|
||||
repo.scheduleTextsSave(
|
||||
0, const [SidecarText(id: 'a', nx: 0.1, ny: 0.1, text: 'x')]);
|
||||
await repo.flush();
|
||||
// The box is emptied + deleted (empty-on-blur), leaving no texts on page 0.
|
||||
repo.scheduleTextsSave(0, const []);
|
||||
await repo.flush();
|
||||
repo.dispose();
|
||||
|
||||
final after = await SidecarRepository.open(src, debounce: _fast);
|
||||
expect(after.loadedTexts.containsKey(0), isFalse);
|
||||
after.dispose();
|
||||
});
|
||||
|
||||
test('deleting a scratch link removes it and its scratchpad', () async {
|
||||
final repo = await SidecarRepository.open(src, debounce: _fast);
|
||||
repo.scheduleScratchLinkUpsert(const ScratchLink(
|
||||
|
||||
Reference in New Issue
Block a user