Wire quick access commands

This commit is contained in:
Курнат Андрей
2026-06-02 20:39:30 +03:00
parent 231bb6c076
commit c16df37c95
5 changed files with 76 additions and 10 deletions
+13 -4
View File
@@ -6,7 +6,8 @@ import {
Share2,
Undo2
} from "lucide-react";
import type { ReactNode } from "react";
import type { MouseEvent, ReactNode } from "react";
import type { QOfficeCommand } from "../hooks/useQOfficeCommand";
import type { AppId } from "../types";
interface AppShellProps {
@@ -28,6 +29,14 @@ const appTitles: Record<AppId, string> = {
mail: "Почта - QOutlook"
};
function dispatchQOfficeCommand(command: QOfficeCommand) {
window.dispatchEvent(new CustomEvent("qoffice-command", { detail: { command } }));
}
function keepActiveEditorFocus(event: MouseEvent<HTMLButtonElement>) {
event.preventDefault();
}
export function AppShell({ activeApp, status, children }: AppShellProps) {
const statusClassName = ["statusbar", status.className].filter(Boolean).join(" ");
@@ -36,13 +45,13 @@ export function AppShell({ activeApp, status, children }: AppShellProps) {
<main className="workspace">
<header className="titlebar">
<div className="quick-access" aria-label="Панель быстрого доступа">
<button type="button" title="Сохранить" aria-label="Сохранить">
<button type="button" title="Сохранить" aria-label="Сохранить" onMouseDown={keepActiveEditorFocus} onClick={() => dispatchQOfficeCommand("save")}>
<Save size={16} />
</button>
<button type="button" title="Отменить" aria-label="Отменить">
<button type="button" title="Отменить" aria-label="Отменить" onMouseDown={keepActiveEditorFocus} onClick={() => dispatchQOfficeCommand("undo")}>
<Undo2 size={16} />
</button>
<button type="button" title="Повторить" aria-label="Повторить">
<button type="button" title="Повторить" aria-label="Повторить" onMouseDown={keepActiveEditorFocus} onClick={() => dispatchQOfficeCommand("redo")}>
<Redo2 size={16} />
</button>
<button type="button" title="Настроить панель" aria-label="Настроить панель">