Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ function PuckLayout<
const rightSideBarVisible = useAppStore(
(s) => s.state.ui.rightSideBarVisible
);
const disableHotKeys = useAppStore((s) => s.state.ui.disableHotKeys);

const {
width: leftWidth,
Expand Down Expand Up @@ -498,11 +499,11 @@ function PuckLayout<
if (ready && iframe.enabled) {
const frameDoc = getFrame();

if (frameDoc) {
if (frameDoc && !disableHotKeys) {
return monitorHotkeys(frameDoc);
}
}
}, [ready, iframe.enabled]);
}, [ready, iframe.enabled, disableHotKeys]);

usePreviewModeHotkeys();

Expand Down
8 changes: 7 additions & 1 deletion packages/core/lib/use-hotkey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect } from "react";
import { create } from "zustand";
import { subscribeWithSelector } from "zustand/middleware";
import { useAppStore } from '../store';

const keys = [
"ctrl",
Expand Down Expand Up @@ -168,7 +169,12 @@ export const monitorHotkeys = (doc: Document) => {
};

export const useMonitorHotkeys = () => {
useEffect(() => monitorHotkeys(document), []);
const disableHotKeys = useAppStore((s) => s.state.ui.disableHotKeys)

useEffect(() => {
if (disableHotKeys) return;
return monitorHotkeys(document);
}, [disableHotKeys]);
};

export const useHotkey = (combo: KeyMapStrict, cb: Function) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/store/default-app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PrivateAppState } from "../types/Internal";
export const defaultAppState: PrivateAppState = {
data: { content: [], root: {}, zones: {} },
ui: {
disableHotKeys: false,
leftSideBarVisible: true,
rightSideBarVisible: true,
arrayState: {},
Expand Down
1 change: 1 addition & 0 deletions packages/core/types/AppState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type ItemWithId = {
export type ArrayState = { items: ItemWithId[]; openId: string };

export type UiState = {
disableHotKeys?: boolean;
leftSideBarVisible: boolean;
rightSideBarVisible: boolean;
leftSideBarWidth?: number | null;
Expand Down