Primary code functionality
This commit is contained in:
parent
4a224bd6a8
commit
29d25dc6e7
8 changed files with 282 additions and 76 deletions
32
src/utils.ts
Normal file
32
src/utils.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue