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
+6 -1
View File
@@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";
export type QOfficeCommand = "open" | "save" | "export-pdf" | "print";
export type QOfficeCommand = "open" | "save" | "export-pdf" | "print" | "undo" | "redo";
export type QOfficeCommandHandlers = Partial<Record<QOfficeCommand, () => void | Promise<void>>>;
export function useQOfficeCommand(handlers: QOfficeCommandHandlers) {
@@ -16,6 +16,11 @@ export function useQOfficeCommand(handlers: QOfficeCommandHandlers) {
const handler = handlersRef.current[command];
if (handler) {
void handler();
return;
}
if (command === "undo" || command === "redo") {
globalThis.document.execCommand?.(command);
}
}