feat(editor): configurable text flow — line height + spacing knobs (#71 follow-up 7)

Three UserDefaults-backed knobs in ProseTypography (line-height multiple,
space-after-¶ and space-after-heading in body lines, clamped), surfaced
in Settings → Text Flow. Also fixes two real bugs from the last commit:
paragraphSpacing was set to 1.25 POINTS (now lines × linePoints), and
reading-mode body paragraphs never received the rhythm at all (they rode
the editing surface's fixed 10pt) — both surfaces now share one rhythm.
This commit is contained in:
AlexKucera committed 2026-10-06 13:43:43 +02:00
1 parent 2d4e2563f7
commit 6d7d1411a2
4 files changed
+98 -5

No files matched your search

+47
View File
@@ -35,6 +35,7 @@ struct SettingsPaneView: View {
VStack(alignment: .leading, spacing: 24) {
contentSection
typographySection
flowSection
}
.padding(24)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
@@ -65,6 +66,23 @@ struct SettingsPaneView: View {
}
}
// MARK: Text flow (#71 polish)
private var flowSection: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Text Flow")
.font(.system(size: 13, weight: .semibold))
Text(
"Reading rhythm. Line height scales the leading; the spacings are measured in body lines — tune them when a face change tightens or loosens the page.",
)
.font(.callout)
.foregroundStyle(DesignTokens.muted)
FlowRow(label: "Line height", key: "proseLineHeight", range: 1 ... 2, step: 0.05)
FlowRow(label: "Space after ¶", key: "proseParagraphSpacingLines", range: 0 ... 4, step: 0.25)
FlowRow(label: "Space after headings", key: "proseHeadingSpacingLines", range: 0 ... 6, step: 0.25)
}
}
// MARK: Typography (#70)
private var typographySection: some View {
@@ -146,6 +164,35 @@ private struct SlotRow: View {
}
}
/// One flow knob: label + numeric field (UserDefaults-backed).
private struct FlowRow: View {
let label: String
let key: String
let range: ClosedRange<Double>
let step: Double
var body: some View {
HStack(spacing: 10) {
Text(label)
.font(.system(size: 12, weight: .semibold))
.frame(width: 150, alignment: .leading)
TextField("", value: binding, format: .number.precision(.fractionLength(2)))
.textFieldStyle(.roundedBorder)
.frame(width: 64)
Text("× body line")
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
}
}
private var binding: Binding<Double> {
Binding(
get: { UserDefaults.standard.double(forKey: key) },
set: { UserDefaults.standard.set(max(range.lowerBound, min(range.upperBound, $0)), forKey: key) },
)
}
}
private extension Array {
/// Order-preserving dedupe (face lists merge current + installed).
func uniqued() -> [Element] where Element: Hashable {