worked on search and dedicated shortcuts file
This commit is contained in:
parent
749a0322bc
commit
4def21c97d
5 changed files with 33 additions and 25 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@
|
|||
<link rel="stylesheet" href="styles.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tauri App</title>
|
||||
<!-- <script src="./main.js"></script> -->
|
||||
<script type="module" src="./main.js" defer></script>
|
||||
<!-- <script src="./ui.js"></script> -->
|
||||
<script type="module" src="./ui.js" defer></script>
|
||||
<!-- <script src="./filesystem.js"></script> -->
|
||||
<script type="module" src="./filesystem.js" defer></script>
|
||||
<script type="module" src="./shortcuts.js" defer></script>
|
||||
<script type="text/javascript" src="./main.js"></script>
|
||||
<script type="text/javascript" src="./filesystem.js"></script>
|
||||
<script type="text/javascript" src="./shortcuts.js"></script>
|
||||
|
||||
<script src="//unpkg.com/force-graph"></script>
|
||||
</head>
|
||||
|
|
|
|||
22
src/main.js
22
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 = {
|
||||
|
|
|
|||
17
src/shortcuts.js
Normal file
17
src/shortcuts.js
Normal file
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
13
src/ui.js
13
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue