Fix bugs across app + server, optimize UI/UX, add Gitea CI
Bug fixes (Flutter):
- Wrap multi-statement DB writes (insert/update/delete note, deleteDocument,
deletePageData, OCR FTS merge, migrations) in transactions to prevent data
loss on interruption and a read-modify-write FTS race.
- Fix PdfDocument leaks on exception (try/finally dispose) and preserve image
aspect ratio when stamping images onto PDF pages.
- Guard file-picker against empty selection (was .single -> crash).
- Fix eraser ConcurrentModificationError and unmodifiable-list crash on PDF
pages; capture page synchronously on save to stop wrong-page data loss.
- Fix Riverpod DB-not-ready races, broken pull-to-refresh, settings load race,
and search N+1; transform stored annotations on PDF page rotation.
- Normalize pen pressure for devices without a pressure range.
- PPT: single source of truth for slide strokes so ink displays and exports.
UI/UX:
- Material 3 typography, theme-aware colors (dark-mode fixes), hover cursors
and right-click/visible actions on desktop, keyboard shortcuts (undo/redo/
save/find), toolbar overflow handling, friendlier empty states, semantic OCR
status badges, relative timestamps, 1-based page indicators, large-deck PPT
navigation, and a scratchpad-scope label in split view.
Server (optional backend):
- Persist JWT secret (was per-process random), block path traversal in storage,
fix CORS '*'+credentials, add OCR job ownership checks, last-writer-wins sync
guard, constant-time login, and split out heavy OCR deps so the API/tests run
without them.
CI: Gitea workflows for format+analyze+test (Linux, system sqlite) and a
Windows release build; pristine `flutter analyze`, all Flutter and server tests
green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:18:00 +08:00
|
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
|
|
|
|
|
|
part 'bookmark.freezed.dart';
|
|
|
|
|
part 'bookmark.g.dart';
|
|
|
|
|
|
2026-06-25 00:00:16 +08:00
|
|
|
/// A saved location in a document.
|
|
|
|
|
///
|
|
|
|
|
/// "Paragraph precision" (user ask: 精确到段落加书签) is expressed by the optional
|
|
|
|
|
/// in-page anchor fields below, all normalized to the page in [0,1]:
|
|
|
|
|
///
|
|
|
|
|
/// * [anchorLeft]/[anchorTop]/[anchorRight]/[anchorBottom] — the bounding rect
|
|
|
|
|
/// of the bookmarked text fragment (the FIRST fragment of the current text
|
|
|
|
|
/// selection), in NORMALIZED page coords with a top-left origin (the same
|
|
|
|
|
/// convention `SidecarHighlight` and the editor's highlight rects use). This
|
|
|
|
|
/// is what jump-to scrolls to (via `goToRectInsidePage`), so the bookmark
|
|
|
|
|
/// lands on the exact paragraph, not just the page top.
|
|
|
|
|
/// * [charIndex] — the character index of the selection start in the page's
|
|
|
|
|
/// `fullText` (the true text-position anchor). Stored for fidelity / future
|
|
|
|
|
/// reflow-tolerant re-anchoring; not currently used for navigation.
|
|
|
|
|
///
|
|
|
|
|
/// When no text was selected the anchor falls back to the tapped point: only
|
|
|
|
|
/// [anchorTop]/[anchorLeft] are set (a zero-size rect) and [charIndex] is null.
|
|
|
|
|
/// All anchor fields are optional and absent from JSON when null, so OLD
|
|
|
|
|
/// bookmarks (page-only) still decode and re-encode unchanged (back-compat).
|
Fix bugs across app + server, optimize UI/UX, add Gitea CI
Bug fixes (Flutter):
- Wrap multi-statement DB writes (insert/update/delete note, deleteDocument,
deletePageData, OCR FTS merge, migrations) in transactions to prevent data
loss on interruption and a read-modify-write FTS race.
- Fix PdfDocument leaks on exception (try/finally dispose) and preserve image
aspect ratio when stamping images onto PDF pages.
- Guard file-picker against empty selection (was .single -> crash).
- Fix eraser ConcurrentModificationError and unmodifiable-list crash on PDF
pages; capture page synchronously on save to stop wrong-page data loss.
- Fix Riverpod DB-not-ready races, broken pull-to-refresh, settings load race,
and search N+1; transform stored annotations on PDF page rotation.
- Normalize pen pressure for devices without a pressure range.
- PPT: single source of truth for slide strokes so ink displays and exports.
UI/UX:
- Material 3 typography, theme-aware colors (dark-mode fixes), hover cursors
and right-click/visible actions on desktop, keyboard shortcuts (undo/redo/
save/find), toolbar overflow handling, friendlier empty states, semantic OCR
status badges, relative timestamps, 1-based page indicators, large-deck PPT
navigation, and a scratchpad-scope label in split view.
Server (optional backend):
- Persist JWT secret (was per-process random), block path traversal in storage,
fix CORS '*'+credentials, add OCR job ownership checks, last-writer-wins sync
guard, constant-time login, and split out heavy OCR deps so the API/tests run
without them.
CI: Gitea workflows for format+analyze+test (Linux, system sqlite) and a
Windows release build; pristine `flutter analyze`, all Flutter and server tests
green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:18:00 +08:00
|
|
|
@freezed
|
|
|
|
|
abstract class Bookmark with _$Bookmark {
|
|
|
|
|
const factory Bookmark({
|
|
|
|
|
required String id,
|
|
|
|
|
required String documentId,
|
2026-06-25 00:00:16 +08:00
|
|
|
|
|
|
|
|
/// 1-based page number this bookmark lives on.
|
Fix bugs across app + server, optimize UI/UX, add Gitea CI
Bug fixes (Flutter):
- Wrap multi-statement DB writes (insert/update/delete note, deleteDocument,
deletePageData, OCR FTS merge, migrations) in transactions to prevent data
loss on interruption and a read-modify-write FTS race.
- Fix PdfDocument leaks on exception (try/finally dispose) and preserve image
aspect ratio when stamping images onto PDF pages.
- Guard file-picker against empty selection (was .single -> crash).
- Fix eraser ConcurrentModificationError and unmodifiable-list crash on PDF
pages; capture page synchronously on save to stop wrong-page data loss.
- Fix Riverpod DB-not-ready races, broken pull-to-refresh, settings load race,
and search N+1; transform stored annotations on PDF page rotation.
- Normalize pen pressure for devices without a pressure range.
- PPT: single source of truth for slide strokes so ink displays and exports.
UI/UX:
- Material 3 typography, theme-aware colors (dark-mode fixes), hover cursors
and right-click/visible actions on desktop, keyboard shortcuts (undo/redo/
save/find), toolbar overflow handling, friendlier empty states, semantic OCR
status badges, relative timestamps, 1-based page indicators, large-deck PPT
navigation, and a scratchpad-scope label in split view.
Server (optional backend):
- Persist JWT secret (was per-process random), block path traversal in storage,
fix CORS '*'+credentials, add OCR job ownership checks, last-writer-wins sync
guard, constant-time login, and split out heavy OCR deps so the API/tests run
without them.
CI: Gitea workflows for format+analyze+test (Linux, system sqlite) and a
Windows release build; pristine `flutter analyze`, all Flutter and server tests
green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:18:00 +08:00
|
|
|
required int pageNumber,
|
|
|
|
|
@Default('') String label,
|
|
|
|
|
@Default(0xFF2196F3) int color,
|
|
|
|
|
required DateTime createdAt,
|
2026-06-25 00:00:16 +08:00
|
|
|
|
|
|
|
|
/// Normalized in-page anchor rect (top-left origin, [0,1]). Null for legacy
|
|
|
|
|
/// page-only bookmarks (and tap-fallback bookmarks set only top/left). Old
|
|
|
|
|
/// page-only bookmark JSON omits these keys; they decode to null and the
|
|
|
|
|
/// data round-trips (back-compat). A re-encoded legacy bookmark gains
|
|
|
|
|
/// explicit null keys, which readers tolerate.
|
|
|
|
|
double? anchorLeft,
|
|
|
|
|
double? anchorTop,
|
|
|
|
|
double? anchorRight,
|
|
|
|
|
double? anchorBottom,
|
|
|
|
|
|
|
|
|
|
/// Character index of the selection start in the page's `fullText`, or null
|
|
|
|
|
/// (tap-fallback / legacy bookmarks).
|
|
|
|
|
int? charIndex,
|
Fix bugs across app + server, optimize UI/UX, add Gitea CI
Bug fixes (Flutter):
- Wrap multi-statement DB writes (insert/update/delete note, deleteDocument,
deletePageData, OCR FTS merge, migrations) in transactions to prevent data
loss on interruption and a read-modify-write FTS race.
- Fix PdfDocument leaks on exception (try/finally dispose) and preserve image
aspect ratio when stamping images onto PDF pages.
- Guard file-picker against empty selection (was .single -> crash).
- Fix eraser ConcurrentModificationError and unmodifiable-list crash on PDF
pages; capture page synchronously on save to stop wrong-page data loss.
- Fix Riverpod DB-not-ready races, broken pull-to-refresh, settings load race,
and search N+1; transform stored annotations on PDF page rotation.
- Normalize pen pressure for devices without a pressure range.
- PPT: single source of truth for slide strokes so ink displays and exports.
UI/UX:
- Material 3 typography, theme-aware colors (dark-mode fixes), hover cursors
and right-click/visible actions on desktop, keyboard shortcuts (undo/redo/
save/find), toolbar overflow handling, friendlier empty states, semantic OCR
status badges, relative timestamps, 1-based page indicators, large-deck PPT
navigation, and a scratchpad-scope label in split view.
Server (optional backend):
- Persist JWT secret (was per-process random), block path traversal in storage,
fix CORS '*'+credentials, add OCR job ownership checks, last-writer-wins sync
guard, constant-time login, and split out heavy OCR deps so the API/tests run
without them.
CI: Gitea workflows for format+analyze+test (Linux, system sqlite) and a
Windows release build; pristine `flutter analyze`, all Flutter and server tests
green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 03:18:00 +08:00
|
|
|
}) = _Bookmark;
|
|
|
|
|
|
|
|
|
|
factory Bookmark.fromJson(Map<String, dynamic> json) =>
|
|
|
|
|
_$BookmarkFromJson(json);
|
|
|
|
|
}
|