Skip to content

Commit 14fadaa

Browse files
committed
feat: config excalidraw
1 parent d954e4d commit 14fadaa

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

src-tauri/src/global_shortcut.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{platform, window};
88
const DEFUALT_HOTKEY_A: &str = "CmdOrCtrl+Shift+A";
99
const DEFUALT_HOTKEY_S: &str = "CmdOrCtrl+Shift+S";
1010
const DEFUALT_HOTKEY_W: &str = "CmdOrCtrl+Shift+W";
11+
const DEFUALT_HOTKEY_E: &str = "CmdOrCtrl+Shift+E";
1112

1213
pub fn register_global_shortcut(app: &tauri::App) -> anyhow::Result<()> {
1314
info!("Registering global shortcuts");
@@ -22,6 +23,8 @@ pub fn register_global_shortcut(app: &tauri::App) -> anyhow::Result<()> {
2223
let shift_ctrl_s_shortcut = Shortcut::from_str(DEFUALT_HOTKEY_S)?;
2324
// capture_window: ctrl + shift + W
2425
let shift_ctrl_w_shortcut = Shortcut::from_str(DEFUALT_HOTKEY_W)?;
26+
// exit: ctrl + shift + E
27+
let shift_ctrl_e_shortcut = Shortcut::from_str(DEFUALT_HOTKEY_E)?;
2528

2629
if !shortcuts.is_registered(shift_ctrl_a_shortcut) {
2730
app.global_shortcut().register(shift_ctrl_a_shortcut)?;
@@ -35,6 +38,10 @@ pub fn register_global_shortcut(app: &tauri::App) -> anyhow::Result<()> {
3538
app.global_shortcut().register(shift_ctrl_w_shortcut)?;
3639
}
3740

41+
if !shortcuts.is_registered(shift_ctrl_e_shortcut) {
42+
app.global_shortcut().register(shift_ctrl_e_shortcut)?;
43+
}
44+
3845
Ok(())
3946
}
4047

@@ -96,6 +103,15 @@ pub fn tauri_plugin_global_shortcut() -> TauriPlugin<tauri::Wry> {
96103
info!("Capture Window Released!");
97104
}
98105
}
106+
} else if shortcut.id == Shortcut::from_str(DEFUALT_HOTKEY_E).unwrap().id {
107+
match event.state() {
108+
ShortcutState::Pressed => {
109+
window::show_main_window(app);
110+
}
111+
ShortcutState::Released => {
112+
info!("Show Main Window Released!");
113+
}
114+
}
99115
}
100116
})
101117
.build()

src/App.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1-
import { Excalidraw } from '@excalidraw/excalidraw'
1+
import { Excalidraw, MainMenu } from '@excalidraw/excalidraw'
22
import './App.css'
33

44
function App() {
5+
const renderMenu = () => {
6+
return (
7+
<MainMenu>
8+
<MainMenu.DefaultItems.LoadScene />
9+
<MainMenu.DefaultItems.SaveToActiveFile />
10+
{/* FIXME we should to test for this inside the item itself */}
11+
<MainMenu.DefaultItems.Export />
12+
{/* FIXME we should to test for this inside the item itself */}
13+
<MainMenu.DefaultItems.SaveAsImage />
14+
{/* <MainMenu.DefaultItems.SearchMenu /> */}
15+
<MainMenu.DefaultItems.Help />
16+
<MainMenu.DefaultItems.ClearCanvas />
17+
<MainMenu.Separator />
18+
<MainMenu.DefaultItems.ToggleTheme />
19+
<MainMenu.DefaultItems.ChangeCanvasBackground />
20+
</MainMenu>
21+
)
22+
}
23+
524
return (
625
<div className="container">
7-
<Excalidraw />
26+
<Excalidraw initialData={{
27+
appState: { viewBackgroundColor: '#FFFFFF00' },
28+
}}
29+
>
30+
{renderMenu()}
31+
</Excalidraw>
832
</div>
933
)
1034
}

0 commit comments

Comments
 (0)