feat: round embedded note images

This commit is contained in:
Valdemar Lorenzen
2026-10-20 12:36:35 +02:00
parent 794d927df1
commit f6d9d04b74
4 changed files with 78 additions and 1 deletions
+12
View File
@@ -619,6 +619,15 @@ private final class NotesView: NSView {
}
}
private final class RoundedImageAttachmentCell: NSTextAttachmentCell {
override func draw(withFrame cellFrame: NSRect, in controlView: NSView?) {
NSGraphicsContext.saveGraphicsState()
defer { NSGraphicsContext.restoreGraphicsState() }
NSBezierPath(roundedRect: cellFrame, xRadius: 8, yRadius: 8).addClip()
super.draw(withFrame: cellFrame, in: controlView)
}
}
@MainActor
enum MarkdownHighlighting {
@@ -677,6 +686,9 @@ enum MarkdownHighlighting {
let size = image.size
let scale = min(1, 460 / max(size.width, 1), 240 / max(size.height, 1))
if scale < 1 { image.size = NSSize(width: size.width * scale, height: size.height * scale) }
if !(cell is RoundedImageAttachmentCell) {
attachment.attachmentCell = RoundedImageAttachmentCell(imageCell: image)
}
}
storage.removeAttribute(.strikethroughStyle, range: range)
storage.addAttribute(hiddenMarkup, value: false, range: range)