diff --git a/src/filesearch.js b/src/filesearch.js
index a6cb93c..7b04240 100644
--- a/src/filesearch.js
+++ b/src/filesearch.js
@@ -1,5 +1,6 @@
const { convertFileSrc, invoke } = window.__TAURI__.core;
+import { handle_file_select } from "./filesystem.js";
var search_input = document.getElementById("file-search-dialog-input");
search_input.addEventListener('input', () => {
search_files();
@@ -17,8 +18,31 @@ function search_files(){
result_div += element;
});
console.log(result_div);
- tag_id.innerHTML = "
".concat("", result_div).concat("", "");
+ tag_id.innerHTML = result_div;
// tag_id.innerHTML = assetUrl.concat(" ", ' \n
'))
}
);
}
+
+
+let filetree = document.getElementById('file-search-results');
+// Options for the observer (which mutations to observe)
+const config = { attributes: true, childList: true, subtree: true };
+
+// Callback function to execute when mutations are observed
+const callback = (mutationList, observer) => {
+ console.log("updating on click");
+ var anchors = document.getElementsByClassName("file-search-button");
+ for (var i = 0; i < anchors.length; i++) {
+ var anchor = anchors[i];
+ anchor.onclick = function() {
+ handle_file_select(this.parentElement.id);
+ };
+ };
+
+};
+
+const observer = new MutationObserver(callback);
+
+// Start observing the target node for configured mutations
+observer.observe(filetree, config);
diff --git a/src/filesystem.js b/src/filesystem.js
index 41c2ba4..0e54e0f 100644
--- a/src/filesystem.js
+++ b/src/filesystem.js
@@ -1,7 +1,7 @@
const { convertFileSrc, invoke } = window.__TAURI__.core;
const { readTextFile } = window.__TAURI__.fs;
import { render_markdown } from "./main.js";
-function handle_file_select(filename) {
+export function handle_file_select(filename) {
if (filename.endsWith("md")) {
readTextFile(convertFileSrc(filename)).then(
(ret) => {
diff --git a/src/styles.css b/src/styles.css
index c185988..fe4634c 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -161,7 +161,8 @@ li {
}
.filetree-directory-button,
-.filetree-file-button {
+.filetree-file-button,
+.file-search-button {
background-color: transparent;
border: none;
width: 100%;
@@ -201,7 +202,6 @@ li {
}
dialog {
-
position: absolute;
top: 50%;
left: 50%;
@@ -213,11 +213,21 @@ dialog {
width: 50%;
height: 20%;
margin: auto;
+ /* display: flex; */
+ /* flex-direction: column; */
+ overflow: hidden;
}
-#file-search-dialog-input{
+
+#file-search-dialog-input {
border: solid;
border-color: var(--accent-color);
- border-top-right-radius:10px;
- border-top-left-radius:10px;
+ border-top-right-radius: 10px;
+ border-top-left-radius: 10px;
color: var(--text-color);
}
+
+#file-search-results {
+ overflow: scroll;
+ grid-column: 1;
+ grid-row: 1;
+}
\ No newline at end of file