feat: EPUB阅读器搜索、注释、CFI模块及大书远距跳转优化

- 实现EPUB阅读器搜索功能及选中注释功能
- 优化CFI模块,修复代码审查发现的11个问题
- 实现大书远距目录跳转与后台补全优化方案
- 优化设置面板与章节运行时联动
- 重构及大量改进优化
This commit is contained in:
shenlei
2026-06-22 20:26:34 +08:00
parent f50495ad91
commit c65c190b71
178 changed files with 11380 additions and 6728 deletions
@@ -1,84 +1,46 @@
// RDEPUBTextPositionConverter.swift
// EPUB
import Foundation
/// WXRead `WREpubPositionConverter`
///
///
/// - `(fileIndex, row, column)`
/// -
/// -
/// - / `RDEPUBLocation`
public struct RDEPUBTextPositionConverter {
/// EPUB
public let book: RDEPUBTextBook
/// EPUB
/// - Parameter book: EPUB
public init(book: RDEPUBTextBook) {
self.book = book
}
///
public var totalCharacterCount: Int {
book.indexTable.totalCharacterCount
}
///
/// - Parameter anchor:
/// - Returns:
public func globalIndex(for anchor: RDEPUBTextAnchor) -> Int {
book.indexTable.globalIndex(for: anchor)
}
///
/// - Parameter rangeAnchor:
/// - Returns: `NSRange`
public func globalRange(for rangeAnchor: RDEPUBTextRangeAnchor) -> NSRange {
book.indexTable.globalRange(for: rangeAnchor)
}
///
/// - Parameter index:
/// - Returns: `nil`
public func fileIndex(forCharacterPosition index: Int) -> Int? {
book.indexTable.fileIndex(forCharacterPosition: index)
}
///
/// - Parameters:
/// - fileIndex:
/// - index:
/// - Returns: `nil`
public func localOffsetInFile(at fileIndex: Int, forGlobalPosition index: Int) -> Int? {
book.indexTable.localOffsetInFile(at: fileIndex, forGlobalPosition: index)
}
///
/// - Parameter index:
/// - Returns: `nil`
public func anchor(forCharacterPosition index: Int) -> RDEPUBTextAnchor? {
book.indexTable.anchor(forGlobalIndex: index)
}
/// `RDEPUBLocation`
/// - Parameter location: EPUB
/// - Returns: `nil`
public func anchor(for location: RDEPUBLocation) -> RDEPUBTextAnchor? {
book.indexTable.anchor(for: location)
}
/// 1
/// - Parameter anchor:
/// - Returns: `nil`
public func pageNumber(for anchor: RDEPUBTextAnchor) -> Int? {
book.indexTable.pageNumber(for: anchor, in: book).map { $0 + 1 }
}
/// 1
/// - Parameter index:
/// - Returns: `nil`
public func pageNumber(forCharacterPosition index: Int) -> Int? {
guard let anchor = anchor(forCharacterPosition: index) else {
return nil
@@ -86,11 +48,6 @@ public struct RDEPUBTextPositionConverter {
return pageNumber(for: anchor)
}
/// `RDEPUBLocation`
/// - Parameters:
/// - anchor:
/// - bookIdentifier: location `bookId`
/// - Returns: `RDEPUBLocation` `nil`
public func location(
for anchor: RDEPUBTextAnchor,
bookIdentifier: String?
@@ -101,11 +58,6 @@ public struct RDEPUBTextPositionConverter {
return book.indexTable.location(for: anchor, in: chapter, bookIdentifier: bookIdentifier)
}
/// `RDEPUBLocation`
/// - Parameters:
/// - rangeAnchor:
/// - bookIdentifier: location `bookId`
/// - Returns: `RDEPUBLocation` `nil`
public func location(
for rangeAnchor: RDEPUBTextRangeAnchor,
bookIdentifier: String?