ReadViewSDK/Doc/WXRead/decompiled/WRBookmark.h
2026-05-21 19:40:51 +08:00

112 lines
4.5 KiB
Objective-C

//
// WRBookmark.h
// WeRead (微信读书)
// Reverse-engineered header
//
// Bookmark model. Stores bookId, chapterUid, and position information.
// Supports highlights, underlines, and page marks with associated text.
// Synced with server via WRBookNetwork.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class WRBook;
@class WRMPReview;
// ---------------------------------------------------------------------------
// Bookmark types
// ---------------------------------------------------------------------------
typedef NS_ENUM(NSInteger, WRBookmarkType) {
WRBookmarkTypeHighlight = 0, // Yellow/blue/etc highlight
WRBookmarkTypeUnderline = 1, // Underline annotation
WRBookmarkTypeMark = 2, // Page bookmark (dog-ear)
WRBookmarkTypeNote = 3, // Written note
WRBookmarkTypePencil = 4, // Apple Pencil drawing
};
// ---------------------------------------------------------------------------
// WRBookmark
// ---------------------------------------------------------------------------
@interface WRBookmark : NSObject
// --- Ivars (from binary analysis) ---
// NSString (many): bookId, chapterUid, markText, colorStyle, reviewId,
// anchorId, rangeKey, noteContent, etc.
// WRBook: associated book model
// WRMPReview: associated review/comment model
// NSArray: range info, selected text fragments
// NSDictionary: extra metadata
// NSMutableSet: tags
// NSDictionary: sync metadata (syncKey, serverVersion)
@property (nonatomic, copy) NSString *bookmarkId; // unique bookmark ID
@property (nonatomic, copy) NSString *bookId; // book identifier
@property (nonatomic, copy) NSString *chapterUid; // chapter UID
@property (nonatomic, assign) NSInteger chapterOffset; // character offset within chapter
@property (nonatomic, assign) NSInteger chapterIndex; // chapter index in spine
@property (nonatomic, copy) NSString *markText; // highlighted/marked text
@property (nonatomic, copy, nullable) NSString *noteContent; // user note text
@property (nonatomic, assign) WRBookmarkType type; // bookmark type
@property (nonatomic, copy, nullable) NSString *colorStyle; // highlight color (e.g., "yellow", "blue", "red", "green")
@property (nonatomic, assign) NSInteger startPos; // start position (global)
@property (nonatomic, assign) NSInteger endPos; // end position (global)
@property (nonatomic, assign) NSInteger rangeLength; // length of the range
@property (nonatomic, copy, nullable) NSString *anchorId; // DOM anchor ID
@property (nonatomic, copy, nullable) NSString *rangeKey; // range key for sync
@property (nonatomic, strong, nullable) WRBook *book; // associated book
@property (nonatomic, strong, nullable) WRMPReview *review; // associated review
@property (nonatomic, strong, nullable) NSArray *rangeInfo; // detailed range info
@property (nonatomic, strong, nullable) NSDictionary *extraMetadata; // additional data
@property (nonatomic, strong, nullable) NSMutableSet<NSString *> *tags;
@property (nonatomic, assign) NSTimeInterval createTime; // creation timestamp
@property (nonatomic, assign) NSTimeInterval updateTime; // last update timestamp
@property (nonatomic, assign) BOOL isSynced; // synced with server
@property (nonatomic, copy, nullable) NSString *syncKey; // sync key for incremental updates
#pragma mark - Factory Methods
+ (instancetype)bookmarkWithBookId:(NSString *)bookId
chapterUid:(NSString *)chapterUid
offset:(NSInteger)offset
text:(NSString *)text
type:(WRBookmarkType)type;
+ (instancetype)highlightWithBookId:(NSString *)bookId
chapterUid:(NSString *)chapterUid
startPos:(NSInteger)startPos
endPos:(NSInteger)endPos
text:(NSString *)text
colorStyle:(NSString *)colorStyle;
#pragma mark - Serialization
- (NSDictionary *)toDictionary;
+ (nullable instancetype)fromDictionary:(NSDictionary *)dict;
/// Convert to JSON data for network sync.
- (nullable NSData *)toJSONData;
/// Create from JSON data received from server.
+ (nullable instancetype)fromJSONData:(NSData *)data;
#pragma mark - Display
/// Return a display-friendly summary string.
- (NSString *)displaySummary;
/// Return the color as a UIColor.
- (UIColor *)highlightUIColor;
@end
NS_ASSUME_NONNULL_END