1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-02 03:25:53 +01:00

Full Screen mode (#1212)

This commit is contained in:
Mohit kumar Bajoria 2020-04-06 03:17:13 +05:30 committed by GitHub
parent 81b38d8808
commit 2de4fe29ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 7 deletions

9
.gitignore vendored

@ -1,7 +1,10 @@
.DS_Store
.vscode
*.log
.DS_Store
.envrc
.now
.vscode
build
firebase/
logs
node_modules
npm-debug.log*
@ -9,5 +12,3 @@ static
yarn-debug.log*
yarn-error.log*
yarn.lock
.envrc
firebase/

@ -4,6 +4,8 @@ import { ToolButton } from "../components/ToolButton";
import { t } from "../i18n";
import { showSelectedShapeActions } from "../element";
import { register } from "./register";
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
import { KEYS } from "../keys";
export const actionToggleCanvasMenu = register({
name: "toggleCanvasMenu",
@ -45,3 +47,19 @@ export const actionToggleEditMenu = register({
/>
),
});
export const actionFullScreen = register({
name: "toggleFullScreen",
perform: () => {
if (!isFullScreen()) {
allowFullScreen();
}
if (isFullScreen()) {
exitFullScreen();
}
return {
commitToHistory: false,
};
},
keyTest: (event) => event.keyCode === KEYS.F_KEY_CODE,
});

@ -36,4 +36,8 @@ export {
} from "./actionExport";
export { actionCopyStyles, actionPasteStyles } from "./actionStyles";
export { actionToggleCanvasMenu, actionToggleEditMenu } from "./actionMenu";
export {
actionToggleCanvasMenu,
actionToggleEditMenu,
actionFullScreen,
} from "./actionMenu";

@ -48,7 +48,8 @@ export type ActionName =
| "zoomIn"
| "zoomOut"
| "resetZoom"
| "changeFontFamily";
| "changeFontFamily"
| "toggleFullScreen";
export interface Action {
name: ActionName;

@ -219,6 +219,7 @@ export const ShortcutsDialog = ({ onClose }: { onClose?: () => void }) => {
title={t("buttons.resetZoom")}
shortcuts={[getShortcutKey("CtrlOrCmd+0", "")]}
/>
<Shortcut title={t("buttons.toggleFullScreen")} shortcuts={["F"]} />
</ShortcutIsland>
</div>
<Footer />

@ -13,6 +13,7 @@ export const KEYS = {
TAB: "Tab",
SPACE: " ",
QUESTION_MARK: "?",
F_KEY_CODE: 70,
} as const;
export type Key = keyof typeof KEYS;

@ -69,7 +69,8 @@
"undo": "Undo",
"redo": "Redo",
"roomDialog": "Start live collaboration",
"createNewRoom": "Create new room"
"createNewRoom": "Create new room",
"toggleFullScreen": "Toggle full screen"
},
"alerts": {
"clearReset": "This will clear the whole canvas. Are you sure?",

@ -144,6 +144,14 @@ export function resetCursor() {
document.documentElement.style.cursor = "";
}
export const isFullScreen = () =>
document.fullscreenElement?.nodeName === "HTML";
export const allowFullScreen = () =>
document.documentElement.requestFullscreen();
export const exitFullScreen = () => document.exitFullscreen();
export const getShortcutKey = (shortcut: string, prefix = " — "): string => {
const isMac = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
if (isMac) {