Add support for annotations and book notes in the new ebook reader (#2313)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-17 22:36:00 -07:00
committed by GitHub
co-authored by acx10
parent d75e7e228a
commit e5b1d33bf7
79 changed files with 7481 additions and 1806 deletions
@@ -0,0 +1,61 @@
import {Injectable, inject} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {API_CONFIG} from '../../core/config/api-config';
export type AnnotationStyle = 'highlight' | 'underline' | 'strikethrough' | 'squiggly';
export interface Annotation {
id: number;
userId?: number;
bookId: number;
cfi: string;
text: string;
color: string;
style: AnnotationStyle;
note?: string;
chapterTitle?: string;
createdAt: string;
updatedAt?: string;
}
export interface CreateAnnotationRequest {
bookId: number;
cfi: string;
text: string;
color?: string;
style?: AnnotationStyle;
note?: string;
chapterTitle?: string;
}
export interface UpdateAnnotationRequest {
color?: string;
style?: AnnotationStyle;
note?: string;
}
@Injectable({
providedIn: 'root'
})
export class AnnotationService {
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/annotations`;
private readonly http = inject(HttpClient);
getAnnotationsForBook(bookId: number): Observable<Annotation[]> {
return this.http.get<Annotation[]>(`${this.url}/book/${bookId}`);
}
createAnnotation(request: CreateAnnotationRequest): Observable<Annotation> {
return this.http.post<Annotation>(this.url, request);
}
deleteAnnotation(annotationId: number): Observable<void> {
return this.http.delete<void>(`${this.url}/${annotationId}`);
}
updateAnnotation(annotationId: number, request: UpdateAnnotationRequest): Observable<Annotation> {
return this.http.put<Annotation>(`${this.url}/${annotationId}`, request);
}
}
@@ -0,0 +1,57 @@
import {Injectable, inject} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {API_CONFIG} from '../../core/config/api-config';
export interface BookNoteV2 {
id: number;
userId?: number;
bookId: number;
cfi: string;
selectedText?: string;
noteContent: string;
color?: string;
chapterTitle?: string;
createdAt: string;
updatedAt?: string;
}
export interface CreateBookNoteV2Request {
bookId: number;
cfi: string;
selectedText?: string;
noteContent: string;
color?: string;
chapterTitle?: string;
}
export interface UpdateBookNoteV2Request {
noteContent?: string;
color?: string;
chapterTitle?: string;
}
@Injectable({
providedIn: 'root'
})
export class BookNoteV2Service {
private readonly url = `${API_CONFIG.BASE_URL}/api/v2/book-notes`;
private readonly http = inject(HttpClient);
getNotesForBook(bookId: number): Observable<BookNoteV2[]> {
return this.http.get<BookNoteV2[]>(`${this.url}/book/${bookId}`);
}
createNote(request: CreateBookNoteV2Request): Observable<BookNoteV2> {
return this.http.post<BookNoteV2>(this.url, request);
}
deleteNote(noteId: number): Observable<void> {
return this.http.delete<void>(`${this.url}/${noteId}`);
}
updateNote(noteId: number, request: UpdateBookNoteV2Request): Observable<BookNoteV2> {
return this.http.put<BookNoteV2>(`${this.url}/${noteId}`, request);
}
}