// What the reader marks in a book, as the core answers it: a highlight // (`shell.reader`'s `highlights`, each a `highlight` row the core made), the // pencil it is drawn in, and a selection about to become one. // // The reader draws every one of a book's highlights back on the page as a // pencil line (Readium's underline decoration) at open and whenever one is // made, recoloured or removed; the row, its chapter, page and percent are // the core's (`reader.highlight`). import CottonPaper import SwiftUI /// The three pencils a passage is underlined in, as they are drawn. enum HighlightPencil: String, CaseIterable, Sendable, Decodable { case red, yellow, teal var material: BookFaceMaterial { switch self { case .red: .pencilRed case .yellow: .pencilYellow case .teal: .pencilTeal } } var colour: SwiftUI.Color { material.colour } } /// One highlight of the open book, as the page draws it. struct BookHighlight: Equatable, Sendable, Identifiable, Decodable { let id: String /// Readium's Locator of the passage, serialised. let at: String var pencil: HighlightPencil var note: String? init(id: String, at: String, pencil: HighlightPencil, note: String? = nil) { self.id = id self.at = at self.pencil = pencil self.note = note } } /// A selection about to become a highlight: the words as they stand in the /// book, and Readium's Locator of them, serialised. struct BookSelection: Equatable, Sendable { let words: String let at: String }