updates plug with all sorts of awesome improvements

This commit is contained in:
2026-11-09 13:09:09 +01:00
parent a92d6f8871
commit 3afdb6d67f
553 changed files with 22780 additions and 13155 deletions
+13 -2
View File
@@ -23,14 +23,14 @@ final class PageText {
init(imageBase: URL, images: ImageCache = ImageCache(), bodySize: CGFloat = TextSize.standard) {
self.imageBase = imageBase
self.images = images
font = PlakFonts.body(bodySize)
font = PlakFonts.mono(bodySize)
codeFont = PlakFonts.mono(round(bodySize * PageMetrics.codeScale))
setBodySize(bodySize)
}
/// The minimum line height lets a line with an image grow to the image.
func setBodySize(_ size: CGFloat) {
font = PlakFonts.body(size)
font = PlakFonts.mono(size)
codeFont = PlakFonts.mono(round(size * PageMetrics.codeScale))
lineHeight = PageMetrics.lineHeight(font)
let style = NSMutableParagraphStyle()
@@ -314,6 +314,17 @@ extension NSString {
PageFile.isBlank(substring(with: range))
}
/// The start of the first line of the block that holds the line at `location`.
func blockStart(at location: Int) -> Int {
var start = lineStart(at: location)
while start > 0 {
let previous = lineStart(at: start - 1)
if isBlankLine(NSRange(location: previous, length: start - 1 - previous)) { break }
start = previous
}
return start
}
/// The lines of the blocks an edit touches; an edit in blank lines also takes the block above and below.
func blockRegion(around edit: NSRange) -> NSRange {
var start = lineStart(at: edit.location)