mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
6b84ce4107
* feat(review): custom font family and size overrides for code review diffs Add Code Font and Code Font Size settings to the review Display tab, letting users override the theme's monospace font in the diff viewer. Supports 9 fonts (Fira Code, Hack, IBM Plex Mono, Inconsolata, JetBrains Mono, Red Hat Mono, Roboto Mono, Source Code Pro, Atkinson Hyperlegible Mono) loaded on demand from Google Fonts / jsDelivr CDN. Font size uses a continuous slider (8–24px) with a Reset button. Settings persist via cookies and sync to ~/.plannotator/config.json under diffOptions.fontFamily / diffOptions.fontSize, matching the existing config pattern. For provenance purposes, this commit was AI assisted. * fix(review): line-height scaling, inline annotation font coverage, and comment card cleanup - Add line-height: 1.5 alongside font-size in Pierre shadow DOM so large sizes don't clip - Include .review-comment-body selectors in font override CSS so inline annotation code spans get the custom font - Simplify comment card: remove drop shadow, left border accent, translateX hover; use tight border with subtle hover For provenance purposes, this commit was AI assisted.
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
/**
|
|
* Dynamic font loading for code review diff viewer.
|
|
*
|
|
* Injects Google Fonts / CDN stylesheet links on demand when the user
|
|
* selects a custom diff font. Each font is loaded at most once.
|
|
*/
|
|
|
|
const FONT_URLS: Record<string, string> = {
|
|
'Red Hat Mono': 'https://fonts.googleapis.com/css2?family=Red+Hat+Mono:wght@300..700&display=swap',
|
|
'Fira Code': 'https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&display=swap',
|
|
'Atkinson Hyperlegible Mono': 'https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible+Mono:wght@200..700&display=swap',
|
|
'Source Code Pro': 'https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@300..700&display=swap',
|
|
'JetBrains Mono': 'https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300..700&display=swap',
|
|
'IBM Plex Mono': 'https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300..700&display=swap',
|
|
'Inconsolata': 'https://fonts.googleapis.com/css2?family=Inconsolata:wght@300..700&display=swap',
|
|
'Roboto Mono': 'https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300..700&display=swap',
|
|
'Hack': 'https://cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css',
|
|
};
|
|
|
|
const loaded = new Set<string>();
|
|
|
|
export function loadDiffFont(fontFamily: string): void {
|
|
if (!fontFamily || loaded.has(fontFamily)) return;
|
|
const url = FONT_URLS[fontFamily];
|
|
if (!url) return;
|
|
|
|
const link = document.createElement('link');
|
|
link.rel = 'stylesheet';
|
|
link.href = url;
|
|
link.dataset.diffFont = fontFamily;
|
|
document.head.appendChild(link);
|
|
loaded.add(fontFamily);
|
|
}
|