diff --git a/src/filesystem.js b/src/filesystem.js index 99293cc..41c2ba4 100644 --- a/src/filesystem.js +++ b/src/filesystem.js @@ -1,5 +1,4 @@ const { convertFileSrc, invoke } = window.__TAURI__.core; -const { homeDir, join } = window.__TAURI__.path; const { readTextFile } = window.__TAURI__.fs; import { render_markdown } from "./main.js"; function handle_file_select(filename) { diff --git a/src/index.html b/src/index.html index eedc9c0..b4cb1ff 100644 --- a/src/index.html +++ b/src/index.html @@ -6,14 +6,13 @@ Tauri App - - - + + diff --git a/src/main.js b/src/main.js index 9be492d..9f1412a 100644 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,4 @@ const { convertFileSrc, invoke } = window.__TAURI__.core; -const { homeDir, join } = window.__TAURI__.path; -const { readFile } = window.__TAURI__.fs; - -const appDataDirPath = await homeDir(); -const filePath = await join(appDataDirPath, 'Pictures/wallpaper.png'); - -const assetUrl = convertFileSrc(filePath); let text = ""; let placeholder_path = "FILEPATH"; @@ -26,22 +19,9 @@ export function render_markdown() { } textarea.addEventListener('input', () => { render_markdown(); - - }); -const dialog = document.querySelector("dialog"); -function showSearch() { - dialog.show(); -} -document - .addEventListener("keydown", - function(event) { - if (event.key === "a") { - event.preventDefault(); - showSearch(); - } - }); + // Random tree // const N = 300; // const gData = { diff --git a/src/shortcuts.js b/src/shortcuts.js new file mode 100644 index 0000000..b528a85 --- /dev/null +++ b/src/shortcuts.js @@ -0,0 +1,17 @@ +import { showGlobalSearch, escape } from "./ui.js"; + +document + .addEventListener("keydown", + function(event) { + if (event.ctrlKey && event.key === "k") { + event.preventDefault(); + showGlobalSearch(); + + } + if (event.key == "Escape"){ + event.preventDefault(); + escape(); + } + }); + + diff --git a/src/ui.js b/src/ui.js index 2ad4199..c078c88 100644 --- a/src/ui.js +++ b/src/ui.js @@ -23,3 +23,16 @@ document.addEventListener("keydown", handleShortcut); document.getElementById("hide-sidebar").onclick = function () { toggle_visibility("sidebar"); }; +const global_search_dialog = document.querySelector("dialog"); +export function showGlobalSearch() { + topmost_element = "global-search"; + global_search_dialog.show(); +} + +let topmost_element = ""; + +export function escape(){ + if (topmost_element === "global-search"){ + global_search_dialog.close(); + } +}