Cmd-m magnify block

This commit is contained in:
sawka 2024-07-31 19:59:21 -07:00
parent a4551f9e4c
commit 933c5d66e9
2 changed files with 20 additions and 0 deletions

View File

@ -670,6 +670,14 @@ function makeAppMenu() {
role: "togglefullscreen",
},
];
const windowMenu: Electron.MenuItemConstructorOptions[] = [
{ role: "minimize", accelerator: "" },
{ role: "zoom" },
{ type: "separator" },
{ role: "front" },
{ type: "separator" },
{ role: "window" },
];
const menuTemplate: Electron.MenuItemConstructorOptions[] = [
{
role: "appMenu",
@ -688,6 +696,7 @@ function makeAppMenu() {
},
{
role: "windowMenu",
submenu: windowMenu,
},
];
const menu = electron.Menu.buildFromTemplate(menuTemplate);

View File

@ -20,6 +20,7 @@ import clsx from "clsx";
import * as jotai from "jotai";
import * as React from "react";
import { adaptFromReactOrNativeKeyEvent, checkKeyPressed } from "@/util/keyutil";
import "./block.less";
export interface LayoutComponentModel {
@ -385,6 +386,15 @@ const BlockFrame_Default_Component = ({
layoutModel?.onMagnifyToggle();
}
function handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>) {
const waveEvent = adaptFromReactOrNativeKeyEvent(e);
if (checkKeyPressed(waveEvent, "Cmd:m")) {
e.preventDefault();
layoutModel?.onMagnifyToggle();
return;
}
}
const innerStyle: React.CSSProperties = {};
if (!preview && customBg?.bg != null) {
innerStyle.background = customBg.bg;
@ -410,6 +420,7 @@ const BlockFrame_Default_Component = ({
onFocusCapture={blockModel?.onFocusCapture}
ref={blockModel?.blockRef}
style={style}
onKeyDown={handleKeyDown}
>
<div className="block-mask"></div>
<div className="block-frame-default-inner" style={innerStyle}>