mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
28 lines
782 B
JavaScript
28 lines
782 B
JavaScript
"use client";
|
|
import { useContainer } from "../../player/context.js";
|
|
import { getHotkeyCoordinator } from "@videojs/core/dom";
|
|
import { useEffect, useState } from "react";
|
|
//#region src/ui/hotkey/use-hotkey-shortcut.ts
|
|
function useHotkeyShortcut(action, value) {
|
|
const container = useContainer();
|
|
const [shortcut, setShortcut] = useState({});
|
|
useEffect(() => {
|
|
if (!container || !action) {
|
|
setShortcut({});
|
|
return;
|
|
}
|
|
const coordinator = getHotkeyCoordinator(container);
|
|
const update = () => setShortcut(coordinator.getShortcut(action, value));
|
|
update();
|
|
return coordinator.subscribeShortcutChanges(update);
|
|
}, [
|
|
container,
|
|
action,
|
|
value
|
|
]);
|
|
return shortcut;
|
|
}
|
|
//#endregion
|
|
export { useHotkeyShortcut };
|
|
|
|
//# sourceMappingURL=use-hotkey-shortcut.js.map
|