style: match Raycast notes window
This commit is contained in:
@@ -18,19 +18,19 @@ private final class ListAttachment: NSTextAttachment {
|
||||
super.init(data: nil, ofType: nil)
|
||||
let cell = ListAttachmentCell(textCell: isTask ? "" : (source.length == 1 ? "•" : source.string))
|
||||
cell.attributedStringValue = NSAttributedString(string: cell.stringValue,
|
||||
attributes: [.font: NSFont.systemFont(ofSize: 14), .foregroundColor: SunsetPalette.accent])
|
||||
attributes: [.font: NotesAppearance.font, .foregroundColor: NotesAppearance.accent])
|
||||
cell.alignment = .right
|
||||
attachmentCell = cell
|
||||
bounds = NSRect(x: 0, y: -3, width: 18, height: 17)
|
||||
bounds = NSRect(x: 0, y: -4, width: 22, height: 21)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("List attachments are serialized as Markdown") }
|
||||
}
|
||||
|
||||
private final class ListAttachmentCell: NSTextAttachmentCell {
|
||||
nonisolated(unsafe) var columnWidth: CGFloat = 18
|
||||
nonisolated override func cellSize() -> NSSize { NSSize(width: columnWidth, height: 17) }
|
||||
nonisolated override func cellBaselineOffset() -> NSPoint { NSPoint(x: 0, y: -3) }
|
||||
nonisolated(unsafe) var columnWidth: CGFloat = 22
|
||||
nonisolated override func cellSize() -> NSSize { NSSize(width: columnWidth, height: 21) }
|
||||
nonisolated override func cellBaselineOffset() -> NSPoint { NSPoint(x: 0, y: -4) }
|
||||
override func draw(withFrame cellFrame: NSRect, in controlView: NSView?) {
|
||||
guard !stringValue.isEmpty else { return }
|
||||
let label = attributedStringValue
|
||||
@@ -202,6 +202,10 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
|
||||
replaceSource(NSAttributedString(string: text, attributes: textTypingAttributes), range: range, semantic: true)
|
||||
}
|
||||
|
||||
func replaceMarkdown(_ contents: NSAttributedString, range: NSRange) {
|
||||
replaceSource(contents, range: range, semantic: true)
|
||||
}
|
||||
|
||||
func markdownInsertionRange(for rendered: NSRange) -> NSRange {
|
||||
guard rendered.length == 0 else { return markdownRange(for: rendered) }
|
||||
let body = listWhitespaceBoundary(from: rendered.location, forward: true)
|
||||
@@ -506,7 +510,7 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
|
||||
while checkboxes.count < taskIndices.count {
|
||||
let checkbox = NSButton(checkboxWithTitle: "", target: self, action: #selector(toggleTask(_:)))
|
||||
checkbox.controlSize = .small
|
||||
checkbox.contentTintColor = SunsetPalette.accent
|
||||
checkbox.contentTintColor = NotesAppearance.accent
|
||||
checkbox.sizeToFit()
|
||||
checkboxes.append(checkbox)
|
||||
addSubview(checkbox)
|
||||
@@ -534,8 +538,8 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
|
||||
layoutManager.delegate = self
|
||||
storage.beginEditing()
|
||||
Self.restoreListLayout(in: storage)
|
||||
let markerFont = NSFont.systemFont(ofSize: 14)
|
||||
let column = ceil(tasks.reduce(CGFloat(18)) { width, task in
|
||||
let markerFont = NotesAppearance.font
|
||||
let column = ceil(tasks.reduce(CGFloat(22)) { width, task in
|
||||
guard !task.attachment.isTask else { return width }
|
||||
return max(width, (task.attachment.marker as NSString).size(withAttributes: [.font: markerFont]).width + 4)
|
||||
})
|
||||
@@ -552,6 +556,8 @@ final class NotesTextView: NSTextView, @MainActor NSLayoutManagerDelegate {
|
||||
}
|
||||
// Keep indentation as native whitespace; null paragraph-leading glyphs lose first-line layout.
|
||||
style.firstLineHeadIndent = 0
|
||||
style.lineSpacing = NotesAppearance.paragraph.lineSpacing
|
||||
style.paragraphSpacing = NotesAppearance.paragraph.paragraphSpacing
|
||||
style.headIndent = CGFloat(depth) * space + column
|
||||
style.tabStops = []
|
||||
style.defaultTabInterval = 4 * space
|
||||
|
||||
Reference in New Issue
Block a user