Wire quick access commands
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user