Skip to content

Feat add editor fontsize #2088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions frontend/app/view/codeeditor/codeeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

import { useOverrideConfigAtom } from "@/app/store/global";
import { boundNumber } from "@/util/util";
import loader from "@monaco-editor/loader";
import { Editor, Monaco } from "@monaco-editor/react";
import type * as MonacoTypes from "monaco-editor/esm/vs/editor/editor.api";
Expand All @@ -11,7 +10,7 @@ import React, { useMemo, useRef } from "react";

import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
import { makeConnRoute } from "@/util/util";
import { boundNumber, makeConnRoute } from "@/util/util";
import editorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
import cssWorker from "monaco-editor/esm/vs/language/css/css.worker?worker";
import htmlWorker from "monaco-editor/esm/vs/language/html/html.worker?worker";
Expand Down
34 changes: 34 additions & 0 deletions frontend/app/view/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,9 @@ export class PreviewModel implements ViewModel {
}

getSettingsMenuItems(): ContextMenuItem[] {
const defaultFontSize = globalStore.get(getSettingsKeyAtom("editor:fontsize")) ?? 12;
const blockData = globalStore.get(this.blockAtom);
const overrideFontSize = blockData?.meta?.["editor:fontsize"];
const menuItems: ContextMenuItem[] = [];
menuItems.push({
label: "Copy Full Path",
Expand Down Expand Up @@ -716,6 +719,37 @@ export class PreviewModel implements ViewModel {
await navigator.clipboard.writeText(fileInfo.name);
}),
});
menuItems.push({ type: "separator" });
const fontSizeSubMenu: ContextMenuItem[] = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18].map(
(fontSize: number) => {
return {
label: fontSize.toString() + "px",
type: "checkbox",
checked: overrideFontSize == fontSize,
click: () => {
RpcApi.SetMetaCommand(TabRpcClient, {
oref: WOS.makeORef("block", this.blockId),
meta: { "editor:fontsize": fontSize },
});
},
};
}
);
fontSizeSubMenu.unshift({
label: "Default (" + defaultFontSize + "px)",
type: "checkbox",
checked: overrideFontSize == null,
click: () => {
RpcApi.SetMetaCommand(TabRpcClient, {
oref: WOS.makeORef("block", this.blockId),
meta: { "editor:fontsize": null },
});
},
});
menuItems.push({
label: "Editor Font Size",
submenu: fontSizeSubMenu,
});
const finfo = jotaiLoadableValue(globalStore.get(this.loadableFileInfo), null);
addOpenMenuItems(menuItems, globalStore.get(this.connectionImmediate), finfo);
const loadableSV = globalStore.get(this.loadableSpecializedView);
Expand Down
1 change: 1 addition & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ declare global {
"editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean;
"editor:wordwrap"?: boolean;
"editor:fontsize"?: number;
"graph:*"?: boolean;
"graph:numpoints"?: number;
"graph:metrics"?: string[];
Expand Down
Loading