merge integration

This commit is contained in:
jess 2026-04-06 17:12:17 -07:00
commit 77bf5a113c
1 changed files with 18 additions and 3 deletions

View File

@ -36,8 +36,10 @@ class MarkdownLayoutManager: NSLayoutManager {
drawBlockquoteBorder(glyphRange: glyphRange, origin: origin, container: textContainer) drawBlockquoteBorder(glyphRange: glyphRange, origin: origin, container: textContainer)
case .horizontalRule: case .horizontalRule:
drawHorizontalRule(glyphRange: glyphRange, origin: origin, container: textContainer) drawHorizontalRule(glyphRange: glyphRange, origin: origin, container: textContainer)
case .checkbox, .tableBlock: case .checkbox:
break break
case .tableBlock:
drawTableBackground(glyphRange: glyphRange, origin: origin, container: textContainer)
} }
} }
} }
@ -59,6 +61,8 @@ class MarkdownLayoutManager: NSLayoutManager {
drawCheckbox(checked: checked, glyphRange: glyphRange, origin: origin, container: textContainer) drawCheckbox(checked: checked, glyphRange: glyphRange, origin: origin, container: textContainer)
case .horizontalRule: case .horizontalRule:
skipRanges.append(glyphRange) skipRanges.append(glyphRange)
case .tableBlock:
skipRanges.append(glyphRange)
default: default:
break break
} }
@ -152,6 +156,17 @@ class MarkdownLayoutManager: NSLayoutManager {
} }
} }
private func drawTableBackground(glyphRange: NSRange, origin: NSPoint, container: NSTextContainer) {
var rect = boundingRect(forGlyphRange: glyphRange, in: container)
rect.origin.x = origin.x + 4
rect.origin.y += origin.y
rect.size.width = container.containerSize.width - 8
let path = NSBezierPath(roundedRect: rect, xRadius: 4, yRadius: 4)
Theme.current.base.setFill()
path.fill()
}
private func drawTableBorders(glyphRange: NSRange, columns: Int, origin: NSPoint, container: NSTextContainer) { private func drawTableBorders(glyphRange: NSRange, columns: Int, origin: NSPoint, container: NSTextContainer) {
guard columns > 0 else { return } guard columns > 0 else { return }
var rect = boundingRect(forGlyphRange: glyphRange, in: container) var rect = boundingRect(forGlyphRange: glyphRange, in: container)
@ -2439,8 +2454,8 @@ private func highlightFootnoteDefinition(textStorage: NSTextStorage, lineRange:
// MARK: - Tables // MARK: - Tables
private func highlightTableLine(_ trimmed: String, lineRange: NSRange, textStorage: NSTextStorage, palette: CatppuccinPalette, baseFont: NSFont, isHeader: Bool, isSeparator: Bool) { private func highlightTableLine(_ trimmed: String, lineRange: NSRange, textStorage: NSTextStorage, palette: CatppuccinPalette, baseFont: NSFont, isHeader: Bool, isSeparator: Bool) {
textStorage.addAttribute(.foregroundColor, value: palette.base, range: lineRange) textStorage.addAttribute(.foregroundColor, value: NSColor.clear, range: lineRange)
textStorage.addAttribute(.font, value: NSFont.systemFont(ofSize: 0.01), range: lineRange) textStorage.addAttribute(.font, value: baseFont, range: lineRange)
} }
// MARK: - Lists and Horizontal Rules // MARK: - Lists and Horizontal Rules