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,54 +1,34 @@
// RDEPUBReaderController+PublicAPI.swift
// RDEPUBReaderController API
import UIKit
// MARK: - Public Reader Commands
extension RDEPUBReaderController {
/// EPUB
public func reloadBook() {
runtime.reloadBook()
}
///
/// - Parameter location:
public func go(to location: RDEPUBLocation) {
guard publication != nil else { return }
_ = runtime.go(to: location)
}
///
/// - Parameters:
/// - pageNumber: 1
/// - animated:
/// - Returns:
@discardableResult
public func go(toPageNumber pageNumber: Int, animated: Bool = false) -> Bool {
runtime.go(toPageNumber: pageNumber, animated: animated)
}
///
public func clearSelection() {
runtime.clearSelection()
}
///
/// - Parameter id: ID
/// - Returns: nil
public func bookmark(withID id: String) -> RDEPUBBookmark? {
runtime.bookmark(withID: id)
}
///
/// - Parameter id: ID
/// - Returns: nil
public func highlight(withID id: String) -> RDEPUBHighlight? {
runtime.highlight(withID: id)
}
/// 访
/// - Returns: nil
public func nativeTextSemanticSummary() -> String? {
let resolvedPage: RDEPUBTextPage?
if let textBook {
@@ -79,12 +59,6 @@ extension RDEPUBReaderController {
return parts.joined(separator: " · ")
}
///
/// - Parameters:
/// - selection: 使 currentSelection
/// - color: CSS
/// - note:
/// - Returns: nil
@discardableResult
public func addHighlight(
from selection: RDEPUBSelection? = nil,
@@ -94,13 +68,6 @@ extension RDEPUBReaderController {
runtime.addHighlight(from: selection, color: color, note: note)
}
///
/// - Parameters:
/// - selection: 使 currentSelection
/// - style: 线
/// - color: CSS
/// - note:
/// - Returns: nil
@discardableResult
public func addAnnotation(
from selection: RDEPUBSelection? = nil,
@@ -111,72 +78,40 @@ extension RDEPUBReaderController {
runtime.addAnnotation(from: selection, style: style, color: color, note: note)
}
///
/// - Parameter highlight:
/// - Returns:
@discardableResult
public func upsertHighlight(_ highlight: RDEPUBHighlight) -> RDEPUBHighlight? {
runtime.upsertHighlight(highlight)
}
///
/// - Parameter id: ID
/// - Returns: nil
@discardableResult
public func removeHighlight(id: String) -> RDEPUBHighlight? {
runtime.removeHighlight(id: id)
}
///
/// - Parameters:
/// - id: ID
/// - note: nil
/// - Returns: nil
@discardableResult
public func updateHighlightNote(id: String, note: String?) -> RDEPUBHighlight? {
runtime.updateHighlightNote(id: id, note: note)
}
///
/// - Parameters:
/// - id: ID
/// - animated:
/// - Returns:
@discardableResult
public func go(toHighlightID id: String, animated: Bool = true) -> Bool {
runtime.go(toHighlightID: id, animated: animated)
}
///
public func removeAllHighlights() {
runtime.removeAllHighlights()
}
///
/// - Parameters:
/// - item: EPUB
/// - animated:
/// - Returns:
@discardableResult
public func go(toTableOfContentsItem item: EPUBTableOfContentsItem, animated: Bool = true) -> Bool {
go(toTableOfContentsHref: item.href, animated: animated)
}
///
/// - Parameters:
/// - item: RDReader
/// - animated:
/// - Returns:
@discardableResult
public func go(toTableOfContentsItem item: RDEPUBReaderTableOfContentsItem, animated: Bool = true) -> Bool {
go(toTableOfContentsHref: item.href, animated: animated)
}
/// href href
/// - Parameters:
/// - href: #fragment
/// - animated:
/// - Returns:
@discardableResult
public func go(toTableOfContentsHref href: String, animated: Bool = true) -> Bool {
guard publication != nil else { return false }
@@ -193,61 +128,40 @@ extension RDEPUBReaderController {
return restoreReadingLocation(location, animated: animated)
}
///
/// - Parameter note:
/// - Returns: nil
@discardableResult
public func addBookmark(note: String? = nil) -> RDEPUBBookmark? {
runtime.addBookmark(note: note)
}
///
/// - Parameter note:
/// - Returns:
@discardableResult
public func toggleBookmark(note: String? = nil) -> RDEPUBBookmark? {
runtime.toggleBookmark(note: note)
}
///
/// - Parameter id: ID
/// - Returns: nil
@discardableResult
public func removeBookmark(id: String) -> RDEPUBBookmark? {
runtime.removeBookmark(id: id)
}
///
/// - Parameters:
/// - id: ID
/// - animated:
/// - Returns:
@discardableResult
public func go(toBookmarkID id: String, animated: Bool = true) -> Bool {
runtime.go(toBookmarkID: id, animated: animated)
}
///
/// - Parameter keyword:
public func search(keyword: String) {
runtime.search(keyword: keyword)
}
///
/// - Returns:
@discardableResult
public func searchNext() -> Bool {
runtime.searchNext()
}
///
/// - Returns:
@discardableResult
public func searchPrevious() -> Bool {
runtime.searchPrevious()
}
///
public func clearSearch() {
runtime.clearSearch()
}