feat(reading): polish typography, externalize CSS

Critique-directed polish of the reading surface (#72 ruling: pipeline
calm, surface not-calm) plus the single-user typography rework:

- Flow: leading 1.5, paragraph gap tightened; heading ladder rescaled
  (h1 1.15x / h2 0.85x / h3 body-face semibold) with cling margins,
  hN+hN suppression, no title dead space
- Constructs: confident blockquote (near-ink text, 3px rail, nesting
  degrades), booktabs tables, tinted code panels, relative inline code
- Fonts hardcoded for Alexander's faces: Valkyrie OT B 17 body,
  Concourse OT Semibold headings, UbuntuMono 14 code; 66ch measure
- Stylesheet moved to Museion/Resources/reading.css, read fresh per
  page build — Debug builds load the repo copy (#filePath), so CSS
  edits hot-reload on the next reading toggle
- Settings Typography/Text Flow sections and all flow-key plumbing
  deleted (56 insertions, 417 deletions)

Refs #72, #78. Detector: 192 findings -> 0. Build + 93 tests green.

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-10-07 17:02:10 +02:00
1 parent eae86dd2ef
commit 4cb753d17f
9 files changed
+134 -417

No files matched your search

+1 -31
View File
@@ -297,19 +297,13 @@ struct ProseTextView: NSViewRepresentable {
func updateNSView(_ scroll: NSScrollView, context: Context) {
guard let tv = scroll.documentView as? NSTextView else { return }
// Typography/flow knob changes arrive via the coordinator's
// UserDefaults observer (SwiftUI doesn't invalidate on defaults
// writes from another pane).
context.coordinator.watchDefaults(tv)
context.coordinator.appliedFlowKey = ProseTypography.flowKey
if let session {
context.coordinator.sessionRef = session
// Load only when the generation moved (open, Yes-reload) — never
// per keystroke: the text view owns the live text.
if context.coordinator.loadedGeneration != session.loadGeneration {
context.coordinator.loadedGeneration = session.loadGeneration
context.coordinator.appliedFlowKey = ProseTypography.flowKey
// Seed from session.text (LIVE), not session.loadText (the
// Seed from session.text (LIVE), not session.loadText (the
// open-time snapshot): the representable is recreated on the
// reading⇄editing swap, and seeding from the snapshot showed
// pre-edit text — then session.edit on the stale view would
@@ -354,30 +348,6 @@ struct ProseTextView: NSViewRepresentable {
var sessionRef: EditorSession?
var loadedGeneration = -1
var appliedCaretToken = -1
var appliedFlowKey = ""
private var defaultsObserver: NSObjectProtocol?
func watchDefaults(_ tv: NSTextView) {
guard defaultsObserver == nil else { return }
defaultsObserver = NotificationCenter.default.addObserver(
forName: UserDefaults.didChangeNotification,
object: nil,
queue: .main,
) { [weak self] _ in
self?.applyTypographyIfChanged(tv)
}
}
private func applyTypographyIfChanged(_ tv: NSTextView) {
let key = ProseTypography.flowKey
guard key != appliedFlowKey else { return }
appliedFlowKey = key
let sel = tv.selectedRange()
if let storage = tv.textStorage as? NSMutableAttributedString {
storage.setAttributedString(ProsePresenter.attribute(tv.string))
tv.setSelectedRange(sel)
}
}
init(representable: ProseTextView) {
onEdit = representable.onEdit