From 46441438a263c31a9608545adff5c79a0e8cd5a1 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Thu, 8 Oct 2026 13:51:07 +0200 Subject: [PATCH] feat(editor): 66ch measure + heading spacing (#77 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - editor text centers at reading.css --measure 66ch (zero-advance × 66 + 2×24pt padding), scroll view still fills the column - headings get paragraphSpacingBefore 75 / after 30 (CSS 90/30 minus the visible blank separator's ~15pt) --- Museion/PostEditorView.swift | 5 +++++ Museion/ProsePresenter.swift | 9 +++++++-- Museion/ProseTypography.swift | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Museion/PostEditorView.swift b/Museion/PostEditorView.swift index 1bfb041..6372e2a 100644 --- a/Museion/PostEditorView.swift +++ b/Museion/PostEditorView.swift @@ -61,7 +61,12 @@ struct PostEditorView: View { stateBox: readingState, ) } else { + // #77: editor measure — reading.css --measure 66ch. The scroll + // view fills the column; the text container centers at the + // measured width so wide columns match the reading surface. editingSurface + .frame(maxWidth: ProseTypography.measureWidth) + .frame(maxWidth: .infinity) } } .frame(maxWidth: .infinity, maxHeight: .infinity) diff --git a/Museion/ProsePresenter.swift b/Museion/ProsePresenter.swift index 88a2986..bff5ffc 100644 --- a/Museion/ProsePresenter.swift +++ b/Museion/ProsePresenter.swift @@ -396,8 +396,13 @@ nonisolated enum ProsePresenter { style.firstLineHeadIndent = 20 // CSS: blockquote padding-left 20px style.headIndent = 20 // wrapped quote lines align under the text } - style.paragraphSpacing = 0 - style.paragraphSpacingBefore = 0 + if kind == .heading1 || kind == .heading2 || kind == .heading3 || kind == .heading4Plus { + // Reading parity: head-space-before 90 / after 30 MINUS the blank + // separator line's own height (~15pt), which the editor shows and + // reading collapses. Alexander ruled blank-only "a bit tight". + style.paragraphSpacingBefore = 75 + style.paragraphSpacing = 30 + } return style } diff --git a/Museion/ProseTypography.swift b/Museion/ProseTypography.swift index 21d15f4..b2f2b34 100644 --- a/Museion/ProseTypography.swift +++ b/Museion/ProseTypography.swift @@ -66,6 +66,15 @@ nonisolated enum ProseTypography { NSFontManager.shared.convert(bodyFont, toSize: blankSize) } + /// Editor measure (#77): reading.css `--measure: 66ch` — the advance of + /// "0" × 66 in the body face (px→pt 1:1), + the text container's 24pt + /// lineFragmentPadding on both sides (the CSS body's 24px side padding). + static var measureWidth: CGFloat { + let zero = NSAttributedString(string: "0", attributes: [.font: bodyFont]) + let ch = zero.size().width + return (ch * 66).rounded() + 48 + } + /// Line-height parity with reading.css (#77): CSS `line-height: n` means /// n × font-size pixels; TextKit's lineHeightMultiple multiplies the /// font's natural box (ascender − descender + leading ≈ 1.2 × size).