mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix code style issues
This commit is contained in:
parent
4c3e186d0b
commit
62c4b5e149
21 changed files with 176 additions and 176 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import esbuild from 'esbuild';
|
||||
import process from 'process';
|
||||
import builtins from 'builtin-modules'
|
||||
|
||||
const banner =
|
||||
|
|
@ -35,7 +35,7 @@ esbuild.build({
|
|||
format: 'cjs',
|
||||
watch: !prod,
|
||||
target: 'es2018',
|
||||
logLevel: "info",
|
||||
logLevel: 'info',
|
||||
sourcemap: prod ? false : 'inline',
|
||||
treeShaking: true,
|
||||
outfile: 'main.js',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import FolderOverviewPlugin from "./main";
|
||||
import FolderOverviewPlugin from './main';
|
||||
|
||||
export function registerCommands(plugin: FolderOverviewPlugin) {
|
||||
plugin.addCommand({
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ export class FileExplorerOverview {
|
|||
}
|
||||
if (excludedFolder?.excludeFromFolderOverview) { return; }
|
||||
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon right-triangle"><path d="M3 8L12 17L21 8"></path></svg>';
|
||||
const svg = '<svg xmlns='http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon right-triangle"><path d="M3 8L12 17L21 8'></path></svg>';
|
||||
if (yaml.includeTypes.includes('folder')) {
|
||||
folderElement = childrenElement.createDiv({
|
||||
cls: 'tree-item nav-folder',
|
||||
|
|
@ -242,7 +242,7 @@ export class FileExplorerOverview {
|
|||
const { draggable } = plugin.app.dragManager;
|
||||
if (draggable && draggable.file instanceof TFolder) {
|
||||
folderElement?.classList.add('is-being-dragged-over');
|
||||
plugin.app.dragManager.setAction(window.i18next.t("interface.drag-and-drop.move-into-folder", { folder: child.name }));
|
||||
plugin.app.dragManager.setAction(window.i18next.t('interface.drag-and-drop.move-into-folder', { folder: child.name }));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -337,7 +337,7 @@ export class FileExplorerOverview {
|
|||
e.preventDefault();
|
||||
const { draggable } = plugin.app.dragManager;
|
||||
if (draggable && draggable.file instanceof TFolder) {
|
||||
plugin.app.dragManager.setAction(window.i18next.t("interface.drag-and-drop.move-into-folder", { folder: child.parent?.name || '' }));
|
||||
plugin.app.dragManager.setAction(window.i18next.t('interface.drag-and-drop.move-into-folder', { folder: child.parent?.name || '' }));
|
||||
const folderEL = folderOverview.getElFromOverview(child.parent?.path || '')
|
||||
if (folderEL) {
|
||||
folderEL.parentElement?.classList.add('is-being-dragged-over');
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ export class FolderOverview {
|
|||
fileMenu.addSeparator();
|
||||
|
||||
fileMenu.addItem((item) => {
|
||||
item.setTitle(window.i18next.t("plugins.file-explorer.menu-opt-rename"));
|
||||
item.setTitle(window.i18next.t('plugins.file-explorer.menu-opt-rename'));
|
||||
item.setIcon('pencil');
|
||||
item.onClick(async () => {
|
||||
plugin.app.fileManager.promptForFileRename(file)
|
||||
|
|
@ -387,7 +387,7 @@ export class FolderOverview {
|
|||
});
|
||||
|
||||
fileMenu.addItem((item) => {
|
||||
item.setTitle(window.i18next.t("plugins.file-explorer.menu-opt-delete"));
|
||||
item.setTitle(window.i18next.t('plugins.file-explorer.menu-opt-delete'));
|
||||
item.setIcon('trash');
|
||||
item.dom.addClass('is-warning');
|
||||
item.dom.setAttribute('data-section', 'danger')
|
||||
|
|
@ -398,7 +398,7 @@ export class FolderOverview {
|
|||
|
||||
fileMenu.addSeparator();
|
||||
|
||||
plugin.app.workspace.trigger('file-menu', fileMenu, file, "folder-overview-file-context-menu", null);
|
||||
plugin.app.workspace.trigger('file-menu', fileMenu, file, 'folder-overview-file-context-menu', null);
|
||||
fileMenu.showAtPosition({ x: e.pageX, y: e.pageY });
|
||||
}
|
||||
|
||||
|
|
@ -429,12 +429,12 @@ export class FolderOverview {
|
|||
|
||||
folderMenu.addSeparator();
|
||||
|
||||
plugin.app.workspace.trigger('file-menu', folderMenu, folder, "folder-overview-folder-context-menu", null);
|
||||
plugin.app.workspace.trigger('file-menu', folderMenu, folder, 'folder-overview-folder-context-menu', null);
|
||||
folderMenu.showAtPosition({ x: e.pageX, y: e.pageY });
|
||||
}
|
||||
|
||||
getElFromOverview(path: string): HTMLElement | null {
|
||||
const el = this.listEl.querySelector(`[data-path="${CSS.escape(path)}"]`) as HTMLElement | null;
|
||||
const el = this.listEl.querySelector(`[data-path='${CSS.escape(path)}']`) as HTMLElement | null;
|
||||
return el;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { ListComponent } from '../utils/ListComponent';
|
|||
import { updateYaml } from '../FolderOverview';
|
||||
import { FolderSuggest } from '../suggesters/FolderSuggester';
|
||||
import { getFolderPathFromString } from '../utils/functions';
|
||||
import { createOverviewSettings } from "../settings";
|
||||
import { createOverviewSettings } from '../settings';
|
||||
import FolderOverviewPlugin from 'src/main';
|
||||
import FolderNotesPlugin from '../../../main';
|
||||
export class FolderOverviewSettings extends Modal {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CustomEventEmitter } from "./EventEmitter";
|
||||
import { CustomEventEmitter } from './EventEmitter';
|
||||
|
||||
export class ListComponent {
|
||||
emitter: CustomEventEmitter;
|
||||
|
|
@ -54,7 +54,7 @@ export class ListComponent {
|
|||
}
|
||||
span.setAttribute('extension', value);
|
||||
const removeSpan = span.createEl('span', { cls: 'ofn-list-item-remove setting-hotkey-icon' });
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>';
|
||||
const svg = '<svg xmlns='http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18'></line></svg>';
|
||||
const svgElement = removeSpan.createEl('span', { cls: 'ofn-list-item-remove-icon' });
|
||||
svgElement.innerHTML = svg;
|
||||
removeSpan.onClickEvent((e) => {
|
||||
|
|
@ -73,7 +73,7 @@ export class ListComponent {
|
|||
|
||||
addResetButton() {
|
||||
const resetButton = this.controlEl.createEl('span', { cls: 'clickable-icon setting-restore-hotkey-button' });
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-rotate-ccw"><path d="M3 2v6h6"></path><path d="M3 13a9 9 0 1 0 3-7.7L3 8"></path></svg>';
|
||||
const svg = '<svg xmlns='http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-rotate-ccw"><path d="M3 2v6h6"></path><path d="M3 13a9 9 0 1 0 3-7.7L3 8'></path></svg>';
|
||||
resetButton.innerHTML = svg;
|
||||
resetButton.onClickEvent((e) => {
|
||||
this.setValues(this.defaultValues);
|
||||
|
|
@ -83,7 +83,7 @@ export class ListComponent {
|
|||
|
||||
removeValue(value: string) {
|
||||
this.values = this.values.filter((v) => v !== value);
|
||||
this.listEl.find(`[extension="${value}"]`).remove();
|
||||
this.listEl.find(`[extension='${value}']`).remove();
|
||||
this.emit('remove', value);
|
||||
this.emit('update', this.values);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CustomEventEmitter } from "src/events/EventEmitter";
|
||||
import { CustomEventEmitter } from 'src/events/EventEmitter';
|
||||
|
||||
export class ListComponent {
|
||||
emitter: CustomEventEmitter;
|
||||
|
|
@ -54,7 +54,7 @@ export class ListComponent {
|
|||
}
|
||||
span.setAttribute('extension', value);
|
||||
const removeSpan = span.createEl('span', { cls: 'ofn-list-item-remove setting-hotkey-icon' });
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>';
|
||||
const svg = '<svg xmlns='http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18'></line></svg>';
|
||||
const svgElement = removeSpan.createEl('span', { cls: 'ofn-list-item-remove-icon' });
|
||||
svgElement.innerHTML = svg;
|
||||
removeSpan.onClickEvent((e) => {
|
||||
|
|
@ -73,7 +73,7 @@ export class ListComponent {
|
|||
|
||||
addResetButton() {
|
||||
const resetButton = this.controlEl.createEl('span', { cls: 'clickable-icon setting-restore-hotkey-button' });
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-rotate-ccw"><path d="M3 2v6h6"></path><path d="M3 13a9 9 0 1 0 3-7.7L3 8"></path></svg>';
|
||||
const svg = '<svg xmlns='http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-rotate-ccw"><path d="M3 2v6h6"></path><path d="M3 13a9 9 0 1 0 3-7.7L3 8'></path></svg>';
|
||||
resetButton.innerHTML = svg;
|
||||
resetButton.onClickEvent((e) => {
|
||||
this.setValues(this.defaultValues);
|
||||
|
|
@ -83,7 +83,7 @@ export class ListComponent {
|
|||
|
||||
removeValue(value: string) {
|
||||
this.values = this.values.filter((v) => v !== value);
|
||||
this.listEl.find(`[extension="${value}"]`).remove();
|
||||
this.listEl.find(`[extension='${value}']`).remove();
|
||||
this.emit('remove', value);
|
||||
this.emit('update', this.values);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { WorkspaceLeaf, App } from "obsidian";
|
||||
import { WorkspaceLeaf, App } from 'obsidian';
|
||||
|
||||
export async function openExcalidrawView(leaf: WorkspaceLeaf) {
|
||||
const {excalidraw, excalidrawEnabled} = await getExcalidrawPlugin(this.app);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ tags: [excalidraw]
|
|||
%%
|
||||
# Drawing
|
||||
\`\`\`json
|
||||
{"type":"excalidraw","version":2,"source":"https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.9.20","elements":[],"appState":{"gridSize":null,"viewBackgroundColor":"#ffffff"}}
|
||||
{'type":"excalidraw","version":2,"source":"https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.9.20","elements":[],"appState":{"gridSize":null,"viewBackgroundColor":"#ffffff'}}
|
||||
\`\`\`
|
||||
%%`;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,150 +5,150 @@ import { getFolder, getFolderNote } from 'src/functions/folderNoteFunctions';
|
|||
import { getFileExplorer } from './utils';
|
||||
|
||||
export function loadFileClasses(forceReload = false, plugin: FolderNotesPlugin) {
|
||||
if (plugin.activeFileExplorer === getFileExplorer(plugin) && !forceReload) { return; }
|
||||
plugin.activeFileExplorer = getFileExplorer(plugin);
|
||||
plugin.app.vault.getAllLoadedFiles().forEach(async (file) => {
|
||||
if (!(file instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(plugin, file.path);
|
||||
if (!folderNote) {
|
||||
removeCSSClassFromEL(file?.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(file?.path, 'only-has-folder-note', plugin);
|
||||
plugin.isEmptyFolderNoteFolder(file)
|
||||
return;
|
||||
}
|
||||
if (plugin.activeFileExplorer === getFileExplorer(plugin) && !forceReload) { return; }
|
||||
plugin.activeFileExplorer = getFileExplorer(plugin);
|
||||
plugin.app.vault.getAllLoadedFiles().forEach(async (file) => {
|
||||
if (!(file instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(plugin, file.path);
|
||||
if (!folderNote) {
|
||||
removeCSSClassFromEL(file?.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(file?.path, 'only-has-folder-note', plugin);
|
||||
plugin.isEmptyFolderNoteFolder(file);
|
||||
return;
|
||||
}
|
||||
|
||||
const excludedFolder = await getExcludedFolder(plugin, file.path, true);
|
||||
// cleanup after ourselves
|
||||
// Incase settings have changed
|
||||
if (excludedFolder?.disableFolderNote) {
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
removeCSSClassFromEL(file.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(file?.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
if (!excludedFolder?.hideNote) {
|
||||
addCSSClassToTitleEL(folderNote.path, 'is-folder-note', plugin);
|
||||
}
|
||||
addCSSClassesToFolder(file, plugin);
|
||||
}
|
||||
});
|
||||
const excludedFolder = await getExcludedFolder(plugin, file.path, true);
|
||||
// cleanup after ourselves
|
||||
// Incase settings have changed
|
||||
if (excludedFolder?.disableFolderNote) {
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
removeCSSClassFromEL(file.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(file?.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
if (!excludedFolder?.hideNote) {
|
||||
addCSSClassToTitleEL(folderNote.path, 'is-folder-note', plugin);
|
||||
}
|
||||
addCSSClassesToFolder(file, plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export async function applyCSSClassesToFolder(folderPath: string, plugin: FolderNotesPlugin) {
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (!folder || !(folder instanceof TFolder)) { return; }
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (!folder || !(folder instanceof TFolder)) { return; }
|
||||
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
|
||||
if (!folderNote) {
|
||||
removeCSSClassFromEL(folder?.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder?.path, 'only-has-folder-note', plugin);
|
||||
return;
|
||||
}
|
||||
if (!folderNote) {
|
||||
removeCSSClassFromEL(folder?.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder?.path, 'only-has-folder-note', plugin);
|
||||
return;
|
||||
}
|
||||
|
||||
const excludedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
const excludedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
|
||||
if (excludedFolder?.disableFolderNote) {
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder?.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
if (!excludedFolder?.hideNote) {
|
||||
addCSSClassToFolderNote(folderNote, plugin);
|
||||
}
|
||||
addCSSClassesToFolder(folder, plugin);
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
if (excludedFolder?.disableFolderNote) {
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder?.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
if (!excludedFolder?.hideNote) {
|
||||
addCSSClassToFolderNote(folderNote, plugin);
|
||||
}
|
||||
addCSSClassesToFolder(folder, plugin);
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
|
||||
addCSSClassesToBothFolderAndNote(folderNote, folder, plugin);
|
||||
addCSSClassesToBothFolderAndNote(folderNote, folder, plugin);
|
||||
}
|
||||
|
||||
export async function applyCSSClassesToFolderNote(filePath: string, plugin: FolderNotesPlugin) {
|
||||
const file = plugin.app.vault.getAbstractFileByPath(filePath);
|
||||
if (!file || !(file instanceof TFile)) { return; }
|
||||
const file = plugin.app.vault.getAbstractFileByPath(filePath);
|
||||
if (!file || !(file instanceof TFile)) { return; }
|
||||
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder || !(folder instanceof TFolder)) { return; }
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder || !(folder instanceof TFolder)) { return; }
|
||||
|
||||
applyCSSClassesToFolder(folder.path, plugin);
|
||||
applyCSSClassesToFolder(folder.path, plugin);
|
||||
|
||||
}
|
||||
|
||||
export function addCSSClassesToBothFolderAndNote(file: TFile, folder: TFolder, plugin: FolderNotesPlugin) {
|
||||
addCSSClassToFolderNote(file, plugin);
|
||||
addCSSClassesToFolder(folder, plugin);
|
||||
addCSSClassToFolderNote(file, plugin);
|
||||
addCSSClassesToFolder(folder, plugin);
|
||||
}
|
||||
|
||||
export function removeCSSClassesFromBothFolderAndNote(folder: TFolder, file: TFile, plugin: FolderNotesPlugin) {
|
||||
removeCSSClassFromFolderNote(file, plugin);
|
||||
removeCSSClassesFromFolder(folder, plugin);
|
||||
removeCSSClassFromFolderNote(file, plugin);
|
||||
removeCSSClassesFromFolder(folder, plugin);
|
||||
}
|
||||
|
||||
export function addCSSClassesToFolder(folder: TFolder, plugin: FolderNotesPlugin) {
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
|
||||
export function addCSSClassToFolderNote(file: TFile, plugin: FolderNotesPlugin) {
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note', plugin);
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note', plugin);
|
||||
}
|
||||
|
||||
export function removeCSSClassFromFolderNote(file: TFile, plugin: FolderNotesPlugin) {
|
||||
removeCSSClassFromEL(file.path, 'is-folder-note', plugin);
|
||||
removeCSSClassFromEL(file.path, 'is-folder-note', plugin);
|
||||
}
|
||||
|
||||
export function removeCSSClassesFromFolder(folder: TFolder, plugin: FolderNotesPlugin) {
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
|
||||
export async function addCSSClassToTitleEL(path: string, cssClass: string, plugin: FolderNotesPlugin, waitForCreate = false, count = 0) {
|
||||
const fileExplorerItem = getEl(path, plugin);
|
||||
if (!fileExplorerItem) {
|
||||
if (waitForCreate && count < 5) {
|
||||
// sleep for a second for the file-explorer event to catch up
|
||||
// this is annoying as in most scanarios our plugin recieves the event before file explorer
|
||||
// If we could guarrantee load order it wouldn't be an issue but we can't
|
||||
// realise this is racey and needs to be fixed.
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
addCSSClassToTitleEL(path, cssClass, plugin, waitForCreate, count + 1);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
fileExplorerItem.addClass(cssClass);
|
||||
const viewHeaderItems = document.querySelectorAll(`[data-path="${CSS.escape(path)}"]`);
|
||||
viewHeaderItems.forEach((item) => {
|
||||
item.addClass(cssClass);
|
||||
});
|
||||
const fileExplorerItem = getEl(path, plugin);
|
||||
if (!fileExplorerItem) {
|
||||
if (waitForCreate && count < 5) {
|
||||
// sleep for a second for the file-explorer event to catch up
|
||||
// this is annoying as in most scanarios our plugin recieves the event before file explorer
|
||||
// If we could guarrantee load order it wouldn't be an issue but we can't
|
||||
// realise this is racey and needs to be fixed.
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
addCSSClassToTitleEL(path, cssClass, plugin, waitForCreate, count + 1);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
fileExplorerItem.addClass(cssClass);
|
||||
const viewHeaderItems = document.querySelectorAll(`[data-path='${CSS.escape(path)}']`);
|
||||
viewHeaderItems.forEach((item) => {
|
||||
item.addClass(cssClass);
|
||||
});
|
||||
}
|
||||
|
||||
export function removeCSSClassFromEL(path: string | undefined, cssClass: string, plugin: FolderNotesPlugin) {
|
||||
if (!path) return;
|
||||
const fileExplorerItem = getEl(path, plugin);
|
||||
const viewHeaderItems = document.querySelectorAll(`[data-path="${CSS.escape(path)}"]`);
|
||||
viewHeaderItems.forEach((item) => {
|
||||
item.removeClass(cssClass);
|
||||
});
|
||||
if (!fileExplorerItem) { return; }
|
||||
fileExplorerItem.removeClass(cssClass);
|
||||
if (!path) return;
|
||||
const fileExplorerItem = getEl(path, plugin);
|
||||
const viewHeaderItems = document.querySelectorAll(`[data-path='${CSS.escape(path)}']`);
|
||||
viewHeaderItems.forEach((item) => {
|
||||
item.removeClass(cssClass);
|
||||
});
|
||||
if (!fileExplorerItem) { return; }
|
||||
fileExplorerItem.removeClass(cssClass);
|
||||
}
|
||||
|
||||
export function getEl(path: string, plugin: FolderNotesPlugin): HTMLElement | null {
|
||||
const fileExplorer = getFileExplorer(plugin);
|
||||
if (!fileExplorer) { return null; }
|
||||
if (!fileExplorer.view) { return null; }
|
||||
if (!fileExplorer.view.fileItems) { return null; }
|
||||
const fileExplorerItem = fileExplorer.view.fileItems[path];
|
||||
if (!fileExplorerItem) { return null; }
|
||||
if (fileExplorerItem.selfEl) return fileExplorerItem.selfEl;
|
||||
return fileExplorerItem.titleEl;
|
||||
const fileExplorer = getFileExplorer(plugin);
|
||||
if (!fileExplorer) { return null; }
|
||||
if (!fileExplorer.view) { return null; }
|
||||
if (!fileExplorer.view.fileItems) { return null; }
|
||||
const fileExplorerItem = fileExplorer.view.fileItems[path];
|
||||
if (!fileExplorerItem) { return null; }
|
||||
if (fileExplorerItem.selfEl) return fileExplorerItem.selfEl;
|
||||
return fileExplorerItem.titleEl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
import { TFile, TFolder } from "obsidian";
|
||||
import { FileExplorerWorkspaceLeaf } from "src/globals";
|
||||
import FolderNotesPlugin from "src/main";
|
||||
import { FileExplorerLeaf } from "obsidian-typings";
|
||||
import { TFile, TFolder } from 'obsidian';
|
||||
import { FileExplorerWorkspaceLeaf } from 'src/globals';
|
||||
import FolderNotesPlugin from 'src/main';
|
||||
import { FileExplorerLeaf } from 'obsidian-typings';
|
||||
|
||||
export function getFileNameFromPathString(path: string): string {
|
||||
return path.substring(path.lastIndexOf('/') >= 0 ? path.lastIndexOf('/') + 1 : 0);
|
||||
return path.substring(path.lastIndexOf('/') >= 0 ? path.lastIndexOf('/') + 1 : 0);
|
||||
}
|
||||
|
||||
export function getFolderNameFromPathString(path: string): string {
|
||||
if (path.endsWith('.md') || path.endsWith('.canvas')) {
|
||||
return path.split('/').slice(-2)[0];
|
||||
} else {
|
||||
return path.split('/').slice(-1)[0];
|
||||
}
|
||||
if (path.endsWith('.md') || path.endsWith('.canvas')) {
|
||||
return path.split('/').slice(-2)[0];
|
||||
} else {
|
||||
return path.split('/').slice(-1)[0];
|
||||
}
|
||||
}
|
||||
|
||||
export function removeExtension(name: string): string {
|
||||
return name.replace(/\.[^/.]+$/, '');
|
||||
return name.replace(/\.[^/.]+$/, '');
|
||||
}
|
||||
|
||||
export function getExtensionFromPathString(path: string): string {
|
||||
return path.slice(path.lastIndexOf('.') >= 0 ? path.lastIndexOf('.') : 0);
|
||||
return path.slice(path.lastIndexOf('.') >= 0 ? path.lastIndexOf('.') : 0);
|
||||
}
|
||||
|
||||
export function getFolderPathFromString(path: string): string {
|
||||
const subString = path.lastIndexOf('/') >= 0 ? path.lastIndexOf('/') : 0;
|
||||
const folderPath = path.substring(0, subString);
|
||||
if (folderPath === '') {
|
||||
return '/';
|
||||
} else {
|
||||
return folderPath;
|
||||
}
|
||||
const subString = path.lastIndexOf('/') >= 0 ? path.lastIndexOf('/') : 0;
|
||||
const folderPath = path.substring(0, subString);
|
||||
if (folderPath === '') {
|
||||
return '/';
|
||||
} else {
|
||||
return folderPath;
|
||||
}
|
||||
}
|
||||
|
||||
export function getParentFolderPath(path: string): string {
|
||||
return this.getFolderPathFromString(this.getFolderPathFromString(path));
|
||||
return this.getFolderPathFromString(this.getFolderPathFromString(path));
|
||||
}
|
||||
|
||||
export function getFileExplorer(plugin: FolderNotesPlugin) {
|
||||
return plugin.app.workspace.getLeavesOfType('file-explorer')[0] as any as FileExplorerWorkspaceLeaf;
|
||||
return plugin.app.workspace.getLeavesOfType('file-explorer')[0] as any as FileExplorerWorkspaceLeaf;
|
||||
}
|
||||
|
||||
export function getFileExplorerView(plugin: FolderNotesPlugin) {
|
||||
return getFileExplorer(plugin).view;
|
||||
return getFileExplorer(plugin).view;
|
||||
}
|
||||
|
||||
export function getFocusedItem(plugin: FolderNotesPlugin) {
|
||||
const fileExplorer = getFileExplorer(plugin) as any as FileExplorerLeaf;
|
||||
const focusedItem = fileExplorer.view.tree.focusedItem
|
||||
return focusedItem;
|
||||
const fileExplorer = getFileExplorer(plugin) as any as FileExplorerLeaf;
|
||||
const focusedItem = fileExplorer.view.tree.focusedItem
|
||||
return focusedItem;
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ import './functions/ListComponent';
|
|||
import { handleDelete } from './events/handleDelete';
|
||||
import { addCSSClassToTitleEL, getEl, loadFileClasses } from './functions/styleFunctions';
|
||||
import { getExcludedFolder } from './ExcludeFolders/functions/folderFunctions';
|
||||
import { ClipBoardManager, FileExplorerView, InternalPlugin } from 'obsidian-typings'
|
||||
import { FileExplorerView, InternalPlugin } from 'obsidian-typings'
|
||||
import { getFocusedItem } from './functions/utils';
|
||||
import { FOLDER_OVERVIEW_VIEW, FolderOverviewView } from './folderOverview/src/view';
|
||||
import {getFolderPathFromString } from './functions/utils';
|
||||
|
|
@ -173,7 +173,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
editMode.clipboardManager.constructor.prototype.handleDragOver = function (evt, ...args) {
|
||||
const { draggable } = plugin.app.dragManager;
|
||||
if (draggable && draggable.file instanceof TFolder && getFolderNote(plugin, draggable.file.path)) {
|
||||
plugin.app.dragManager.setAction(window.i18next.t("interface.drag-and-drop.insert-link-here"));
|
||||
plugin.app.dragManager.setAction(window.i18next.t('interface.drag-and-drop.insert-link-here'));
|
||||
} else {
|
||||
originalHandleDragOver.call(this, evt, ...args);
|
||||
}
|
||||
|
|
@ -186,9 +186,9 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
const { draggable } = plugin.app.dragManager;
|
||||
if (draggable && draggable.file instanceof TFolder && getFolderNote(plugin, draggable.file.path)) {
|
||||
const folderNote = getFolderNote(plugin, draggable.file.path);
|
||||
if (draggable?.type === "folder" && draggable.file instanceof TFolder && folderNote) {
|
||||
if (draggable?.type === 'folder' && draggable.file instanceof TFolder && folderNote) {
|
||||
draggable.file = folderNote;
|
||||
draggable.type = "file";
|
||||
draggable.type = 'file';
|
||||
}
|
||||
}
|
||||
return originalHandleDrop.call(this, evt, ...args);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export default class AddSupportedFileModal extends Modal {
|
|||
});
|
||||
contentEl.createEl('h2', { text: 'Extension name' });
|
||||
new Setting(contentEl)
|
||||
.setName('Enter the name of the extension (only the short form, e.g. "md")')
|
||||
.setName('Enter the name of the extension (only the short form, e.g. 'md')')
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue('')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { FuzzySuggestModal, Notice, TFile } from "obsidian";
|
||||
import FolderNotesPlugin from "src/main";
|
||||
import { createFolderNote } from "src/functions/folderNoteFunctions";
|
||||
import { FuzzySuggestModal, Notice, TFile } from 'obsidian';
|
||||
import FolderNotesPlugin from 'src/main';
|
||||
import { createFolderNote } from 'src/functions/folderNoteFunctions';
|
||||
export class AskForExtensionModal extends FuzzySuggestModal<string> {
|
||||
plugin: FolderNotesPlugin
|
||||
extension: string
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ export default class ConfirmationModal extends Modal {
|
|||
.setDesc('Choose the file extension for the folder notes.')
|
||||
.addDropdown((cb) => {
|
||||
this.plugin.settings.supportedFileTypes.forEach((extension) => {
|
||||
cb.addOption("." + extension, extension);
|
||||
cb.addOption('.' + extension, extension);
|
||||
});
|
||||
cb.setValue(this.extension);
|
||||
cb.onChange(async (value) => {
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ export default class DeleteConfirmationModal extends Modal {
|
|||
const modalTitle = contentEl.createDiv({ cls: 'fn-modal-title' });
|
||||
const modalContent = contentEl.createDiv({ cls: 'fn-modal-content' });
|
||||
modalTitle.createEl('h2', { text: 'Delete folder note' });
|
||||
modalContent.createEl('p', { text: `Are you sure you want to delete the folder note "${this.file.name}" ?` });
|
||||
modalContent.createEl('p', { text: `Are you sure you want to delete the folder note '${this.file.name}' ?` });
|
||||
switch (plugin.settings.deleteFilesAction) {
|
||||
case 'trash':
|
||||
modalContent.createEl('p', { text: 'It will be moved to your system trash.' });
|
||||
break;
|
||||
case 'obsidianTrash':
|
||||
modalContent.createEl('p', { text: 'It will be moved to your Obsidian trash, which is located in the ".trash" hidden folder in your vault.' });
|
||||
modalContent.createEl('p', { text: 'It will be moved to your Obsidian trash, which is located in the '.trash' hidden folder in your vault.' });
|
||||
break;
|
||||
case 'delete':
|
||||
modalContent.createEl('p', { text: 'It will be permanently deleted.' }).setCssStyles({ color: 'red' });
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { addExcludeFolderListItem, addExcludedFolder } from 'src/ExcludeFolders/
|
|||
import { ExcludedFolder } from 'src/ExcludeFolders/ExcludeFolder';
|
||||
import { addExcludePatternListItem } from 'src/ExcludeFolders/functions/patternFunctions';
|
||||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
import ExcludedFolderSettings from 'src/ExcludeFolders/modals/ExcludeFolderSettings';
|
||||
import PatternSettings from 'src/ExcludeFolders/modals/PatternSettings';
|
||||
import WhitelistedFoldersSettings from 'src/ExcludeFolders/modals/WhitelistedFoldersSettings';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Setting } from "obsidian";
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
export async function renderFileExplorer(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { PluginSettingTab, Setting, TFolder } from "obsidian";
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { PluginSettingTab, Setting, TFolder } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
import { ListComponent } from 'src/functions/ListComponent';
|
||||
import { includeTypes } from 'src/folderOverview/src/FolderOverview';
|
||||
import { FolderSuggest } from "src/suggesters/FolderSuggester";
|
||||
import { createOverviewSettings } from "src/folderOverview/src/settings";
|
||||
import { FolderSuggest } from 'src/suggesters/FolderSuggester';
|
||||
import { createOverviewSettings } from 'src/folderOverview/src/settings';
|
||||
|
||||
export async function renderFolderOverview(settingsTab: SettingsTab) {
|
||||
const { plugin } = settingsTab;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { Setting, Platform, SettingTab } from "obsidian";
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { Setting, Platform, SettingTab } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
import { ListComponent } from '../functions/ListComponent';
|
||||
import AddSupportedFileModal from '../modals/AddSupportedFileType';
|
||||
import { FrontMatterTitlePluginHandler } from '../events/FrontMatterTitle';
|
||||
import ConfirmationModal from "../modals/ConfirmCreation";
|
||||
import ConfirmationModal from '../modals/ConfirmCreation';
|
||||
import { TemplateSuggest } from '../suggesters/TemplateSuggester';
|
||||
import { loadFileClasses } from "../functions/styleFunctions";
|
||||
import { loadFileClasses } from '../functions/styleFunctions';
|
||||
|
||||
export async function renderGeneral(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
|
|
@ -36,7 +36,7 @@ export async function renderGeneral(settingsTab: SettingsTab) {
|
|||
if (settingsTab.plugin.settings.newFolderNoteName !== '{{folder_name}}') {
|
||||
new Setting(containerEl)
|
||||
.setName('Use folder name instead of folder note name in the tab title')
|
||||
.setDesc('When you\'re using a folder note name like "folder note" and have multiple folder notes open you can\'t separate them anymore by their name. This setting uses the folder name instead and allows you to indentify the different files.')
|
||||
.setDesc('When you\'re using a folder note name like 'folder note' and have multiple folder notes open you can\'t separate them anymore by their name. This setting uses the folder name instead and allows you to indentify the different files.')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.tabManagerEnabled)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Setting } from "obsidian";
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
export async function renderPath(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
new Setting(containerEl)
|
||||
|
|
|
|||
Loading…
Reference in a new issue