140 lines
4.6 KiB
Objective-C
140 lines
4.6 KiB
Objective-C
//
|
|
// WRPageMark.h
|
|
// WeRead (微信读书)
|
|
// Reverse-engineered header
|
|
//
|
|
// Annotation model for page bookmarks/marks (dog-ear style).
|
|
// 25 methods identified from binary. The most feature-rich annotation type.
|
|
// Supports bookmark management, sorting, filtering, and display.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <UIKit/UIKit.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@class WRBook;
|
|
@class WRBookmark;
|
|
@class WRPageHighlight;
|
|
@class WRPageUnderline;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Mark display mode
|
|
// ---------------------------------------------------------------------------
|
|
typedef NS_ENUM(NSInteger, WRPageMarkDisplayMode) {
|
|
WRPageMarkDisplayModeIcon = 0, // Show bookmark icon
|
|
WRPageMarkDisplayModeList = 1, // Show in list view
|
|
WRPageMarkDisplayModeInline = 2, // Show inline in text
|
|
};
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// WRPageMark
|
|
// ---------------------------------------------------------------------------
|
|
@interface WRPageMark : NSObject
|
|
|
|
@property (nonatomic, copy) NSString *markId;
|
|
@property (nonatomic, copy) NSString *bookId;
|
|
@property (nonatomic, copy) NSString *chapterUid;
|
|
@property (nonatomic, assign) NSInteger chapterOffset;
|
|
@property (nonatomic, assign) NSInteger pageIndex;
|
|
@property (nonatomic, copy) NSString *chapterTitle; // display title
|
|
@property (nonatomic, copy, nullable) NSString *excerptText; // text near the mark
|
|
@property (nonatomic, assign) NSTimeInterval createTime;
|
|
@property (nonatomic, assign) NSTimeInterval updateTime;
|
|
@property (nonatomic, assign) BOOL isSynced;
|
|
@property (nonatomic, copy, nullable) NSString *syncKey;
|
|
|
|
// Color/style for the mark icon
|
|
@property (nonatomic, strong, nullable) UIColor *markColor;
|
|
@property (nonatomic, assign) WRPageMarkDisplayMode displayMode;
|
|
|
|
// Linked annotations at the same position
|
|
@property (nonatomic, strong, nullable) NSArray<WRPageHighlight *> *linkedHighlights;
|
|
@property (nonatomic, strong, nullable) NSArray<WRPageUnderline *> *linkedUnderlines;
|
|
|
|
#pragma mark - Initialization
|
|
|
|
/// Create a page mark at the given position.
|
|
- (instancetype)initWithBookId:(NSString *)bookId
|
|
chapterUid:(NSString *)chapterUid
|
|
chapterOffset:(NSInteger)offset
|
|
pageIndex:(NSInteger)pageIndex
|
|
chapterTitle:(NSString *)title;
|
|
|
|
#pragma mark - Conversion (25 methods, reconstructed)
|
|
|
|
/// Convert to WRBookmark for persistence.
|
|
- (WRBookmark *)toBookmark;
|
|
|
|
/// Create from WRBookmark.
|
|
+ (nullable instancetype)fromBookmark:(WRBookmark *)bookmark;
|
|
|
|
#pragma mark - Linked Annotations
|
|
|
|
/// Add a highlight linked to this mark.
|
|
- (void)addLinkedHighlight:(WRPageHighlight *)highlight;
|
|
|
|
/// Add an underline linked to this mark.
|
|
- (void)addLinkedUnderline:(WRPageUnderline *)underline;
|
|
|
|
/// Remove a linked highlight by ID.
|
|
- (void)removeLinkedHighlightWithId:(NSString *)highlightId;
|
|
|
|
/// Remove a linked underline by ID.
|
|
- (void)removeLinkedUnderlineWithId:(NSString *)underlineId;
|
|
|
|
/// Return all linked annotation IDs.
|
|
- (NSArray<NSString *> *)allLinkedAnnotationIds;
|
|
|
|
#pragma mark - Display
|
|
|
|
/// Return the title for display in the bookmark list.
|
|
- (NSString *)displayTitle;
|
|
|
|
/// Return the subtitle/detail text.
|
|
- (NSString *)displaySubtitle;
|
|
|
|
/// Return a formatted date string.
|
|
- (NSString *)formattedDate;
|
|
|
|
/// Return the mark icon image.
|
|
- (UIImage *)markIcon;
|
|
|
|
#pragma mark - Sorting & Filtering
|
|
|
|
/// Compare marks by position (for sorting in reading order).
|
|
- (NSComparisonResult)compareByPosition:(WRPageMark *)other;
|
|
|
|
/// Compare marks by creation date.
|
|
- (NSComparisonResult)compareByDate:(WRPageMark *)other;
|
|
|
|
/// Check if this mark is in the given chapter.
|
|
- (BOOL)isInChapter:(NSString *)chapterUid;
|
|
|
|
#pragma mark - Serialization
|
|
|
|
- (NSDictionary *)toDictionary;
|
|
+ (nullable instancetype)fromDictionary:(NSDictionary *)dict;
|
|
- (nullable NSData *)toJSONData;
|
|
+ (nullable instancetype)fromJSONData:(NSData *)data;
|
|
|
|
#pragma mark - Batch Operations (class methods)
|
|
|
|
/// Sort an array of marks by position.
|
|
+ (NSArray<WRPageMark *> *)marksSortedByPosition:(NSArray<WRPageMark *> *)marks;
|
|
|
|
/// Sort an array of marks by date.
|
|
+ (NSArray<WRPageMark *> *)marksSortedByDate:(NSArray<WRPageMark *> *)marks;
|
|
|
|
/// Filter marks for a specific chapter.
|
|
+ (NSArray<WRPageMark *> *)marksInChapter:(NSString *)chapterUid
|
|
fromMarks:(NSArray<WRPageMark *> *)marks;
|
|
|
|
/// Filter marks within a position range.
|
|
+ (NSArray<WRPageMark *> *)marksInRange:(NSRange)range
|
|
fromMarks:(NSArray<WRPageMark *> *)marks;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|