fix: restore PDF pen capture and overhaul sticky/pens/pages
All checks were successful
CI / Windows build (push) Successful in 9m55s

Reinstall PenCaptureBinding so stylus ink hits again; keep finger Listener translucent under pinch; page-anchor sticky with drag/resize; OneNote pen slots (brush+width+color); blank-note multi-page; default side button to hold-select-text.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-07 02:38:58 +08:00
parent ad9b1b46db
commit 307161f465
16 changed files with 1279 additions and 487 deletions

View File

@@ -128,12 +128,38 @@ class SidecarRepository {
}
final file = File('$sourceFilePath$kSidecarSuffix');
final loaded = await SidecarStore.read(file);
final sidecar = loaded ??
var sidecar = loaded ??
BadnoteSidecar(
sourceFile: _basename(sourceFilePath),
docType: docType,
pageCount: docType == 'notebook' ? 1 : null,
createdAt: DateTime.now().toUtc(),
);
// Standalone notebooks always carry an explicit pageCount (min 1). Older
// sidecars that omit it are normalized in-memory on open.
if (docType == 'notebook' &&
(sidecar.pageCount == null || sidecar.pageCount! < 1)) {
sidecar = BadnoteSidecar(
version: sidecar.version,
sourceFile: sidecar.sourceFile,
docType: sidecar.docType,
title: sidecar.title,
pageCount: 1,
rotation: sidecar.rotation,
createdAt: sidecar.createdAt,
updatedAt: sidecar.updatedAt,
strokes: sidecar.strokes,
highlights: sidecar.highlights,
texts: sidecar.texts,
bookmarks: sidecar.bookmarks,
scratchLinks: sidecar.scratchLinks,
legacyAnnotations: sidecar.legacyAnnotations,
ocrText: sidecar.ocrText,
pageText: sidecar.pageText,
legacyId: sidecar.legacyId,
background: sidecar.background,
);
}
final repo = SidecarRepository._(
sourceFilePath: sourceFilePath,
sidecar: sidecar,
@@ -220,6 +246,14 @@ class SidecarRepository {
_replace(strokes: next);
}
/// Replace the standalone-notebook page count and schedule a save. No-op if
/// unchanged. [count] is clamped to at least 1.
void schedulePageCountSave(int count) {
final next = count < 1 ? 1 : count;
if (_sidecar.pageCount == next) return;
_replace(pageCount: next);
}
/// Replace the highlight rects for [pageIndex] and schedule a save.
void scheduleHighlightSave(int pageIndex, List<SidecarHighlight> highlights) {
final next = Map<int, List<SidecarHighlight>>.from(_sidecar.highlights);
@@ -345,6 +379,7 @@ class SidecarRepository {
/// synchronously here so a later edit can't corrupt an in-flight write.
void _replace({
String? title,
int? pageCount,
Map<int, List<EditorStroke>>? strokes,
Map<int, List<SidecarHighlight>>? highlights,
Map<int, List<SidecarText>>? texts,
@@ -362,7 +397,7 @@ class SidecarRepository {
sourceFile: _sidecar.sourceFile,
docType: _sidecar.docType,
title: title ?? _sidecar.title,
pageCount: _sidecar.pageCount,
pageCount: pageCount ?? _sidecar.pageCount,
rotation: _sidecar.rotation,
createdAt: _sidecar.createdAt,
updatedAt: DateTime.now().toUtc(),