feat: round embedded note images
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user