0
0
Fork 0

Change the system to not use a stylesheet at all and work based on inline styling

This commit is contained in:
Oliver Akins 2022-06-02 21:41:44 -06:00
parent 8349757af4
commit 68953651dc
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99
3 changed files with 35 additions and 109 deletions

View file

@ -1,32 +1,12 @@
import { Notice } from "obsidian";
/**
* Creates a CSS rule that is used to hide the file or folder from the file
* explorer when it is enabled.
*
* @param type The type of file it is
* @param path The full filepath of the file/folder from the root of the vault
* @returns The CSS string that is used to target the file or folder
*/
export function createStyleLine(type: string, path: string) {
return `.nav-${type} > [data-path="${path}"] { display: none; }`;
};
/**
* Locates the File Hider stylesheet within Obsidian to allow us to modify it
* dynamically, for enabling and disabling it in order to show/hide the files
* and directories in the file explorer
*
* @returns The stylesheet if it was found
*/
export function findStyleSheet() {
for (var i in document.styleSheets) {
let style = document.styleSheets[i];
//@ts-ignore
let content = style?.ownerNode?.innerText;
if (content && content.startsWith(`/* FILE HIDER */`)) {
return style;
};
export function changePathVisibility(path: string, hide: boolean) {
let n = document.querySelector(`[data-path="${path}"]`);
if (!n) {
return;
};
let p = n.parentElement
if (hide) {
p.style.display = `none`
} else {
p.style.display = ``;
};
};