From 6056c7056975344f5e464126d9f5c0f27e41a28b Mon Sep 17 00:00:00 2001 From: Ted Vu Date: Fri, 7 Apr 2023 22:51:36 +0700 Subject: [PATCH] [fix/web] Escape on preview mode --- apps/web/src/toolbar/preview.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/web/src/toolbar/preview.tsx b/apps/web/src/toolbar/preview.tsx index 80cad1e..eef7e8e 100644 --- a/apps/web/src/toolbar/preview.tsx +++ b/apps/web/src/toolbar/preview.tsx @@ -1,6 +1,5 @@ import { LogIcon } from "@primer/octicons-react"; -import { useCallback, useEffect } from "react"; -import tinykeys from "tinykeys"; +import { useCallback } from "react"; import { Layout, LayoutState } from "../layout/type"; import { getLayoutFromPreview } from "../settings/preview/preview"; import { Settings } from "../settings/type"; @@ -21,7 +20,14 @@ export const ToolbarPreview = (props: Props): JSX.Element => { setLayout(target); }, [layout, settings, setLayout]); + const exitPreviewMode = useCallback((): void => { + if (layout !== "editor") { + setLayout("editor"); + } + }, [layout, setLayout]); + useShortcut("$mod+r", callback); + useShortcut("Escape", exitPreviewMode); return (