file loadig and file tree working

This commit is contained in:
Iaphetes 2024-12-28 23:41:17 +01:00
parent c2cc84f9dc
commit 869157c08c
15 changed files with 608 additions and 128 deletions

View file

@ -1,5 +1,4 @@
const { convertFileSrc, invoke } = window.__TAURI__.core;
// const { invoke } = window.__TAURI__.core;
const { homeDir, join } = window.__TAURI__.path;
const { readFile } = window.__TAURI__.fs;
@ -9,16 +8,10 @@ const filePath = await join(appDataDirPath, 'Pictures/wallpaper.png');
const assetUrl = convertFileSrc(filePath);
let text = "";
// window.addEventListener("DOMCharacterDataModified", () => {
// var tag_id = document.getElementById('rendered_markdown');
// tag_id.innerHTML = "<p>HI</p>"
// window.addEventListener("DOMContentLoaded", () => {
let textarea = document.getElementById('markdown_input');
let placeholder_path = "FILEPATH";
let path_template = convertFileSrc(placeholder_path);
let textarea = document.getElementById('markdown_input');
textarea.addEventListener('input', ()=> {
text = textarea.innerText;
var tag_id = document.getElementById('rendered_markdown');
@ -32,31 +25,7 @@ textarea.addEventListener('input', ()=> {
// });
});
document.getElementById("hide-sidebar").onclick = function() {toggle_visibility("sidebar");};
function toggle_visibility(id) {
if (document.getElementById(id).style.visibility == "hidden"){
document.getElementById(id).style.visibility = "visible";
var style = window.getComputedStyle(document.body);
document.getElementById(id).style.width = style.getPropertyValue("--sidebar-width");
}else{
document.getElementById(id).style.visibility = "hidden";
document.getElementById(id).style.width = 0;
}
}
function handleShortcut(event) {
var markdown_editor = document.getElementById('markdown_input');
if (document.activeElement === markdown_editor){
if (event.ctrlKey) {
if (event.key === "l"){
event.preventDefault();
}
}
}
}
document.addEventListener("keydown", handleShortcut);
// Random tree
// const N = 300;
// const gData = {