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:
1 parent
2d4e2563f7
commit
6d7d1411a2
4 files changed
+98
-5
No files matched your search
@@ -146,7 +146,8 @@ enum ReadingPresenter {
|
||||
/// paragraph when the file can't load.
|
||||
private static func imageBlockContent(url: URL, alt: String) -> NSAttributedString {
|
||||
let ps = NSMutableParagraphStyle()
|
||||
ps.paragraphSpacing = 10
|
||||
ps.lineHeightMultiple = lineHeightMultiple
|
||||
ps.paragraphSpacing = paragraphSpacingAfter
|
||||
ps.paragraphSpacingBefore = 8
|
||||
guard let image = NSImage(contentsOf: url), image.size.width > 0 else {
|
||||
return inlineParse(alt.isEmpty ? ")" : alt)
|
||||
@@ -201,7 +202,13 @@ enum ReadingPresenter {
|
||||
.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||
.filter { !$0.isEmpty }
|
||||
.joined(separator: " ")
|
||||
return inlineParse(joined)
|
||||
let para = inlineParse(joined)
|
||||
let ps = NSMutableParagraphStyle()
|
||||
ps.lineHeightMultiple = lineHeightMultiple
|
||||
ps.paragraphSpacing = paragraphSpacingAfter
|
||||
let styled = NSMutableAttributedString(attributedString: para)
|
||||
styled.addAttribute(.paragraphStyle, value: ps, range: NSRange(location: 0, length: styled.length))
|
||||
return styled
|
||||
}
|
||||
|
||||
private static func headingContent(_ text: String, level: Int) -> NSAttributedString {
|
||||
|
||||
Reference in new issue
Block a user