дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
feat(markdown): set the preview font size apart from the UI font (#1045)
The Markdown preview had a fixed 14px body and notebook Markdown cells inherited the UI font size, so enlarging them meant scaling the whole UI. Languages & Frameworks › Markdown › Preview font size (application-level, 8–72, following the editor font size until set) now drives the preview and notebook Markdown cells; fenced code scales with it, and notebook code cells and outputs follow the editor font. Fixes #768 Co-authored-by: jaw52 <[email protected]>
Цей коміт міститься в:
12 files changed
+176
-6
No files matched your search
@@ -51,6 +51,8 @@ export interface LanguagesValid {
|
||||
gradle: { jvm: string; distribution: "wrapper" | "local"; home: string; userHome: string };
|
||||
maven: { home: string; userSettings: string; localRepository: string; unlinkedProjects: string[] };
|
||||
};
|
||||
/** Preview font size in px; `null` follows the editor font size. */
|
||||
markdown: { previewFontSize: number | null };
|
||||
}
|
||||
|
||||
export interface ProjectStructureValid {
|
||||
@@ -111,6 +113,7 @@ export const DEFAULT_LANGUAGES: LanguagesValid = {
|
||||
gradle: { jvm: "", distribution: "wrapper", home: "", userHome: "" },
|
||||
maven: { home: "", userSettings: "", localRepository: "", unlinkedProjects: [] },
|
||||
},
|
||||
markdown: { previewFontSize: null },
|
||||
};
|
||||
|
||||
export const DEFAULT_PROJECT_STRUCTURE: ProjectStructureValid = {
|
||||
@@ -140,6 +143,9 @@ export function normalizeFolder(path: string): string {
|
||||
.replace(/^\/+|\/+$/g, "");
|
||||
}
|
||||
|
||||
/** A stored preview font size within IDEA's 8..72, or `null` (follow the editor font). */
|
||||
const previewSize = (v: unknown): number | null =>
|
||||
typeof v === "number" && Number.isFinite(v) ? Math.min(72, Math.max(8, Math.round(v))) : null;
|
||||
const folders = (v: unknown): string[] =>
|
||||
Array.isArray(v)
|
||||
? [
|
||||
@@ -171,6 +177,7 @@ export function validateLanguages(raw: unknown): LanguagesValid {
|
||||
const java = obj(l.java);
|
||||
const maven = obj(java.maven);
|
||||
const gradle = obj(java.gradle);
|
||||
const markdown = obj(l.markdown);
|
||||
return {
|
||||
python: {
|
||||
interpreter: text(py.interpreter, d.python.interpreter),
|
||||
@@ -229,9 +236,29 @@ export function validateLanguages(raw: unknown): LanguagesValid {
|
||||
unlinkedProjects: folders(maven.unlinkedProjects),
|
||||
},
|
||||
},
|
||||
markdown: { previewFontSize: previewSize(markdown.previewFontSize) },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Markdown preview (and notebook Markdown cell) font size in px: Languages &
|
||||
* Frameworks › Markdown, else the editor font size, as IDEA defaults it.
|
||||
*/
|
||||
export function markdownPreviewFontSize(settings: unknown): number {
|
||||
const s = obj(settings);
|
||||
const editorSize = obj(s.editor).fontSize;
|
||||
return (
|
||||
previewSize(obj(obj(s.languages).markdown).previewFontSize) ??
|
||||
// 13: the editor's default font size.
|
||||
(typeof editorSize === "number" && editorSize > 0 ? editorSize : 13)
|
||||
);
|
||||
}
|
||||
|
||||
/** Reactive `markdownPreviewFontSize` of the open project. */
|
||||
export function useMarkdownPreviewFontSize(): number {
|
||||
return useProject((s) => markdownPreviewFontSize(s.settings));
|
||||
}
|
||||
|
||||
export function validateProjectStructure(raw: unknown): ProjectStructureValid {
|
||||
const p = obj(raw);
|
||||
return {
|
||||
|
||||
@@ -5373,6 +5373,8 @@
|
||||
"Pull Request branch update failed": "拉取请求分支更新失败",
|
||||
"#{n} on {branch}": "#{n} 位于 {branch}",
|
||||
"Markdown Images": "Markdown 图片",
|
||||
"Preview font size": "预览字号",
|
||||
"Also used by Markdown cells in Jupyter notebooks. Defaults to the editor font size, independent of the UI font size.": "同时用于 Jupyter 笔记本中的 Markdown 单元格。默认跟随编辑器字号,与 UI 字号相互独立。",
|
||||
"Image folder": "图片文件夹",
|
||||
"Relative to the Markdown file.": "相对于 Markdown 文件。",
|
||||
"Image name pattern": "图片名称格式",
|
||||
|
||||
Reference in new issue
Заблокувати користувача