feat(editor): 66ch measure + heading spacing (#77 follow-up)
- 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)
This commit is contained in:
1 parent
3934b10ec5
commit
46441438a2
3 files changed
+21
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in new issue
Block a user