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
9c8760ef7d
commit
8f131c83a8
40 changed files with 1566 additions and 1566 deletions
|
|
@ -5,7 +5,7 @@ import { ExcludedFolder } from './ExcludeFolders/ExcludeFolder';
|
|||
import { getFolderPathFromString } from './functions/utils';
|
||||
import { getExcludedFolderByPattern } from './ExcludeFolders/functions/patternFunctions';
|
||||
import { addExcludedFolder, deleteExcludedFolder, getDetachedFolder, getExcludedFolder, getExcludedFoldersByPath, updateExcludedFolder } from './ExcludeFolders/functions/folderFunctions';
|
||||
import ExcludedFolderSettings from './ExcludeFolders/modals/ExcludeFolderSettings'
|
||||
import ExcludedFolderSettings from './ExcludeFolders/modals/ExcludeFolderSettings';
|
||||
import { ExcludePattern } from './ExcludeFolders/ExcludePattern';
|
||||
import PatternSettings from './ExcludeFolders/modals/PatternSettings';
|
||||
import { applyCSSClassesToFolder } from './functions/styleFunctions';
|
||||
|
|
@ -33,7 +33,7 @@ export class Commands {
|
|||
if (!(folder instanceof TFolder)) return;
|
||||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
turnIntoFolderNote(this.plugin, file, folder, folderNote);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.plugin.addCommand({
|
||||
|
|
@ -58,8 +58,8 @@ export class Commands {
|
|||
createFolderNote(this.plugin, folder.path, true, '.' + file.extension, false, file);
|
||||
this.plugin.settings.autoCreate = automaticallyCreateFolderNote;
|
||||
this.plugin.saveSettings();
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
this.plugin.addCommand({
|
||||
id: 'create-folder-note-for-current-folder',
|
||||
|
|
@ -70,7 +70,7 @@ export class Commands {
|
|||
const folder = file.parent;
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
createFolderNote(this.plugin, folder.path, true, '.md', false);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.plugin.settings.supportedFileTypes.forEach((fileType) => {
|
||||
|
|
@ -84,7 +84,7 @@ export class Commands {
|
|||
const folder = file.parent;
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
createFolderNote(this.plugin, folder.path, true, '.' + fileType, false);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ export class Commands {
|
|||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
if (!(folderNote instanceof TFile)) return;
|
||||
deleteFolderNote(this.plugin, folderNote, true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.plugin.addCommand({
|
||||
|
|
@ -113,7 +113,7 @@ export class Commands {
|
|||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
if (!(folderNote instanceof TFile)) return;
|
||||
openFolderNote(this.plugin, folderNote);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.plugin.addCommand({
|
||||
|
|
@ -173,7 +173,7 @@ export class Commands {
|
|||
}
|
||||
return false;
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fileCommands() {
|
||||
|
|
@ -195,7 +195,7 @@ export class Commands {
|
|||
|
||||
if (folder instanceof TFolder) {
|
||||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
const excludedFolder = await getExcludedFolder(this.plugin, folder.path, true)
|
||||
const excludedFolder = await getExcludedFolder(this.plugin, folder.path, true);
|
||||
if (folderNote?.path === file.path && !excludedFolder?.detached) { return; }
|
||||
} else if (file.parent instanceof TFolder) {
|
||||
folder = file.parent;
|
||||
|
|
@ -254,8 +254,8 @@ export class Commands {
|
|||
});
|
||||
}
|
||||
if (!(file instanceof TFolder)) return;
|
||||
const excludedFolder = await getExcludedFolder(this.plugin, file.path, false)
|
||||
const detachedExcludedFolder = getDetachedFolder(this.plugin, file.path)
|
||||
const excludedFolder = await getExcludedFolder(this.plugin, file.path, false);
|
||||
const detachedExcludedFolder = getDetachedFolder(this.plugin, file.path);
|
||||
if (excludedFolder && !excludedFolder.hideNote) {
|
||||
// I'm not sure if I'm ever going to add this because of the possibility that a folder got more than one excluded
|
||||
// subMenu.addItem((item) => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export class ExcludedFolder {
|
|||
enableCollapsing: boolean;
|
||||
position: number;
|
||||
excludeFromFolderOverview: boolean;
|
||||
hideInSettings: boolean;
|
||||
hideInSettings: boolean;
|
||||
detached: boolean;
|
||||
detachedFilePath?: string;
|
||||
hideNote: boolean;
|
||||
|
|
@ -27,7 +27,7 @@ export class ExcludedFolder {
|
|||
this.position = position;
|
||||
this.excludeFromFolderOverview = plugin.settings.excludeFolderDefaultSettings.excludeFromFolderOverview;
|
||||
this.string = '';
|
||||
this.hideInSettings = false;
|
||||
this.hideInSettings = false;
|
||||
this.hideNote = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export class ExcludePattern {
|
|||
disableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
excludeFromFolderOverview: boolean;
|
||||
hideInSettings: boolean;
|
||||
hideInSettings: boolean;
|
||||
detached: boolean;
|
||||
detachedFilePath?: string;
|
||||
hideNote: boolean;
|
||||
|
|
@ -27,6 +27,6 @@ export class ExcludePattern {
|
|||
this.enableCollapsing = plugin.settings.excludePatternDefaultSettings.enableCollapsing;
|
||||
this.excludeFromFolderOverview = plugin.settings.excludePatternDefaultSettings.excludeFromFolderOverview;
|
||||
this.path = '';
|
||||
this.hideInSettings = false;
|
||||
this.hideInSettings = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ export class WhitelistedFolder {
|
|||
this.position = position;
|
||||
this.string = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export class WhitelistedPattern {
|
|||
enableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
showInFolderOverview: boolean;
|
||||
hideInSettings: boolean;
|
||||
hideInSettings: boolean;
|
||||
constructor(pattern: string, position: number, id: string | undefined, plugin: FolderNotesPlugin) {
|
||||
this.type = 'pattern';
|
||||
this.id = id || crypto.randomUUID();
|
||||
|
|
@ -20,4 +20,4 @@ export class WhitelistedPattern {
|
|||
this.string = pattern;
|
||||
this.path = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export async function getExcludedFolder(plugin: FolderNotesPlugin, path: string,
|
|||
let combinedExcludedFolders = [...matchedPatterns, ...excludedFolders];
|
||||
|
||||
if (!includeDetached) {
|
||||
combinedExcludedFolders = combinedExcludedFolders.filter(f => !f.detached)
|
||||
combinedExcludedFolders = combinedExcludedFolders.filter((f) => !f.detached);
|
||||
}
|
||||
|
||||
const propertiesToCopy: (keyof ExcludedFolder)[] = [
|
||||
|
|
@ -33,12 +33,12 @@ export async function getExcludedFolder(plugin: FolderNotesPlugin, path: string,
|
|||
'detached',
|
||||
'hideInSettings',
|
||||
'hideNote',
|
||||
'id'
|
||||
'id',
|
||||
];
|
||||
|
||||
if (combinedExcludedFolders.length > 0) {
|
||||
for (const matchedFolder of combinedExcludedFolders) {
|
||||
propertiesToCopy.forEach(property => {
|
||||
propertiesToCopy.forEach((property) => {
|
||||
if (matchedFolder[property] === true) {
|
||||
(excludedFolder as any)[property] = true;
|
||||
} else if (!matchedFolder[property]) {
|
||||
|
|
@ -74,14 +74,14 @@ export async function getExcludedFolder(plugin: FolderNotesPlugin, path: string,
|
|||
hideInSettings: false,
|
||||
detached: false,
|
||||
hideNote: false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return excludedFolder;
|
||||
}
|
||||
|
||||
export function getDetachedFolder(plugin: FolderNotesPlugin, path: string) {
|
||||
return plugin.settings.excludeFolders.find(f => f.path == path && f.detached);
|
||||
return plugin.settings.excludeFolders.find((f) => f.path == path && f.detached);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,146 +6,146 @@ import { addExcludedFolder, resyncArray, updateExcludedFolder } from './folderFu
|
|||
import PatternSettings from '../modals/PatternSettings';
|
||||
|
||||
export function updatePattern(plugin: FolderNotesPlugin, pattern: ExcludePattern, newPattern: ExcludePattern) {
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id);
|
||||
addExcludedFolder(plugin, newPattern);
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id);
|
||||
addExcludedFolder(plugin, newPattern);
|
||||
}
|
||||
|
||||
export function deletePattern(plugin: FolderNotesPlugin, pattern: ExcludePattern) {
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id || folder.type === 'folder');
|
||||
plugin.saveSettings(true);
|
||||
resyncArray(plugin);
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id || folder.type === 'folder');
|
||||
plugin.saveSettings(true);
|
||||
resyncArray(plugin);
|
||||
}
|
||||
|
||||
export function getExcludedFoldersByPattern(plugin: FolderNotesPlugin, folderName: string): ExcludePattern[] {
|
||||
return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').filter((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').filter((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getExcludedFolderByPattern(plugin: FolderNotesPlugin, folderName: string): ExcludePattern | undefined{
|
||||
return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function addExcludePatternListItem(settings: SettingsTab, containerEl: HTMLElement, pattern: ExcludePattern) {
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Pattern');
|
||||
cb.setValue(pattern.string);
|
||||
cb.onChange((value) => {
|
||||
pattern.string = value;
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit pattern');
|
||||
cb.onClick(() => {
|
||||
new PatternSettings(plugin.app, plugin, pattern).open();
|
||||
});
|
||||
});
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Pattern');
|
||||
cb.setValue(pattern.string);
|
||||
cb.onChange((value) => {
|
||||
pattern.string = value;
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit pattern');
|
||||
cb.onClick(() => {
|
||||
new PatternSettings(plugin.app, plugin, pattern).open();
|
||||
});
|
||||
});
|
||||
|
||||
if (Platform.isDesktop || Platform.isTablet) {
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === 0) { return; }
|
||||
pattern.position -= 1;
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position += 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updatePattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
if (Platform.isDesktop || Platform.isTablet) {
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === 0) { return; }
|
||||
pattern.position -= 1;
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position += 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updatePattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === plugin.settings.excludeFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
pattern.position += 1;
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === plugin.settings.excludeFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
pattern.position += 1;
|
||||
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position -= 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updatePattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
updatePattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position -= 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updatePattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete pattern');
|
||||
cb.onClick(() => {
|
||||
deletePattern(plugin, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete pattern');
|
||||
cb.onClick(() => {
|
||||
deletePattern(plugin, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { SettingsTab } from '../../settings/SettingsTab';
|
|||
import WhitelistededFoldersSettings from '../modals/WhitelistedFoldersSettings';
|
||||
import WhitelistFolderSettings from '../modals/WhitelistFolderSettings';
|
||||
import { updateWhitelistedPattern, getWhitelistedFoldersByPattern, addWhitelistedPatternListItem } from './whitelistPatternFunctions';
|
||||
Platform.isMobileApp
|
||||
Platform.isMobileApp;
|
||||
|
||||
export function getWhitelistedFolder(plugin: FolderNotesPlugin, path: string) {
|
||||
let whitelistedFolder = {} as WhitelistedFolder | WhitelistedPattern | undefined;
|
||||
|
|
@ -20,12 +20,12 @@ export function getWhitelistedFolder(plugin: FolderNotesPlugin, path: string) {
|
|||
'enableAutoCreate',
|
||||
'enableFolderNote',
|
||||
'enableSync',
|
||||
'showInFolderOverview'
|
||||
'showInFolderOverview',
|
||||
];
|
||||
|
||||
if (combinedWhitelistedFolders.length > 0) {
|
||||
for (const matchedFolder of combinedWhitelistedFolders) {
|
||||
propertiesToCopy.forEach(property => {
|
||||
propertiesToCopy.forEach((property) => {
|
||||
if (matchedFolder[property] === true) {
|
||||
(whitelistedFolder as any)[property] = true;
|
||||
} else if (!matchedFolder[property]) {
|
||||
|
|
@ -87,7 +87,7 @@ export function addWhitelistFolderListItem(settings: SettingsTab, containerEl: H
|
|||
setting.setClass('fn-exclude-folder-list');
|
||||
|
||||
const inputContainer = setting.settingEl.createDiv({ cls: 'fn-whitelist-folder-input-container' });
|
||||
const SearchComponent = new Setting(inputContainer)
|
||||
const SearchComponent = new Setting(inputContainer);
|
||||
SearchComponent.addSearch((cb) => {
|
||||
new FolderSuggest(
|
||||
cb.inputEl,
|
||||
|
|
|
|||
|
|
@ -7,145 +7,145 @@ import { WhitelistedPattern } from '../WhitelistPattern';
|
|||
import { addWhitelistedFolder, updateWhitelistedFolder } from './whitelistFolderFunctions';
|
||||
|
||||
export function updateWhitelistedPattern(plugin: FolderNotesPlugin, pattern: WhitelistedPattern, newPattern: WhitelistedPattern) {
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== pattern.id);
|
||||
addWhitelistedFolder(plugin, newPattern);
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== pattern.id);
|
||||
addWhitelistedFolder(plugin, newPattern);
|
||||
}
|
||||
|
||||
export function deletePattern(plugin: FolderNotesPlugin, pattern: WhitelistedPattern) {
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== pattern.id || folder.type === 'folder');
|
||||
plugin.saveSettings(true);
|
||||
resyncArray(plugin);
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== pattern.id || folder.type === 'folder');
|
||||
plugin.saveSettings(true);
|
||||
resyncArray(plugin);
|
||||
}
|
||||
|
||||
export function getWhitelistedFolderByPattern(plugin: FolderNotesPlugin, folderName: string) {
|
||||
return plugin.settings.whitelistFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return plugin.settings.whitelistFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getWhitelistedFoldersByPattern(plugin: FolderNotesPlugin, folderName: string) {
|
||||
return plugin.settings.whitelistFolders.filter((s) => s.type == 'pattern').filter((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return plugin.settings.whitelistFolders.filter((s) => s.type == 'pattern').filter((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.trim();
|
||||
if (!string.startsWith('{regex}') && !(string.startsWith('*') || string.endsWith('*'))) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function addWhitelistedPatternListItem(settings: SettingsTab, containerEl: HTMLElement, pattern: WhitelistedPattern) {
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Pattern');
|
||||
cb.setValue(pattern.string);
|
||||
cb.onChange((value) => {
|
||||
if (plugin.settings.whitelistFolders.find((folder) => folder.string === value)) { return; }
|
||||
pattern.string = value;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit pattern');
|
||||
cb.onClick(() => {
|
||||
new WhitelistPatternSettings(plugin.app, plugin, pattern).open();
|
||||
});
|
||||
});
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Pattern');
|
||||
cb.setValue(pattern.string);
|
||||
cb.onChange((value) => {
|
||||
if (plugin.settings.whitelistFolders.find((folder) => folder.string === value)) { return; }
|
||||
pattern.string = value;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit pattern');
|
||||
cb.onClick(() => {
|
||||
new WhitelistPatternSettings(plugin.app, plugin, pattern).open();
|
||||
});
|
||||
});
|
||||
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === 0) { return; }
|
||||
pattern.position -= 1;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position += 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === 0) { return; }
|
||||
pattern.position -= 1;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position += 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === plugin.settings.whitelistFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
pattern.position += 1;
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === plugin.settings.whitelistFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
pattern.position += 1;
|
||||
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position -= 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position -= 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete pattern');
|
||||
cb.onClick(() => {
|
||||
deletePattern(plugin, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete pattern');
|
||||
cb.onClick(() => {
|
||||
deletePattern(plugin, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ export default class WhitelistedFoldersSettings extends Modal {
|
|||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
export class CustomEventEmitter {
|
||||
private events: { [key: string]: Array<(data?: any) => void> } = {};
|
||||
private events: { [key: string]: Array<(data?: any) => void> } = {};
|
||||
|
||||
on(event: string, listener: (data?: any) => void) {
|
||||
if (!this.events[event]) {
|
||||
this.events[event] = [];
|
||||
}
|
||||
this.events[event].push(listener);
|
||||
}
|
||||
on(event: string, listener: (data?: any) => void) {
|
||||
if (!this.events[event]) {
|
||||
this.events[event] = [];
|
||||
}
|
||||
this.events[event].push(listener);
|
||||
}
|
||||
|
||||
off(event: string, listener: (data?: any) => void) {
|
||||
if (!this.events[event]) return;
|
||||
off(event: string, listener: (data?: any) => void) {
|
||||
if (!this.events[event]) return;
|
||||
|
||||
this.events[event] = this.events[event].filter((l) => l !== listener);
|
||||
}
|
||||
this.events[event] = this.events[event].filter((l) => l !== listener);
|
||||
}
|
||||
|
||||
emit(event: string, data?: any) {
|
||||
if (!this.events[event]) return;
|
||||
emit(event: string, data?: any) {
|
||||
if (!this.events[event]) return;
|
||||
|
||||
this.events[event].forEach((listener) => listener(data));
|
||||
}
|
||||
}
|
||||
this.events[event].forEach((listener) => listener(data));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export class FrontMatterTitlePluginHandler {
|
|||
deffer: DeferInterface | null = null;
|
||||
modifiedFolders: Map<string, TFolder> = new Map();
|
||||
eventRef: ListenerRef<'manager:update'>;
|
||||
dispatcher: EventDispatcherInterface<Events>
|
||||
dispatcher: EventDispatcherInterface<Events>;
|
||||
constructor(plugin: FolderNotesPlugin) {
|
||||
this.plugin = plugin;
|
||||
this.app = plugin.app;
|
||||
|
|
@ -57,18 +57,18 @@ export class FrontMatterTitlePluginHandler {
|
|||
result: boolean;
|
||||
path: string;
|
||||
}, isEvent: boolean) {
|
||||
if ((data as any).data) data = (data as any).data
|
||||
if ((data as any).data) data = (data as any).data;
|
||||
const file = this.app.vault.getAbstractFileByPath(data.path);
|
||||
if (!(file instanceof TFile)) { return; }
|
||||
|
||||
const resolver = this.api?.getResolverFactory()?.createResolver('#feature-id#');
|
||||
const newName = resolver?.resolve(file?.path ?? '')
|
||||
const newName = resolver?.resolve(file?.path ?? '');
|
||||
const folder = getFolder(this.plugin, file);
|
||||
if (!(folder instanceof TFolder)) { return; }
|
||||
|
||||
|
||||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
if (!folderNote) { return }
|
||||
if (folderNote !== file) { return }
|
||||
if (!folderNote) { return; }
|
||||
if (folderNote !== file) { return; }
|
||||
|
||||
if (isEvent) {
|
||||
this.plugin.changeName(folder, newName, true);
|
||||
|
|
|
|||
|
|
@ -7,119 +7,119 @@ import { applyCSSClassesToFolder, applyCSSClassesToFolderNote } from 'src/functi
|
|||
import { getFolderNameFromPathString } from 'src/functions/utils';
|
||||
|
||||
export async function addObserver(plugin: FolderNotesPlugin) {
|
||||
plugin.observer = new MutationObserver((mutations: MutationRecord[]) => {
|
||||
mutations.forEach((rec) => {
|
||||
if (rec.type === 'childList') {
|
||||
(<Element>rec.target).querySelectorAll('div.nav-folder')
|
||||
.forEach(async (element: HTMLElement) => {
|
||||
let folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
const filePath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
|
||||
applyCSSClassesToFolder(filePath, plugin);
|
||||
plugin.observer = new MutationObserver((mutations: MutationRecord[]) => {
|
||||
mutations.forEach((rec) => {
|
||||
if (rec.type === 'childList') {
|
||||
(<Element>rec.target).querySelectorAll('div.nav-folder')
|
||||
.forEach(async (element: HTMLElement) => {
|
||||
let folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
const filePath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
|
||||
if (folderTitle) {
|
||||
await initializeFolderTitle(folderTitle, plugin);
|
||||
} else {
|
||||
applyCSSClassesToFolder(filePath, plugin);
|
||||
|
||||
const observer = new MutationObserver(async (mutations, obs) => {
|
||||
folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
if (folderTitle) {
|
||||
await initializeFolderTitle(folderTitle, plugin);
|
||||
obs.disconnect();
|
||||
}
|
||||
});
|
||||
if (folderTitle) {
|
||||
await initializeFolderTitle(folderTitle, plugin);
|
||||
} else {
|
||||
|
||||
observer.observe(element, { childList: true, subtree: true });
|
||||
}
|
||||
});
|
||||
if (!plugin.settings.openFolderNoteOnClickInPath) { return; }
|
||||
// (<Element>rec.target).querySelectorAll('div.nav-file-title-content')
|
||||
// .forEach(async (element: HTMLElement) => {
|
||||
// const filePath = element.parentElement?.getAttribute('data-path') || '';
|
||||
// applyCSSClassesToFolderNote(filePath, plugin);
|
||||
// });
|
||||
(<Element>rec.target).querySelectorAll('span.view-header-breadcrumb')
|
||||
.forEach((element: HTMLElement) => {
|
||||
const breadcrumbs = element.parentElement?.querySelectorAll('span.view-header-breadcrumb');
|
||||
if (!breadcrumbs) return;
|
||||
let path = '';
|
||||
breadcrumbs.forEach(async (breadcrumb: HTMLElement) => {
|
||||
if (breadcrumb.hasAttribute('old-name')) {
|
||||
path += breadcrumb.getAttribute('old-name') + '/';
|
||||
} else {
|
||||
path += breadcrumb.innerText.trim() + '/';
|
||||
}
|
||||
const folderPath = path.slice(0, -1);
|
||||
breadcrumb.setAttribute('data-path', folderPath);
|
||||
const folder = plugin.fmtpHandler?.modifiedFolders.get(folderPath);
|
||||
if (folder && plugin.settings.frontMatterTitle.path && plugin.settings.frontMatterTitle.enabled) {
|
||||
breadcrumb.setAttribute('old-name', folder.name || '');
|
||||
breadcrumb.innerText = folder.newName || '';
|
||||
}
|
||||
const excludedFolder = await getExcludedFolder(plugin, folderPath, true)
|
||||
if (excludedFolder?.disableFolderNote) return;
|
||||
const folderNote = getFolderNote(plugin, folderPath);
|
||||
if (folderNote) {
|
||||
breadcrumb.classList.add('has-folder-note');
|
||||
}
|
||||
});
|
||||
element.parentElement?.setAttribute('data-path', path.slice(0, -1));
|
||||
if (breadcrumbs.length > 0) {
|
||||
breadcrumbs.forEach((breadcrumb: HTMLElement) => {
|
||||
if (breadcrumb.onclick) return;
|
||||
breadcrumb.addEventListener('click', (e) => {
|
||||
handleViewHeaderClick(e, plugin);
|
||||
}, { capture: true });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
const observer = new MutationObserver(async (mutations, obs) => {
|
||||
folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
if (folderTitle) {
|
||||
await initializeFolderTitle(folderTitle, plugin);
|
||||
obs.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(element, { childList: true, subtree: true });
|
||||
}
|
||||
});
|
||||
if (!plugin.settings.openFolderNoteOnClickInPath) { return; }
|
||||
// (<Element>rec.target).querySelectorAll('div.nav-file-title-content')
|
||||
// .forEach(async (element: HTMLElement) => {
|
||||
// const filePath = element.parentElement?.getAttribute('data-path') || '';
|
||||
// applyCSSClassesToFolderNote(filePath, plugin);
|
||||
// });
|
||||
(<Element>rec.target).querySelectorAll('span.view-header-breadcrumb')
|
||||
.forEach((element: HTMLElement) => {
|
||||
const breadcrumbs = element.parentElement?.querySelectorAll('span.view-header-breadcrumb');
|
||||
if (!breadcrumbs) return;
|
||||
let path = '';
|
||||
breadcrumbs.forEach(async (breadcrumb: HTMLElement) => {
|
||||
if (breadcrumb.hasAttribute('old-name')) {
|
||||
path += breadcrumb.getAttribute('old-name') + '/';
|
||||
} else {
|
||||
path += breadcrumb.innerText.trim() + '/';
|
||||
}
|
||||
const folderPath = path.slice(0, -1);
|
||||
breadcrumb.setAttribute('data-path', folderPath);
|
||||
const folder = plugin.fmtpHandler?.modifiedFolders.get(folderPath);
|
||||
if (folder && plugin.settings.frontMatterTitle.path && plugin.settings.frontMatterTitle.enabled) {
|
||||
breadcrumb.setAttribute('old-name', folder.name || '');
|
||||
breadcrumb.innerText = folder.newName || '';
|
||||
}
|
||||
const excludedFolder = await getExcludedFolder(plugin, folderPath, true);
|
||||
if (excludedFolder?.disableFolderNote) return;
|
||||
const folderNote = getFolderNote(plugin, folderPath);
|
||||
if (folderNote) {
|
||||
breadcrumb.classList.add('has-folder-note');
|
||||
}
|
||||
});
|
||||
element.parentElement?.setAttribute('data-path', path.slice(0, -1));
|
||||
if (breadcrumbs.length > 0) {
|
||||
breadcrumbs.forEach((breadcrumb: HTMLElement) => {
|
||||
if (breadcrumb.onclick) return;
|
||||
breadcrumb.addEventListener('click', (e) => {
|
||||
handleViewHeaderClick(e, plugin);
|
||||
}, { capture: true });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function initializeFolderTitle(folderTitle: HTMLElement, plugin: any) {
|
||||
if (folderTitle.onclick) return;
|
||||
if (Platform.isMobile && plugin.settings.disableOpenFolderNoteOnClick) return;
|
||||
if (folderTitle.onclick) return;
|
||||
if (Platform.isMobile && plugin.settings.disableOpenFolderNoteOnClick) return;
|
||||
|
||||
let folderPath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
const folderPath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
|
||||
await applyCSSClassesToFolder(folderPath, plugin);
|
||||
await applyCSSClassesToFolder(folderPath, plugin);
|
||||
|
||||
// Handle middle click (auxclick)
|
||||
folderTitle.addEventListener('auxclick', (event: MouseEvent) => {
|
||||
if (event.button == 1) {
|
||||
handleFolderClick(event, plugin);
|
||||
}
|
||||
}, { capture: true });
|
||||
// Handle middle click (auxclick)
|
||||
folderTitle.addEventListener('auxclick', (event: MouseEvent) => {
|
||||
if (event.button == 1) {
|
||||
handleFolderClick(event, plugin);
|
||||
}
|
||||
}, { capture: true });
|
||||
|
||||
folderTitle.onclick = (event: MouseEvent) => handleFolderClick(event, plugin);
|
||||
folderTitle.onclick = (event: MouseEvent) => handleFolderClick(event, plugin);
|
||||
|
||||
plugin.registerDomEvent(folderTitle, 'pointerover', (event: MouseEvent) => {
|
||||
plugin.hoveredElement = folderTitle;
|
||||
plugin.mouseEvent = event;
|
||||
plugin.registerDomEvent(folderTitle, 'pointerover', (event: MouseEvent) => {
|
||||
plugin.hoveredElement = folderTitle;
|
||||
plugin.mouseEvent = event;
|
||||
|
||||
if (!Keymap.isModEvent(event)) return;
|
||||
if (!(event.target instanceof HTMLElement)) return;
|
||||
if (!Keymap.isModEvent(event)) return;
|
||||
if (!(event.target instanceof HTMLElement)) return;
|
||||
|
||||
const folderPath = event?.target.parentElement?.getAttribute('data-path') || '';
|
||||
const folderNote = getFolderNote(plugin, folderPath);
|
||||
if (!folderNote) return;
|
||||
const folderPath = event?.target.parentElement?.getAttribute('data-path') || '';
|
||||
const folderNote = getFolderNote(plugin, folderPath);
|
||||
if (!folderNote) return;
|
||||
|
||||
plugin.app.workspace.trigger('hover-link', {
|
||||
event: event,
|
||||
source: 'preview',
|
||||
hoverParent: { file: folderNote },
|
||||
targetEl: event.target,
|
||||
linktext: folderNote?.basename,
|
||||
sourcePath: folderNote?.path,
|
||||
});
|
||||
plugin.hoverLinkTriggered = true;
|
||||
});
|
||||
plugin.app.workspace.trigger('hover-link', {
|
||||
event: event,
|
||||
source: 'preview',
|
||||
hoverParent: { file: folderNote },
|
||||
targetEl: event.target,
|
||||
linktext: folderNote?.basename,
|
||||
sourcePath: folderNote?.path,
|
||||
});
|
||||
plugin.hoverLinkTriggered = true;
|
||||
});
|
||||
|
||||
plugin.registerDomEvent(folderTitle, 'pointerout', () => {
|
||||
plugin.hoveredElement = null;
|
||||
plugin.mouseEvent = null;
|
||||
plugin.hoverLinkTriggered = false;
|
||||
});
|
||||
}
|
||||
plugin.registerDomEvent(folderTitle, 'pointerout', () => {
|
||||
plugin.hoveredElement = null;
|
||||
plugin.mouseEvent = null;
|
||||
plugin.hoverLinkTriggered = false;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,61 @@
|
|||
import FolderNotesPlugin from 'src/main';
|
||||
import { App, EditableFileView, TFile, TFolder } from 'obsidian';
|
||||
import { getFolder, getFolderNote} from 'src/functions/folderNoteFunctions';
|
||||
import { getFolder, getFolderNote } from 'src/functions/folderNoteFunctions';
|
||||
export class TabManager {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
constructor(plugin: FolderNotesPlugin) {
|
||||
this.plugin = plugin;
|
||||
this.app = plugin.app;
|
||||
}
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
constructor(plugin: FolderNotesPlugin) {
|
||||
this.plugin = plugin;
|
||||
this.app = plugin.app;
|
||||
}
|
||||
|
||||
resetTabs() {
|
||||
if (!this.isEnabled()) return;
|
||||
resetTabs() {
|
||||
if (!this.isEnabled()) return;
|
||||
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(file.basename);
|
||||
});
|
||||
}
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(file.basename);
|
||||
});
|
||||
}
|
||||
|
||||
updateTabs() {
|
||||
if (!this.isEnabled()) return;
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
const folder = getFolder(this.plugin, file);
|
||||
if (!folder) return;
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(folder.name);
|
||||
});
|
||||
}
|
||||
updateTabs() {
|
||||
if (!this.isEnabled()) return;
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
const folder = getFolder(this.plugin, file);
|
||||
if (!folder) return;
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(folder.name);
|
||||
});
|
||||
}
|
||||
|
||||
updateTab(folderPath: string) {
|
||||
if (!this.isEnabled()) return;
|
||||
updateTab(folderPath: string) {
|
||||
if (!this.isEnabled()) return;
|
||||
|
||||
const folder = this.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
const folder = this.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
|
||||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
if (!folderNote) return;
|
||||
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
if (file.path === folderNote.path) {
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(folder.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
const folderNote = getFolderNote(this.plugin, folder.path);
|
||||
if (!folderNote) return;
|
||||
|
||||
isEnabled() {
|
||||
if (this.plugin.settings.folderNoteName == '{{folder_name}}') return false;
|
||||
return this.plugin.settings.tabManagerEnabled;
|
||||
}
|
||||
}
|
||||
this.app.workspace.iterateAllLeaves((leaf) => {
|
||||
if (!(leaf.view instanceof EditableFileView)) return;
|
||||
const file = leaf.view?.file;
|
||||
if (!file) return;
|
||||
if (file.path === folderNote.path) {
|
||||
// @ts-ignore
|
||||
leaf.tabHeaderInnerTitleEl.setText(folder.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
if (this.plugin.settings.folderNoteName == '{{folder_name}}') return false;
|
||||
return this.plugin.settings.tabManagerEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ export async function handleFolderClick(event: MouseEvent, plugin: FolderNotesPl
|
|||
|
||||
if (!(event.target instanceof HTMLElement)) return;
|
||||
if (!event || !event.target) return;
|
||||
|
||||
|
||||
if (!event.shiftKey) {
|
||||
event.stopImmediatePropagation();
|
||||
} else {
|
||||
|
|
@ -82,7 +82,7 @@ export async function handleFolderClick(event: MouseEvent, plugin: FolderNotesPl
|
|||
return openFolderNote(plugin, folderNote, event);
|
||||
} else {
|
||||
if (plugin.settings.enableCollapsing) return;
|
||||
event.target.parentElement?.click()
|
||||
event.target.parentElement?.click();
|
||||
return;
|
||||
}
|
||||
} else if (event.altKey || Keymap.isModEvent(event) === 'tab') {
|
||||
|
|
|
|||
|
|
@ -6,66 +6,66 @@ import { removeCSSClassFromEL, addCSSClassToTitleEL } from 'src/functions/styleF
|
|||
import { removeExtension } from 'src/functions/utils';
|
||||
|
||||
export async function handleCreate(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
||||
if (!plugin.app.workspace.layoutReady) return;
|
||||
if (!plugin.app.workspace.layoutReady) return;
|
||||
|
||||
const folder = file.parent;
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
const folder = file.parent;
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
|
||||
if (file instanceof TFile) {
|
||||
handleFileCreation(file, plugin);
|
||||
} else if (file instanceof TFolder && plugin.settings.autoCreate) {
|
||||
handleFolderCreation(file, plugin);
|
||||
}
|
||||
if (file instanceof TFile) {
|
||||
handleFileCreation(file, plugin);
|
||||
} else if (file instanceof TFolder && plugin.settings.autoCreate) {
|
||||
handleFolderCreation(file, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFileCreation(file: TFile, plugin: FolderNotesPlugin) {
|
||||
const folder = getFolder(plugin, file);
|
||||
const folder = getFolder(plugin, file);
|
||||
|
||||
if (!(folder instanceof TFolder) && plugin.settings.autoCreateForFiles) {
|
||||
if (!file.parent) { return; }
|
||||
const newFolder = await plugin.app.fileManager.createNewFolder(file.parent)
|
||||
turnIntoFolderNote(plugin, file, newFolder);
|
||||
} else if (folder instanceof TFolder) {
|
||||
const detachedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
if (detachedFolder) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (!(folder instanceof TFolder) && plugin.settings.autoCreateForFiles) {
|
||||
if (!file.parent) { return; }
|
||||
const newFolder = await plugin.app.fileManager.createNewFolder(file.parent);
|
||||
turnIntoFolderNote(plugin, file, newFolder);
|
||||
} else if (folder instanceof TFolder) {
|
||||
const detachedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
if (detachedFolder) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
|
||||
if (folderNote && folderNote.path === file.path) {
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note', plugin);
|
||||
} else if (plugin.settings.autoCreateForFiles) {
|
||||
if (!file.parent) { return; }
|
||||
const newFolder = await plugin.app.fileManager.createNewFolder(file.parent)
|
||||
turnIntoFolderNote(plugin, file, newFolder);
|
||||
}
|
||||
}
|
||||
if (folderNote && folderNote.path === file.path) {
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
addCSSClassToTitleEL(file.path, 'is-folder-note', plugin);
|
||||
} else if (plugin.settings.autoCreateForFiles) {
|
||||
if (!file.parent) { return; }
|
||||
const newFolder = await plugin.app.fileManager.createNewFolder(file.parent);
|
||||
turnIntoFolderNote(plugin, file, newFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFolderCreation(folder: TFolder, plugin: FolderNotesPlugin) {
|
||||
let openFile = plugin.settings.autoCreateFocusFiles;
|
||||
let openFile = plugin.settings.autoCreateFocusFiles;
|
||||
|
||||
const attachmentFolderPath = plugin.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
const cleanAttachmentFolderPath = attachmentFolderPath?.replace('./', '') || '';
|
||||
const attachmentsAreInRootFolder = attachmentFolderPath === './' || attachmentFolderPath === '';
|
||||
const attachmentFolderPath = plugin.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
const cleanAttachmentFolderPath = attachmentFolderPath?.replace('./', '') || '';
|
||||
const attachmentsAreInRootFolder = attachmentFolderPath === './' || attachmentFolderPath === '';
|
||||
|
||||
if (!plugin.settings.autoCreateForAttachmentFolder) {
|
||||
if (!attachmentsAreInRootFolder && cleanAttachmentFolderPath === folder.name) return;
|
||||
} else if (!attachmentsAreInRootFolder && cleanAttachmentFolderPath === folder.name) {
|
||||
openFile = false;
|
||||
}
|
||||
if (!plugin.settings.autoCreateForAttachmentFolder) {
|
||||
if (!attachmentsAreInRootFolder && cleanAttachmentFolderPath === folder.name) return;
|
||||
} else if (!attachmentsAreInRootFolder && cleanAttachmentFolderPath === folder.name) {
|
||||
openFile = false;
|
||||
}
|
||||
|
||||
const excludedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
if (excludedFolder?.disableAutoCreate) return;
|
||||
const excludedFolder = await getExcludedFolder(plugin, folder.path, true);
|
||||
if (excludedFolder?.disableAutoCreate) return;
|
||||
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (folderNote) return;
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (folderNote) return;
|
||||
|
||||
createFolderNote(plugin, folder.path, openFile, undefined, true);
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
}
|
||||
createFolderNote(plugin, folder.path, openFile, undefined, true);
|
||||
addCSSClassToTitleEL(folder.path, 'has-folder-note', plugin);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,28 +5,28 @@ import { removeCSSClassFromEL, addCSSClassToTitleEL } from 'src/functions/styleF
|
|||
import { getFolderPathFromString } from 'src/functions/utils';
|
||||
|
||||
export function handleDelete(file: TAbstractFile, plugin: FolderNotesPlugin) {
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(getFolderPathFromString(file.path));
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(getFolderPathFromString(file.path));
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
} else {
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
}
|
||||
|
||||
if (file instanceof TFile) {
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (folderNote) { return; }
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
if (file instanceof TFile) {
|
||||
const folder = getFolder(plugin, file);
|
||||
if (!folder) { return; }
|
||||
const folderNote = getFolderNote(plugin, folder.path);
|
||||
if (folderNote) { return; }
|
||||
removeCSSClassFromEL(folder.path, 'has-folder-note', plugin);
|
||||
removeCSSClassFromEL(folder.path, 'only-has-folder-note', plugin);
|
||||
}
|
||||
|
||||
if (!(file instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(plugin, file.path);
|
||||
if (!folderNote) { return; }
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
if (!plugin.settings.syncDelete) { return; }
|
||||
deleteFolderNote(plugin, folderNote, false);
|
||||
}
|
||||
if (!(file instanceof TFolder)) { return; }
|
||||
const folderNote = getFolderNote(plugin, file.path);
|
||||
if (!folderNote) { return; }
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
if (!plugin.settings.syncDelete) { return; }
|
||||
deleteFolderNote(plugin, folderNote, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getFolderPathFromString, removeExtension, getFileNameFromPathString } f
|
|||
export function handleRename(file: TAbstractFile, oldPath: string, plugin: FolderNotesPlugin) {
|
||||
const folder = file.parent;
|
||||
const oldFolder = plugin.app.vault.getAbstractFileByPath(getFolderPathFromString(oldPath));
|
||||
const isRename = (file.parent?.path === getFolderPathFromString(oldPath))
|
||||
const isRename = (file.parent?.path === getFolderPathFromString(oldPath));
|
||||
if (folder instanceof TFolder) {
|
||||
if (plugin.isEmptyFolderNoteFolder(folder)) {
|
||||
addCSSClassToTitleEL(folder.path, 'only-has-folder-note', plugin);
|
||||
|
|
@ -138,8 +138,8 @@ export async function handleFileRename(file: TFile, oldPath: string, plugin: Fol
|
|||
const folderName = extractFolderName(plugin.settings.folderNoteName, file.basename) || file.basename;
|
||||
const oldFolderName = extractFolderName(plugin.settings.folderNoteName, oldFileName) || oldFileName;
|
||||
const newFolder = getFolderNoteFolder(plugin, file, file.basename);
|
||||
let excludedFolder = await getExcludedFolder(plugin, newFolder?.path || '', true);
|
||||
const detachedExcludedFolder = getDetachedFolder(plugin, newFolder?.path || '')
|
||||
const excludedFolder = await getExcludedFolder(plugin, newFolder?.path || '', true);
|
||||
const detachedExcludedFolder = getDetachedFolder(plugin, newFolder?.path || '');
|
||||
const folderNote = getFolderNote(plugin, oldPath, plugin.settings.storageLocation, file);
|
||||
|
||||
if (!excludedFolder?.disableFolderNote && folderName === newFolder?.name && !detachedExcludedFolder) {
|
||||
|
|
@ -227,4 +227,4 @@ function updateExcludedFolderPath(folder: TFolder, oldPath: string, plugin: Fold
|
|||
excludedFolder.path = folders.join('/');
|
||||
});
|
||||
plugin.saveSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export class ListComponent {
|
|||
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);
|
||||
this.setValues(this.defaultValues);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
|
@ -87,4 +87,4 @@ export class ListComponent {
|
|||
this.emit('remove', value);
|
||||
this.emit('update', this.values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import { WorkspaceLeaf, App } from 'obsidian';
|
||||
|
||||
export async function openExcalidrawView(leaf: WorkspaceLeaf) {
|
||||
const {excalidraw, excalidrawEnabled} = await getExcalidrawPlugin(this.app);
|
||||
if (excalidrawEnabled) {
|
||||
excalidraw.setExcalidrawView(leaf);
|
||||
}
|
||||
const { excalidraw, excalidrawEnabled } = await getExcalidrawPlugin(this.app);
|
||||
if (excalidrawEnabled) {
|
||||
excalidraw.setExcalidrawView(leaf);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getExcalidrawPlugin(app: App) {
|
||||
const excalidraw = (app as any).plugins.plugins['obsidian-excalidraw-plugin'];
|
||||
const excalidrawEnabled = (app as any).plugins.enabledPlugins.has(
|
||||
const excalidraw = (app as any).plugins.plugins['obsidian-excalidraw-plugin'];
|
||||
const excalidrawEnabled = (app as any).plugins.enabledPlugins.has(
|
||||
'obsidian-excalidraw-plugin'
|
||||
);
|
||||
return {
|
||||
excalidraw,
|
||||
excalidrawEnabled
|
||||
}
|
||||
}
|
||||
return {
|
||||
excalidraw,
|
||||
excalidrawEnabled,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
|
|||
const leaf = plugin.app.workspace.getLeaf(false);
|
||||
const folderName = getFolderNameFromPathString(folderPath);
|
||||
const fileName = plugin.settings.folderNoteName.replace('{{folder_name}}', folderName);
|
||||
let folderNote = getFolderNote(plugin, folderPath)
|
||||
let folderNote = getFolderNote(plugin, folderPath);
|
||||
if (preexistingNote) {
|
||||
folderNote = preexistingNote;
|
||||
}
|
||||
let folderNoteType = extension ?? plugin.settings.folderNoteType;
|
||||
const detachedFolder = getDetachedFolder(plugin, folderPath)
|
||||
const detachedFolder = getDetachedFolder(plugin, folderPath);
|
||||
let path = '';
|
||||
|
||||
if (folderNoteType === '.excalidraw') {
|
||||
|
|
@ -69,7 +69,7 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
|
|||
count++;
|
||||
newName = removeExtension(folderNote.path) + ` (${count}).${folderNote.path.split('.').pop()}`;
|
||||
}
|
||||
const [excludedFolder, excludedFolderExisted, disabledSync] = await tempDisableSync(plugin, folder)
|
||||
const [excludedFolder, excludedFolderExisted, disabledSync] = await tempDisableSync(plugin, folder);
|
||||
|
||||
await plugin.app.fileManager.renameFile(folderNote, newName).then(() => {
|
||||
if (!excludedFolder) return;
|
||||
|
|
@ -105,13 +105,13 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
|
|||
} else if (plugin.settings.folderNoteType === '.excalidraw' || extension === '.excalidraw') {
|
||||
content = defaultExcalidrawTemplate;
|
||||
} else if (plugin.settings.folderNoteType === '.canvas') {
|
||||
content = '{}'
|
||||
content = '{}';
|
||||
}
|
||||
}
|
||||
|
||||
folderNote = await plugin.app.vault.create(path, content);
|
||||
} else {
|
||||
await plugin.app.fileManager.renameFile(folderNote, path)
|
||||
await plugin.app.fileManager.renameFile(folderNote, path);
|
||||
}
|
||||
|
||||
if (openFile) {
|
||||
|
|
@ -145,7 +145,7 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
|
|||
}
|
||||
|
||||
export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile, folder: TFolder, folderNote?: TFile | null | TAbstractFile, skipConfirmation?: boolean) {
|
||||
const extension = file.extension
|
||||
const extension = file.extension;
|
||||
const detachedExcludedFolder = getDetachedFolder(plugin, folder.path);
|
||||
|
||||
if (folderNote) {
|
||||
|
|
@ -154,7 +154,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
|
|||
}
|
||||
removeCSSClassFromEL(folderNote.path, 'is-folder-note', plugin);
|
||||
|
||||
const [excludedFolder, excludedFolderExisted, disabledSync] = await tempDisableSync(plugin, folder)
|
||||
const [excludedFolder, excludedFolderExisted, disabledSync] = await tempDisableSync(plugin, folder);
|
||||
|
||||
const newPath = `${folder.path}/${folder.name} (${file.stat.ctime.toString().slice(10) + Math.floor(Math.random() * 1000)}).${extension}`;
|
||||
plugin.app.fileManager.renameFile(folderNote, newPath).then(() => {
|
||||
|
|
@ -182,7 +182,7 @@ export async function turnIntoFolderNote(plugin: FolderNotesPlugin, file: TFile,
|
|||
}
|
||||
|
||||
if (detachedExcludedFolder) {
|
||||
deleteExcludedFolder(plugin, detachedExcludedFolder)
|
||||
deleteExcludedFolder(plugin, detachedExcludedFolder);
|
||||
}
|
||||
|
||||
await plugin.app.fileManager.renameFile(file, path);
|
||||
|
|
@ -214,7 +214,7 @@ export async function tempDisableSync(plugin: FolderNotesPlugin, folder: TFolder
|
|||
updateExcludedFolder(plugin, excludedFolder, excludedFolder);
|
||||
}
|
||||
|
||||
return [excludedFolder, excludedFolderExisted, disabledSync]
|
||||
return [excludedFolder, excludedFolderExisted, disabledSync];
|
||||
}
|
||||
|
||||
export async function openFolderNote(plugin: FolderNotesPlugin, file: TAbstractFile, evt?: MouseEvent) {
|
||||
|
|
|
|||
2
src/globals.d.ts
vendored
2
src/globals.d.ts
vendored
|
|
@ -44,4 +44,4 @@ declare global {
|
|||
t: (key: string, options?: { [key: string]: string }) => string;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
src/main.ts
16
src/main.ts
|
|
@ -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 { FileExplorerView, InternalPlugin } from 'obsidian-typings'
|
||||
import { FileExplorerView, InternalPlugin } from 'obsidian-typings';
|
||||
import { getFocusedItem } from './functions/utils';
|
||||
import { FOLDER_OVERVIEW_VIEW, FolderOverviewView } from './obsidian-folder-overview/src/view';
|
||||
import { getFolderPathFromString } from './functions/utils';
|
||||
|
|
@ -118,7 +118,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
|
||||
const folder = getFolder(this, openFile);
|
||||
if (!folder) { return; }
|
||||
const excludedFolder = await getExcludedFolder(this, folder.path, true)
|
||||
const excludedFolder = await getExcludedFolder(this, folder.path, true);
|
||||
if (excludedFolder?.disableFolderNote) return;
|
||||
const folderNote = getFolderNote(this, folder.path);
|
||||
if (!folderNote) { return; }
|
||||
|
|
@ -187,7 +187,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
return originalHandleDrop.call(this, evt, ...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -242,11 +242,11 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
workspace.revealLeaf(leaf);
|
||||
}
|
||||
|
||||
updateOverviewView = updateOverviewView
|
||||
updateViewDropdown = updateViewDropdown
|
||||
updateOverviewView = updateOverviewView;
|
||||
updateViewDropdown = updateViewDropdown;
|
||||
|
||||
isEmptyFolderNoteFolder(folder: TFolder): boolean {
|
||||
let attachmentFolderPath = this.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
const attachmentFolderPath = this.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
const cleanAttachmentFolderPath = attachmentFolderPath?.replace('./', '') || '';
|
||||
const attachmentsAreInRootFolder = attachmentFolderPath === './' || attachmentFolderPath === '';
|
||||
const threshold = this.settings.storageLocation === 'insideFolder' ? 1 : 0;
|
||||
|
|
@ -260,7 +260,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
if (attachmentsAreInRootFolder) {
|
||||
return false;
|
||||
} else if (this.settings.ignoreAttachmentFolder && this.app.vault.getAbstractFileByPath(`${folder.path}/${cleanAttachmentFolderPath}`)) {
|
||||
const folderPath = `${folder.path}/${cleanAttachmentFolderPath}`
|
||||
const folderPath = `${folder.path}/${cleanAttachmentFolderPath}`;
|
||||
const attachmentFolder = this.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (attachmentFolder instanceof TFolder && folder.children.length <= threshold + 1) {
|
||||
if (!folder.collapsed) {
|
||||
|
|
@ -287,7 +287,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
return;
|
||||
}
|
||||
|
||||
fileExplorerItem = fileExplorerItem?.querySelector('div.nav-folder-title-content')
|
||||
fileExplorerItem = fileExplorerItem?.querySelector('div.nav-folder-title-content');
|
||||
if (!fileExplorerItem) { return; }
|
||||
if (this.settings.frontMatterTitle.explorer && this.settings.frontMatterTitle.enabled) {
|
||||
fileExplorerItem.innerText = name;
|
||||
|
|
|
|||
|
|
@ -4,56 +4,56 @@ import { ListComponent } from 'src/functions/ListComponent';
|
|||
import { SettingTab } from 'obsidian';
|
||||
|
||||
export default class AddSupportedFileModal extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
name: string;
|
||||
list: ListComponent;
|
||||
settingsTab: SettingTab;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, settingsTab: SettingTab, list: ListComponent) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.name = '';
|
||||
this.list = list;
|
||||
this.settingsTab = settingsTab;
|
||||
}
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
// close when user presses enter
|
||||
contentEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
contentEl.createEl('h2', { text: 'Extension name' });
|
||||
new Setting(contentEl)
|
||||
.setName('Enter the name of the extension (only the short form, e.g. "md")')
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue('')
|
||||
.onChange(async (value) => {
|
||||
if (value.trim() !== '') {
|
||||
this.name = value.trim();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
async onClose() {
|
||||
if (this.name.toLocaleLowerCase() === 'markdown') {
|
||||
this.name = 'md';
|
||||
}
|
||||
const { contentEl } = this;
|
||||
if (this.name === '') {
|
||||
contentEl.empty();
|
||||
this.settingsTab.display();
|
||||
} else if (this.plugin.settings.supportedFileTypes.includes(this.name.toLowerCase())) {
|
||||
return new Notice('This extension is already supported');
|
||||
} else {
|
||||
// @ts-ignore
|
||||
await this.list.addValue(this.name.toLowerCase());
|
||||
this.settingsTab.display();
|
||||
this.plugin.saveSettings();
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
name: string;
|
||||
list: ListComponent;
|
||||
settingsTab: SettingTab;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, settingsTab: SettingTab, list: ListComponent) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.name = '';
|
||||
this.list = list;
|
||||
this.settingsTab = settingsTab;
|
||||
}
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
// close when user presses enter
|
||||
contentEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
contentEl.createEl('h2', { text: 'Extension name' });
|
||||
new Setting(contentEl)
|
||||
.setName('Enter the name of the extension (only the short form, e.g. "md")')
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue('')
|
||||
.onChange(async (value) => {
|
||||
if (value.trim() !== '') {
|
||||
this.name = value.trim();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
async onClose() {
|
||||
if (this.name.toLocaleLowerCase() === 'markdown') {
|
||||
this.name = 'md';
|
||||
}
|
||||
const { contentEl } = this;
|
||||
if (this.name === '') {
|
||||
contentEl.empty();
|
||||
this.settingsTab.display();
|
||||
} else if (this.plugin.settings.supportedFileTypes.includes(this.name.toLowerCase())) {
|
||||
return new Notice('This extension is already supported');
|
||||
} else {
|
||||
// @ts-ignore
|
||||
await this.list.addValue(this.name.toLowerCase());
|
||||
this.settingsTab.display();
|
||||
this.plugin.saveSettings();
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,33 +2,33 @@ 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
|
||||
folderPath: string;
|
||||
openFile: boolean;
|
||||
useModal: boolean | undefined;
|
||||
existingNote: TFile | undefined;
|
||||
constructor(plugin: FolderNotesPlugin, folderPath: string, openFile: boolean, extension: string, useModal?: boolean, existingNote?: TFile) {
|
||||
super(plugin.app);
|
||||
this.plugin = plugin;
|
||||
this.folderPath = folderPath;
|
||||
this.extension = extension;
|
||||
this.openFile = openFile;
|
||||
this.useModal = useModal;
|
||||
this.existingNote = existingNote;
|
||||
}
|
||||
|
||||
getItems(): string[] {
|
||||
return this.plugin.settings.supportedFileTypes.filter((item) => item.toLowerCase() !== '.ask');
|
||||
}
|
||||
plugin: FolderNotesPlugin;
|
||||
extension: string;
|
||||
folderPath: string;
|
||||
openFile: boolean;
|
||||
useModal: boolean | undefined;
|
||||
existingNote: TFile | undefined;
|
||||
constructor(plugin: FolderNotesPlugin, folderPath: string, openFile: boolean, extension: string, useModal?: boolean, existingNote?: TFile) {
|
||||
super(plugin.app);
|
||||
this.plugin = plugin;
|
||||
this.folderPath = folderPath;
|
||||
this.extension = extension;
|
||||
this.openFile = openFile;
|
||||
this.useModal = useModal;
|
||||
this.existingNote = existingNote;
|
||||
}
|
||||
|
||||
getItemText(item: string): string {
|
||||
return item;
|
||||
}
|
||||
getItems(): string[] {
|
||||
return this.plugin.settings.supportedFileTypes.filter((item) => item.toLowerCase() !== '.ask');
|
||||
}
|
||||
|
||||
onChooseItem(item: string, evt: MouseEvent | KeyboardEvent) {
|
||||
this.extension = '.' + item;
|
||||
createFolderNote(this.plugin, this.folderPath, this.openFile, this.extension, this.useModal, this.existingNote);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
getItemText(item: string): string {
|
||||
return item;
|
||||
}
|
||||
|
||||
onChooseItem(item: string, evt: MouseEvent | KeyboardEvent) {
|
||||
this.extension = '.' + item;
|
||||
createFolderNote(this.plugin, this.folderPath, this.openFile, this.extension, this.useModal, this.existingNote);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export {}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ export default class DeleteConfirmationModal extends Modal {
|
|||
const buttonContainer = contentEl.createEl('div', { cls: 'modal-button-container' });
|
||||
|
||||
if (!Platform.isMobile) {
|
||||
const checkbox = buttonContainer.createEl('label', { cls: 'mod-checkbox' })
|
||||
checkbox.tabIndex = -1
|
||||
const checkbox = buttonContainer.createEl('label', { cls: 'mod-checkbox' });
|
||||
checkbox.tabIndex = -1;
|
||||
const input = checkbox.createEl('input', { type: 'checkbox' });
|
||||
checkbox.appendText('Don\'t ask again')
|
||||
checkbox.appendText('Don\'t ask again');
|
||||
input.addEventListener('change', (e) => {
|
||||
const target = e.target as HTMLInputElement;
|
||||
if (target.checked) {
|
||||
|
|
|
|||
|
|
@ -1,73 +1,73 @@
|
|||
import { App, Modal, Setting, TFolder } from 'obsidian';
|
||||
import FolderNotesPlugin from '../main';
|
||||
export default class NewFolderNameModal extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
folder: TFolder;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, folder: TFolder) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.folder = folder;
|
||||
}
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
folder: TFolder;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, folder: TFolder) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.folder = folder;
|
||||
}
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
|
||||
contentEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.saveFolderName()
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
contentEl.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.saveFolderName();
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
|
||||
this.modalEl.classList.add('mod-file-rename')
|
||||
const modalTitle = this.modalEl.querySelector('div.modal-title')
|
||||
if (modalTitle) {
|
||||
modalTitle.textContent = 'Folder title'
|
||||
}
|
||||
this.modalEl.classList.add('mod-file-rename');
|
||||
const modalTitle = this.modalEl.querySelector('div.modal-title');
|
||||
if (modalTitle) {
|
||||
modalTitle.textContent = 'Folder title';
|
||||
}
|
||||
|
||||
const textarea = contentEl.createEl('textarea', {
|
||||
text: this.folder.name.replace(this.plugin.settings.folderNoteType, ''),
|
||||
attr: {
|
||||
placeholder: 'Enter the name of the folder',
|
||||
rows: '1',
|
||||
spellcheck: 'false',
|
||||
class: 'rename-textarea'
|
||||
}
|
||||
})
|
||||
const textarea = contentEl.createEl('textarea', {
|
||||
text: this.folder.name.replace(this.plugin.settings.folderNoteType, ''),
|
||||
attr: {
|
||||
placeholder: 'Enter the name of the folder',
|
||||
rows: '1',
|
||||
spellcheck: 'false',
|
||||
class: 'rename-textarea',
|
||||
},
|
||||
});
|
||||
|
||||
textarea.addEventListener('focus', function() {
|
||||
this.select();
|
||||
});
|
||||
|
||||
textarea.focus()
|
||||
textarea.addEventListener('focus', function() {
|
||||
this.select();
|
||||
});
|
||||
|
||||
const buttonContainer = this.modalEl.createDiv({ cls: 'modal-button-container' });
|
||||
const saveButton = buttonContainer.createEl('button', { text: 'Save', cls: 'mod-cta' });
|
||||
saveButton.addEventListener('click', async () => {
|
||||
this.saveFolderName()
|
||||
this.close()
|
||||
})
|
||||
textarea.focus();
|
||||
|
||||
const cancelButton = buttonContainer.createEl('button', { text: 'Cancel', cls: 'mod-cancel' });
|
||||
cancelButton.addEventListener('click', () => {
|
||||
this.close()
|
||||
})
|
||||
}
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
const buttonContainer = this.modalEl.createDiv({ cls: 'modal-button-container' });
|
||||
const saveButton = buttonContainer.createEl('button', { text: 'Save', cls: 'mod-cta' });
|
||||
saveButton.addEventListener('click', async () => {
|
||||
this.saveFolderName();
|
||||
this.close();
|
||||
});
|
||||
|
||||
saveFolderName() {
|
||||
const textarea = this.contentEl.querySelector('textarea')
|
||||
if (textarea) {
|
||||
const newName = textarea.value.trim()
|
||||
if (newName.trim() !== '') {
|
||||
if (!this.app.vault.getAbstractFileByPath(this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + newName.trim())) {
|
||||
this.plugin.app.fileManager.renameFile(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + newName.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const cancelButton = buttonContainer.createEl('button', { text: 'Cancel', cls: 'mod-cancel' });
|
||||
cancelButton.addEventListener('click', () => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
|
||||
saveFolderName() {
|
||||
const textarea = this.contentEl.querySelector('textarea');
|
||||
if (textarea) {
|
||||
const newName = textarea.value.trim();
|
||||
if (newName.trim() !== '') {
|
||||
if (!this.app.vault.getAbstractFileByPath(this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + newName.trim())) {
|
||||
this.plugin.app.fileManager.renameFile(this.folder, this.folder.path.slice(0, this.folder.path.lastIndexOf('/') + 1) + newName.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,80 +9,80 @@ import WhitelistedFoldersSettings from 'src/ExcludeFolders/modals/WhitelistedFol
|
|||
// import ExcludedFoldersWhitelist from 'src/ExcludeFolders/modals/WhitelistModal';
|
||||
|
||||
export async function renderExcludeFolders(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
const manageExcluded = new Setting(containerEl)
|
||||
.setHeading()
|
||||
.setClass('fn-excluded-folder-heading')
|
||||
.setName('Manage excluded folders');
|
||||
const desc3 = document.createDocumentFragment();
|
||||
desc3.append(
|
||||
'Add {regex} at the beginning of the folder name to use a regex pattern.',
|
||||
desc3.createEl('br'),
|
||||
'Use * before and after to exclude folders that include the name between the *s.',
|
||||
desc3.createEl('br'),
|
||||
'Use * before the folder name to exclude folders that end with the folder name.',
|
||||
desc3.createEl('br'),
|
||||
'Use * after the folder name to exclude folders that start with the folder name.',
|
||||
);
|
||||
manageExcluded.setDesc(desc3);
|
||||
manageExcluded.infoEl.appendText('The regexes and wildcards are only for the folder name, not the path.');
|
||||
manageExcluded.infoEl.createEl('br');
|
||||
manageExcluded.infoEl.appendText('If you want to switch to a folder path delete the pattern first.');
|
||||
manageExcluded.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
const manageExcluded = new Setting(containerEl)
|
||||
.setHeading()
|
||||
.setClass('fn-excluded-folder-heading')
|
||||
.setName('Manage excluded folders');
|
||||
const desc3 = document.createDocumentFragment();
|
||||
desc3.append(
|
||||
'Add {regex} at the beginning of the folder name to use a regex pattern.',
|
||||
desc3.createEl('br'),
|
||||
'Use * before and after to exclude folders that include the name between the *s.',
|
||||
desc3.createEl('br'),
|
||||
'Use * before the folder name to exclude folders that end with the folder name.',
|
||||
desc3.createEl('br'),
|
||||
'Use * after the folder name to exclude folders that start with the folder name.',
|
||||
);
|
||||
manageExcluded.setDesc(desc3);
|
||||
manageExcluded.infoEl.appendText('The regexes and wildcards are only for the folder name, not the path.');
|
||||
manageExcluded.infoEl.createEl('br');
|
||||
manageExcluded.infoEl.appendText('If you want to switch to a folder path delete the pattern first.');
|
||||
manageExcluded.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Whitelisted folders')
|
||||
.setDesc('Folders that override the excluded folders/patterns')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage')
|
||||
cb.setCta()
|
||||
cb.onClick(async () => {
|
||||
new WhitelistedFoldersSettings(settingsTab).open();
|
||||
})
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName('Whitelisted folders')
|
||||
.setDesc('Folders that override the excluded folders/patterns')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage');
|
||||
cb.setCta();
|
||||
cb.onClick(async () => {
|
||||
new WhitelistedFoldersSettings(settingsTab).open();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Exclude folder default settings')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage')
|
||||
cb.setCta()
|
||||
cb.onClick(async () => {
|
||||
new ExcludedFolderSettings(settingsTab.app, settingsTab.plugin, settingsTab.plugin.settings.excludeFolderDefaultSettings).open();
|
||||
})
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName('Exclude folder default settings')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage');
|
||||
cb.setCta();
|
||||
cb.onClick(async () => {
|
||||
new ExcludedFolderSettings(settingsTab.app, settingsTab.plugin, settingsTab.plugin.settings.excludeFolderDefaultSettings).open();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Exclude pattern default settings')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage')
|
||||
cb.setCta()
|
||||
cb.onClick(async () => {
|
||||
new PatternSettings(settingsTab.app, settingsTab.plugin, settingsTab.plugin.settings.excludePatternDefaultSettings).open();
|
||||
})
|
||||
})
|
||||
new Setting(containerEl)
|
||||
.setName('Exclude pattern default settings')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage');
|
||||
cb.setCta();
|
||||
cb.onClick(async () => {
|
||||
new PatternSettings(settingsTab.app, settingsTab.plugin, settingsTab.plugin.settings.excludePatternDefaultSettings).open();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Add excluded folder')
|
||||
.setClass('add-exclude-folder-item')
|
||||
.addButton((cb) => {
|
||||
cb.setIcon('plus');
|
||||
cb.setClass('add-exclude-folder');
|
||||
cb.setTooltip('Add excluded folder');
|
||||
cb.onClick(() => {
|
||||
const excludedFolder = new ExcludedFolder('', settingsTab.plugin.settings.excludeFolders.length, undefined, settingsTab.plugin);
|
||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||
addExcludedFolder(settingsTab.plugin, excludedFolder);
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Add excluded folder')
|
||||
.setClass('add-exclude-folder-item')
|
||||
.addButton((cb) => {
|
||||
cb.setIcon('plus');
|
||||
cb.setClass('add-exclude-folder');
|
||||
cb.setTooltip('Add excluded folder');
|
||||
cb.onClick(() => {
|
||||
const excludedFolder = new ExcludedFolder('', settingsTab.plugin.settings.excludeFolders.length, undefined, settingsTab.plugin);
|
||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||
addExcludedFolder(settingsTab.plugin, excludedFolder);
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
|
||||
settingsTab.plugin.settings.excludeFolders.filter((folder) => !folder.hideInSettings).sort((a, b) => a.position - b.position).forEach((excludedFolder) => {
|
||||
if (excludedFolder.string?.trim() !== '' && excludedFolder.path?.trim() === '') {
|
||||
addExcludePatternListItem(settingsTab, containerEl, excludedFolder);
|
||||
} else {
|
||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
settingsTab.plugin.settings.excludeFolders.filter((folder) => !folder.hideInSettings).sort((a, b) => a.position - b.position).forEach((excludedFolder) => {
|
||||
if (excludedFolder.string?.trim() !== '' && excludedFolder.path?.trim() === '') {
|
||||
addExcludePatternListItem(settingsTab, containerEl, excludedFolder);
|
||||
} else {
|
||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,219 +1,219 @@
|
|||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
export async function renderFileExplorer(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Hide folder note')
|
||||
.setDesc('Hide the folder note in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideFolderNote)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideFolderNote = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('hide-folder-note');
|
||||
} else {
|
||||
document.body.classList.remove('hide-folder-note');
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Hide folder note')
|
||||
.setDesc('Hide the folder note in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideFolderNote)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideFolderNote = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('hide-folder-note');
|
||||
} else {
|
||||
document.body.classList.remove('hide-folder-note');
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
const setting2 = new Setting(containerEl)
|
||||
.setName('Don\'t open folder notes by clicking on the name (on mobile)')
|
||||
.setDesc('Folder notes don\'t open when clicking on the name of the folder (on mobile)')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.disableOpenFolderNoteOnClick)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.disableOpenFolderNoteOnClick = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
const setting2 = new Setting(containerEl)
|
||||
.setName('Don\'t open folder notes by clicking on the name (on mobile)')
|
||||
.setDesc('Folder notes don\'t open when clicking on the name of the folder (on mobile)')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.disableOpenFolderNoteOnClick)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.disableOpenFolderNoteOnClick = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
setting2.infoEl.appendText('Requires a restart to take effect');
|
||||
setting2.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
setting2.infoEl.appendText('Requires a restart to take effect');
|
||||
setting2.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Only open folder notes through the name')
|
||||
.setDesc('Only open folder notes in the file explorer by clicking on the folder name')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!settingsTab.plugin.settings.stopWhitespaceCollapsing)
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
document.body.classList.add('fn-whitespace-stop-collapsing');
|
||||
} else {
|
||||
document.body.classList.remove('fn-whitespace-stop-collapsing');
|
||||
}
|
||||
settingsTab.plugin.settings.stopWhitespaceCollapsing = !value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
const disableSetting = new Setting(containerEl);
|
||||
disableSetting.setName('Disable folder collapsing');
|
||||
disableSetting.setDesc('Disable the ability to collapse folders by clicking exactly on the folder name');
|
||||
disableSetting.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!settingsTab.plugin.settings.enableCollapsing)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.enableCollapsing = !value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
disableSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
disableSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
new Setting(containerEl)
|
||||
.setName('Only open folder notes through the name')
|
||||
.setDesc('Only open folder notes in the file explorer by clicking on the folder name')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!settingsTab.plugin.settings.stopWhitespaceCollapsing)
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
document.body.classList.add('fn-whitespace-stop-collapsing');
|
||||
} else {
|
||||
document.body.classList.remove('fn-whitespace-stop-collapsing');
|
||||
}
|
||||
settingsTab.plugin.settings.stopWhitespaceCollapsing = !value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Use submenus')
|
||||
.setDesc('Use submenus for file/folder commands')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.useSubmenus)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.useSubmenus = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
const disableSetting = new Setting(containerEl);
|
||||
disableSetting.setName('Disable folder collapsing');
|
||||
disableSetting.setDesc('Disable the ability to collapse folders by clicking exactly on the folder name');
|
||||
disableSetting.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!settingsTab.plugin.settings.enableCollapsing)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.enableCollapsing = !value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
disableSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
disableSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
if (settingsTab.plugin.settings.frontMatterTitle.enabled) {
|
||||
new Setting(containerEl)
|
||||
.setName('Change folder name in the file explorer')
|
||||
.setDesc('Automatically rename a folder name in the file explorer when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.explorer)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.explorer = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.plugin.app.vault.getFiles().forEach((file) => {
|
||||
settingsTab.plugin.fmtpHandler?.handleRename({ id: '', result: false, path: file.path }, false);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Use submenus')
|
||||
.setDesc('Use submenus for file/folder commands')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.useSubmenus)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.useSubmenus = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
settingsTab.settingsPage.createEl('h3', { text: 'Style settings' });
|
||||
if (settingsTab.plugin.settings.frontMatterTitle.enabled) {
|
||||
new Setting(containerEl)
|
||||
.setName('Change folder name in the file explorer')
|
||||
.setDesc('Automatically rename a folder name in the file explorer when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.explorer)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.explorer = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.plugin.app.vault.getFiles().forEach((file) => {
|
||||
settingsTab.plugin.fmtpHandler?.handleRename({ id: '', result: false, path: file.path }, false);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Highlight folder in the file explorer')
|
||||
.setDesc('Highlight the folder name in the file explorer when you click on a folder that has a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.highlightFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.highlightFolder = value;
|
||||
if (!value) {
|
||||
document.body.classList.add('disable-folder-highlight');
|
||||
} else {
|
||||
document.body.classList.remove('disable-folder-highlight');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
settingsTab.settingsPage.createEl('h3', { text: 'Style settings' });
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon')
|
||||
.setDesc('Hide the collapse icon in the file explorer next to the name of a folder when a folder only contains a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideCollapsingIcon)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideCollapsingIcon = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('fn-hide-collapse-icon');
|
||||
} else {
|
||||
document.body.classList.remove('fn-hide-collapse-icon');
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Highlight folder in the file explorer')
|
||||
.setDesc('Highlight the folder name in the file explorer when you click on a folder that has a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.highlightFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.highlightFolder = value;
|
||||
if (!value) {
|
||||
document.body.classList.add('disable-folder-highlight');
|
||||
} else {
|
||||
document.body.classList.remove('disable-folder-highlight');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon for every empty folder')
|
||||
.setDesc('Hide the collapse icon in the file explorer next to the name of a folder when a folder is empty')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideCollapsingIconForEmptyFolders)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideCollapsingIconForEmptyFolders = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('fn-hide-empty-collapse-icon');
|
||||
} else {
|
||||
document.body.classList.remove('fn-hide-empty-collapse-icon');
|
||||
}
|
||||
settingsTab.display();
|
||||
}
|
||||
));
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon')
|
||||
.setDesc('Hide the collapse icon in the file explorer next to the name of a folder when a folder only contains a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideCollapsingIcon)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideCollapsingIcon = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('fn-hide-collapse-icon');
|
||||
} else {
|
||||
document.body.classList.remove('fn-hide-collapse-icon');
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (settingsTab.plugin.settings.hideCollapsingIcon) {
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon also when the attachment folder is in the same folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.ignoreAttachmentFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.ignoreAttachmentFolder = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon for every empty folder')
|
||||
.setDesc('Hide the collapse icon in the file explorer next to the name of a folder when a folder is empty')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.hideCollapsingIconForEmptyFolders)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideCollapsingIconForEmptyFolders = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
document.body.classList.add('fn-hide-empty-collapse-icon');
|
||||
} else {
|
||||
document.body.classList.remove('fn-hide-empty-collapse-icon');
|
||||
}
|
||||
settingsTab.display();
|
||||
}
|
||||
));
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Underline the name of folder notes')
|
||||
.setDesc('Add an underline to folders that have a folder note in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolder = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
if (settingsTab.plugin.settings.hideCollapsingIcon) {
|
||||
new Setting(containerEl)
|
||||
.setName('Hide collapse icon also when the attachment folder is in the same folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.ignoreAttachmentFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.ignoreAttachmentFolder = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Bold the name of folder notes')
|
||||
.setDesc('Make the folder name bold in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.boldName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.boldName = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-bold');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-bold');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Underline the name of folder notes')
|
||||
.setDesc('Add an underline to folders that have a folder note in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolder = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Cursive the name of folder notes')
|
||||
.setDesc('Make the folder name cursive in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.cursiveName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.cursiveName = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-cursive');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-cursive');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Bold the name of folder notes')
|
||||
.setDesc('Make the folder name bold in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.boldName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.boldName = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-bold');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-bold');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Cursive the name of folder notes')
|
||||
.setDesc('Make the folder name cursive in the file explorer')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.cursiveName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.cursiveName = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-cursive');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-cursive');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import { FolderSuggest } from 'src/suggesters/FolderSuggester';
|
|||
import { createOverviewSettings } from 'src/obsidian-folder-overview/src/settings';
|
||||
|
||||
export async function renderFolderOverview(settingsTab: SettingsTab) {
|
||||
const { plugin } = settingsTab;
|
||||
let overviewSettings = plugin.settings.defaultOverview;
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
containerEl.createEl('p', { text: 'Edit the default settings for folder overviews', cls: 'setting-item-description' });
|
||||
const { plugin } = settingsTab;
|
||||
const overviewSettings = plugin.settings.defaultOverview;
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
containerEl.createEl('p', { text: 'Edit the default settings for folder overviews', cls: 'setting-item-description' });
|
||||
|
||||
createOverviewSettings(containerEl, overviewSettings, plugin, plugin.settings.defaultOverview, settingsTab.display, undefined, undefined, undefined, settingsTab );
|
||||
createOverviewSettings(containerEl, overviewSettings, plugin, plugin.settings.defaultOverview, settingsTab.display, undefined, undefined, undefined, settingsTab);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,411 +10,411 @@ import BackupWarningModal from './modals/BackupWarning';
|
|||
import RenameFolderNotesModal from './modals/RenameFns';
|
||||
|
||||
export async function renderGeneral(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
const nameSetting = new Setting(containerEl)
|
||||
.setName('Folder note name')
|
||||
.setDesc('{{folder_name}} will be replaced with the name of the folder')
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(settingsTab.plugin.settings.folderNoteName)
|
||||
.onChange(async (value) => {
|
||||
if (value.trim() === '') { return; }
|
||||
settingsTab.plugin.settings.folderNoteName = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Rename existing folder notes')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
new RenameFolderNotesModal(
|
||||
settingsTab.plugin,
|
||||
'Rename all existing folder notes',
|
||||
'When you click on "Confirm" all existing folder notes will be renamed to the new folder note name.',
|
||||
settingsTab.renameFolderNotes,
|
||||
[])
|
||||
.open();
|
||||
})
|
||||
);
|
||||
nameSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
nameSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
const nameSetting = new Setting(containerEl)
|
||||
.setName('Folder note name')
|
||||
.setDesc('{{folder_name}} will be replaced with the name of the folder')
|
||||
.addText((text) =>
|
||||
text
|
||||
.setValue(settingsTab.plugin.settings.folderNoteName)
|
||||
.onChange(async (value) => {
|
||||
if (value.trim() === '') { return; }
|
||||
settingsTab.plugin.settings.folderNoteName = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Rename existing folder notes')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
new RenameFolderNotesModal(
|
||||
settingsTab.plugin,
|
||||
'Rename all existing folder notes',
|
||||
'When you click on "Confirm" all existing folder notes will be renamed to the new folder note name.',
|
||||
settingsTab.renameFolderNotes,
|
||||
[])
|
||||
.open();
|
||||
})
|
||||
);
|
||||
nameSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
nameSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
if (settingsTab.plugin.settings.folderNoteName !== '{{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.')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.tabManagerEnabled)
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
settingsTab.plugin.tabManager.resetTabs();
|
||||
} else {
|
||||
settingsTab.plugin.settings.tabManagerEnabled = value;
|
||||
settingsTab.plugin.tabManager.updateTabs();
|
||||
}
|
||||
settingsTab.plugin.settings.tabManagerEnabled = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
if (settingsTab.plugin.settings.folderNoteName !== '{{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.')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.tabManagerEnabled)
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
settingsTab.plugin.tabManager.resetTabs();
|
||||
} else {
|
||||
settingsTab.plugin.settings.tabManagerEnabled = value;
|
||||
settingsTab.plugin.tabManager.updateTabs();
|
||||
}
|
||||
settingsTab.plugin.settings.tabManagerEnabled = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Default folder note type for new folder notes')
|
||||
.setDesc('Choose the default file type for new folder notes. (canvas, markdown, ...)')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('.ask', 'ask for file type');
|
||||
settingsTab.plugin.settings.supportedFileTypes.forEach((type) => {
|
||||
if (type === '.md' || type === 'md') {
|
||||
dropdown.addOption('.md', 'markdown');
|
||||
} else {
|
||||
dropdown.addOption('.' + type, type);
|
||||
}
|
||||
});
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes.includes(settingsTab.plugin.settings.folderNoteType.replace('.', '')) && settingsTab.plugin.settings.folderNoteType !== '.ask') {
|
||||
settingsTab.plugin.settings.folderNoteType = '.md';
|
||||
settingsTab.plugin.saveSettings();
|
||||
}
|
||||
const defaultType = settingsTab.plugin.settings.folderNoteType.startsWith('.') ? settingsTab.plugin.settings.folderNoteType : '.' + settingsTab.plugin.settings.folderNoteType;
|
||||
new Setting(containerEl)
|
||||
.setName('Default folder note type for new folder notes')
|
||||
.setDesc('Choose the default file type for new folder notes. (canvas, markdown, ...)')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('.ask', 'ask for file type');
|
||||
settingsTab.plugin.settings.supportedFileTypes.forEach((type) => {
|
||||
if (type === '.md' || type === 'md') {
|
||||
dropdown.addOption('.md', 'markdown');
|
||||
} else {
|
||||
dropdown.addOption('.' + type, type);
|
||||
}
|
||||
});
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes.includes(settingsTab.plugin.settings.folderNoteType.replace('.', '')) && settingsTab.plugin.settings.folderNoteType !== '.ask') {
|
||||
settingsTab.plugin.settings.folderNoteType = '.md';
|
||||
settingsTab.plugin.saveSettings();
|
||||
}
|
||||
const defaultType = settingsTab.plugin.settings.folderNoteType.startsWith('.') ? settingsTab.plugin.settings.folderNoteType : '.' + settingsTab.plugin.settings.folderNoteType;
|
||||
|
||||
dropdown
|
||||
.setValue(defaultType)
|
||||
.onChange(async (value: '.md' | '.canvas') => {
|
||||
settingsTab.plugin.settings.folderNoteType = value;
|
||||
settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
});
|
||||
dropdown
|
||||
.setValue(defaultType)
|
||||
.onChange(async (value: '.md' | '.canvas') => {
|
||||
settingsTab.plugin.settings.folderNoteType = value;
|
||||
settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
|
||||
const setting0 = new Setting(containerEl)
|
||||
setting0.setName('Supported file types for folder notes')
|
||||
const desc0 = document.createDocumentFragment();
|
||||
desc0.append(
|
||||
'Choose the file types that should be supported for folder notes. (e.g. if you click on a folder name it searches for all file extensions that are supported)',
|
||||
desc0.createEl('br'),
|
||||
'Adding more file types may cause performance issues becareful when adding more file types and don\'t add too many.',
|
||||
)
|
||||
setting0.setDesc(desc0);
|
||||
const list = new ListComponent(setting0.settingEl, settingsTab.plugin.settings.supportedFileTypes || [], ['md', 'canvas']);
|
||||
list.on('update', async (values: string[]) => {
|
||||
settingsTab.plugin.settings.supportedFileTypes = values;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
const setting0 = new Setting(containerEl);
|
||||
setting0.setName('Supported file types for folder notes');
|
||||
const desc0 = document.createDocumentFragment();
|
||||
desc0.append(
|
||||
'Choose the file types that should be supported for folder notes. (e.g. if you click on a folder name it searches for all file extensions that are supported)',
|
||||
desc0.createEl('br'),
|
||||
'Adding more file types may cause performance issues becareful when adding more file types and don\'t add too many.',
|
||||
);
|
||||
setting0.setDesc(desc0);
|
||||
const list = new ListComponent(setting0.settingEl, settingsTab.plugin.settings.supportedFileTypes || [], ['md', 'canvas']);
|
||||
list.on('update', async (values: string[]) => {
|
||||
settingsTab.plugin.settings.supportedFileTypes = values;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
});
|
||||
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes.includes('md') || !settingsTab.plugin.settings.supportedFileTypes.includes('canvas') || !settingsTab.plugin.settings.supportedFileTypes.includes('excalidraw')) {
|
||||
setting0.addDropdown((dropdown) => {
|
||||
const options = [
|
||||
{ value: 'md', label: 'Markdown' },
|
||||
{ value: 'canvas', label: 'Canvas' },
|
||||
{ value: 'excalidraw', label: 'excalidraw' },
|
||||
{ value: 'custom', label: 'Custom extension' },
|
||||
];
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes.includes('md') || !settingsTab.plugin.settings.supportedFileTypes.includes('canvas') || !settingsTab.plugin.settings.supportedFileTypes.includes('excalidraw')) {
|
||||
setting0.addDropdown((dropdown) => {
|
||||
const options = [
|
||||
{ value: 'md', label: 'Markdown' },
|
||||
{ value: 'canvas', label: 'Canvas' },
|
||||
{ value: 'excalidraw', label: 'excalidraw' },
|
||||
{ value: 'custom', label: 'Custom extension' },
|
||||
];
|
||||
|
||||
options.forEach((option) => {
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes?.includes(option.value)) {
|
||||
dropdown.addOption(option.value, option.label);
|
||||
}
|
||||
});
|
||||
dropdown.addOption('+', '+');
|
||||
dropdown.setValue('+');
|
||||
dropdown.onChange(async (value) => {
|
||||
if (value === 'custom') {
|
||||
return new AddSupportedFileModal(settingsTab.app, settingsTab.plugin, settingsTab, list as ListComponent).open();
|
||||
}
|
||||
await list.addValue(value.toLowerCase());
|
||||
settingsTab.display();
|
||||
settingsTab.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setting0.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Add custom file type')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
new AddSupportedFileModal(settingsTab.app, settingsTab.plugin, settingsTab, list as ListComponent).open();
|
||||
})
|
||||
);
|
||||
}
|
||||
options.forEach((option) => {
|
||||
if (!settingsTab.plugin.settings.supportedFileTypes?.includes(option.value)) {
|
||||
dropdown.addOption(option.value, option.label);
|
||||
}
|
||||
});
|
||||
dropdown.addOption('+', '+');
|
||||
dropdown.setValue('+');
|
||||
dropdown.onChange(async (value) => {
|
||||
if (value === 'custom') {
|
||||
return new AddSupportedFileModal(settingsTab.app, settingsTab.plugin, settingsTab, list as ListComponent).open();
|
||||
}
|
||||
await list.addValue(value.toLowerCase());
|
||||
settingsTab.display();
|
||||
settingsTab.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setting0.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Add custom file type')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
new AddSupportedFileModal(settingsTab.app, settingsTab.plugin, settingsTab, list as ListComponent).open();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const templateSetting = new Setting(containerEl)
|
||||
.setDesc('Requires templates/templater plugin to be enabled')
|
||||
.setName('Template path')
|
||||
.addSearch((cb) => {
|
||||
new TemplateSuggest(cb.inputEl, settingsTab.plugin);
|
||||
cb.setPlaceholder('Template path');
|
||||
cb.setValue(settingsTab.plugin.app.vault.getAbstractFileByPath(settingsTab.plugin.settings.templatePath)?.name.replace('.md', '') || '');
|
||||
cb.onChange(async (value) => {
|
||||
if (value.trim() === '') {
|
||||
settingsTab.plugin.settings.templatePath = '';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
templateSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
templateSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
const templateSetting = new Setting(containerEl)
|
||||
.setDesc('Requires templates/templater plugin to be enabled')
|
||||
.setName('Template path')
|
||||
.addSearch((cb) => {
|
||||
new TemplateSuggest(cb.inputEl, settingsTab.plugin);
|
||||
cb.setPlaceholder('Template path');
|
||||
cb.setValue(settingsTab.plugin.app.vault.getAbstractFileByPath(settingsTab.plugin.settings.templatePath)?.name.replace('.md', '') || '');
|
||||
cb.onChange(async (value) => {
|
||||
if (value.trim() === '') {
|
||||
settingsTab.plugin.settings.templatePath = '';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
templateSetting.infoEl.appendText('Requires a restart to take effect');
|
||||
templateSetting.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
const storageLocation = new Setting(containerEl)
|
||||
.setName('Storage location')
|
||||
.setDesc('Choose where to store the folder notes')
|
||||
.addDropdown((dropdown) =>
|
||||
dropdown
|
||||
.addOption('insideFolder', 'Inside the folder')
|
||||
.addOption('parentFolder', 'In the parent folder')
|
||||
.setValue(settingsTab.plugin.settings.storageLocation)
|
||||
.onChange(async (value: 'insideFolder' | 'parentFolder' | 'vaultFolder') => {
|
||||
settingsTab.plugin.settings.storageLocation = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
loadFileClasses(undefined, settingsTab.plugin);
|
||||
})
|
||||
)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Switch')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
let oldStorageLocation = settingsTab.plugin.settings.storageLocation;
|
||||
if (settingsTab.plugin.settings.storageLocation === 'parentFolder') {
|
||||
oldStorageLocation = 'insideFolder';
|
||||
} else if (settingsTab.plugin.settings.storageLocation === 'insideFolder') {
|
||||
oldStorageLocation = 'parentFolder';
|
||||
}
|
||||
new BackupWarningModal(
|
||||
settingsTab.plugin,
|
||||
'Switch storage location',
|
||||
'When you click on "Confirm" all folder notes will be moved to the new storage location.',
|
||||
settingsTab.switchStorageLocation,
|
||||
[oldStorageLocation]
|
||||
).open();
|
||||
})
|
||||
);
|
||||
storageLocation.infoEl.appendText('Requires a restart to take effect');
|
||||
storageLocation.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
const storageLocation = new Setting(containerEl)
|
||||
.setName('Storage location')
|
||||
.setDesc('Choose where to store the folder notes')
|
||||
.addDropdown((dropdown) =>
|
||||
dropdown
|
||||
.addOption('insideFolder', 'Inside the folder')
|
||||
.addOption('parentFolder', 'In the parent folder')
|
||||
.setValue(settingsTab.plugin.settings.storageLocation)
|
||||
.onChange(async (value: 'insideFolder' | 'parentFolder' | 'vaultFolder') => {
|
||||
settingsTab.plugin.settings.storageLocation = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
loadFileClasses(undefined, settingsTab.plugin);
|
||||
})
|
||||
)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText('Switch')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
let oldStorageLocation = settingsTab.plugin.settings.storageLocation;
|
||||
if (settingsTab.plugin.settings.storageLocation === 'parentFolder') {
|
||||
oldStorageLocation = 'insideFolder';
|
||||
} else if (settingsTab.plugin.settings.storageLocation === 'insideFolder') {
|
||||
oldStorageLocation = 'parentFolder';
|
||||
}
|
||||
new BackupWarningModal(
|
||||
settingsTab.plugin,
|
||||
'Switch storage location',
|
||||
'When you click on "Confirm" all folder notes will be moved to the new storage location.',
|
||||
settingsTab.switchStorageLocation,
|
||||
[oldStorageLocation]
|
||||
).open();
|
||||
})
|
||||
);
|
||||
storageLocation.infoEl.appendText('Requires a restart to take effect');
|
||||
storageLocation.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
if (settingsTab.plugin.settings.storageLocation === 'parentFolder') {
|
||||
new Setting(containerEl)
|
||||
.setName('Delete folder notes when deleting the folder')
|
||||
.setDesc('Delete the folder note when deleting the folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncDelete)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncDelete = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
}
|
||||
)
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Move folder notes when moving the folder')
|
||||
.setDesc('Move the folder note when moving the folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncMove)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncMove = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
if (Platform.isDesktopApp) {
|
||||
new Setting(containerEl)
|
||||
.setName('Key for creating folder note')
|
||||
.setDesc('The key combination to create a folder note')
|
||||
.addDropdown((dropdown) => {
|
||||
if (!Platform.isMacOS) {
|
||||
dropdown.addOption('ctrl', 'Ctrl + Click');
|
||||
} else {
|
||||
dropdown.addOption('ctrl', 'Cmd + Click');
|
||||
}
|
||||
dropdown.addOption('alt', 'Alt + Click');
|
||||
dropdown.setValue(settingsTab.plugin.settings.ctrlKey ? 'ctrl' : 'alt');
|
||||
dropdown.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.ctrlKey = value === 'ctrl';
|
||||
settingsTab.plugin.settings.altKey = value === 'alt';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
if (settingsTab.plugin.settings.storageLocation === 'parentFolder') {
|
||||
new Setting(containerEl)
|
||||
.setName('Delete folder notes when deleting the folder')
|
||||
.setDesc('Delete the folder note when deleting the folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncDelete)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncDelete = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
}
|
||||
)
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Move folder notes when moving the folder')
|
||||
.setDesc('Move the folder note when moving the folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncMove)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncMove = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
if (Platform.isDesktopApp) {
|
||||
new Setting(containerEl)
|
||||
.setName('Key for creating folder note')
|
||||
.setDesc('The key combination to create a folder note')
|
||||
.addDropdown((dropdown) => {
|
||||
if (!Platform.isMacOS) {
|
||||
dropdown.addOption('ctrl', 'Ctrl + Click');
|
||||
} else {
|
||||
dropdown.addOption('ctrl', 'Cmd + Click');
|
||||
}
|
||||
dropdown.addOption('alt', 'Alt + Click');
|
||||
dropdown.setValue(settingsTab.plugin.settings.ctrlKey ? 'ctrl' : 'alt');
|
||||
dropdown.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.ctrlKey = value === 'ctrl';
|
||||
settingsTab.plugin.settings.altKey = value === 'alt';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Key for opening folder note')
|
||||
.setDesc('Select the combination to open a folder note')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('click', 'Mouse Click');
|
||||
if (!Platform.isMacOS) {
|
||||
dropdown.addOption('ctrl', 'Ctrl + Click');
|
||||
} else {
|
||||
dropdown.addOption('ctrl', 'Cmd + Click');
|
||||
}
|
||||
dropdown.addOption('alt', 'Alt + Click');
|
||||
if (settingsTab.plugin.settings.openByClick) {
|
||||
dropdown.setValue('click');
|
||||
} else if (settingsTab.plugin.settings.openWithCtrl) {
|
||||
dropdown.setValue('ctrl');
|
||||
} else {
|
||||
dropdown.setValue('alt');
|
||||
}
|
||||
dropdown.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openByClick = value === 'click';
|
||||
settingsTab.plugin.settings.openWithCtrl = value === 'ctrl';
|
||||
settingsTab.plugin.settings.openWithAlt = value === 'alt';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Key for opening folder note')
|
||||
.setDesc('Select the combination to open a folder note')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('click', 'Mouse Click');
|
||||
if (!Platform.isMacOS) {
|
||||
dropdown.addOption('ctrl', 'Ctrl + Click');
|
||||
} else {
|
||||
dropdown.addOption('ctrl', 'Cmd + Click');
|
||||
}
|
||||
dropdown.addOption('alt', 'Alt + Click');
|
||||
if (settingsTab.plugin.settings.openByClick) {
|
||||
dropdown.setValue('click');
|
||||
} else if (settingsTab.plugin.settings.openWithCtrl) {
|
||||
dropdown.setValue('ctrl');
|
||||
} else {
|
||||
dropdown.setValue('alt');
|
||||
}
|
||||
dropdown.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openByClick = value === 'click';
|
||||
settingsTab.plugin.settings.openWithCtrl = value === 'ctrl';
|
||||
settingsTab.plugin.settings.openWithAlt = value === 'alt';
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Sync folder name')
|
||||
.setDesc('Automatically rename the folder note when the folder name is changed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncFolderName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncFolderName = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Sync folder name')
|
||||
.setDesc('Automatically rename the folder note when the folder name is changed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.syncFolderName)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.syncFolderName = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Confirm folder note deletion')
|
||||
.setDesc('Ask for confirmation before deleting a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.showDeleteConfirmation)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.showDeleteConfirmation = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Confirm folder note deletion')
|
||||
.setDesc('Ask for confirmation before deleting a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.showDeleteConfirmation)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.showDeleteConfirmation = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Deleted folder notes')
|
||||
.setDesc('What happens to the folder note after you delete it')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('trash', 'Move to system trash');
|
||||
dropdown.addOption('obsidianTrash', 'Move to Obsidian trash (.trash folder)');
|
||||
dropdown.addOption('delete', 'Delete permanently');
|
||||
dropdown.setValue(settingsTab.plugin.settings.deleteFilesAction);
|
||||
dropdown.onChange(async (value: 'trash' | 'delete' | 'obsidianTrash') => {
|
||||
settingsTab.plugin.settings.deleteFilesAction = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Deleted folder notes')
|
||||
.setDesc('What happens to the folder note after you delete it')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown.addOption('trash', 'Move to system trash');
|
||||
dropdown.addOption('obsidianTrash', 'Move to Obsidian trash (.trash folder)');
|
||||
dropdown.addOption('delete', 'Delete permanently');
|
||||
dropdown.setValue(settingsTab.plugin.settings.deleteFilesAction);
|
||||
dropdown.onChange(async (value: 'trash' | 'delete' | 'obsidianTrash') => {
|
||||
settingsTab.plugin.settings.deleteFilesAction = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
|
||||
if (Platform.isDesktop) {
|
||||
const setting3 = new Setting(containerEl);
|
||||
setting3.setName('Open folder note in a new tab by default');
|
||||
setting3.setDesc('Always open folder notes in a new tab (except when you try to open the same note) instead of having to use ctrl/cmd + click to open in a new tab');
|
||||
setting3.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openInNewTab)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openInNewTab = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
setting3.infoEl.appendText('Requires a restart to take effect');
|
||||
setting3.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
}
|
||||
if (Platform.isDesktop) {
|
||||
const setting3 = new Setting(containerEl);
|
||||
setting3.setName('Open folder note in a new tab by default');
|
||||
setting3.setDesc('Always open folder notes in a new tab (except when you try to open the same note) instead of having to use ctrl/cmd + click to open in a new tab');
|
||||
setting3.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openInNewTab)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openInNewTab = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
setting3.infoEl.appendText('Requires a restart to take effect');
|
||||
setting3.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Enable front matter title plugin integration')
|
||||
.setDesc('Automatically rename a folder name when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.enabled)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.enabled = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
settingsTab.plugin.fmtpHandler = new FrontMatterTitlePluginHandler(settingsTab.plugin);
|
||||
} else {
|
||||
if (settingsTab.plugin.fmtpHandler) {
|
||||
settingsTab.plugin.updateBreadcrumbs(true);
|
||||
}
|
||||
settingsTab.plugin.app.vault.getFiles().forEach((file) => {
|
||||
settingsTab.plugin.fmtpHandler?.handleRename({ id: '', result: false, path: file.path }, false);
|
||||
});
|
||||
settingsTab.plugin.fmtpHandler?.deleteEvent();
|
||||
settingsTab.plugin.fmtpHandler = null;
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Enable front matter title plugin integration')
|
||||
.setDesc('Automatically rename a folder name when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.enabled)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.enabled = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
settingsTab.plugin.fmtpHandler = new FrontMatterTitlePluginHandler(settingsTab.plugin);
|
||||
} else {
|
||||
if (settingsTab.plugin.fmtpHandler) {
|
||||
settingsTab.plugin.updateBreadcrumbs(true);
|
||||
}
|
||||
settingsTab.plugin.app.vault.getFiles().forEach((file) => {
|
||||
settingsTab.plugin.fmtpHandler?.handleRename({ id: '', result: false, path: file.path }, false);
|
||||
});
|
||||
settingsTab.plugin.fmtpHandler?.deleteEvent();
|
||||
settingsTab.plugin.fmtpHandler = null;
|
||||
}
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Create folder note for every folder')
|
||||
.setDesc('Create a folder note for every folder in the vault')
|
||||
.addButton((cb) => {
|
||||
cb.setIcon('plus');
|
||||
cb.setTooltip('Create folder notes');
|
||||
cb.onClick(async () => {
|
||||
new ConfirmationModal(settingsTab.app, settingsTab.plugin).open();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('Create folder note for every folder')
|
||||
.setDesc('Create a folder note for every folder in the vault')
|
||||
.addButton((cb) => {
|
||||
cb.setIcon('plus');
|
||||
cb.setTooltip('Create folder notes');
|
||||
cb.onClick(async () => {
|
||||
new ConfirmationModal(settingsTab.app, settingsTab.plugin).open();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Automatically create folder notes')
|
||||
.setDesc('Automatically create a folder note when a new folder is created')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreate)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreate = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Automatically create folder notes')
|
||||
.setDesc('Automatically create a folder note when a new folder is created')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreate)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreate = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (settingsTab.plugin.settings.autoCreate) {
|
||||
new Setting(containerEl)
|
||||
.setName('Open folder note after creating')
|
||||
.setDesc('Automatically open the folder note after automatically creating it')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateFocusFiles)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateFocusFiles = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
if (settingsTab.plugin.settings.autoCreate) {
|
||||
new Setting(containerEl)
|
||||
.setName('Open folder note after creating')
|
||||
.setDesc('Automatically open the folder note after automatically creating it')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateFocusFiles)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateFocusFiles = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Auto create folder note for attachment folder')
|
||||
.setDesc('Automatically create a folder note for the attachment folder when you attach a file to a note and the attachment folder gets created')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateForAttachmentFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateForAttachmentFolder = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Auto create folder note for attachment folder')
|
||||
.setDesc('Automatically create a folder note for the attachment folder when you attach a file to a note and the attachment folder gets created')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateForAttachmentFolder)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateForAttachmentFolder = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Automatically create folder note when you create a note')
|
||||
.setDesc('Automatically create a folder note when a note is created. It has to be a file type that you selected in the supported file types')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateForFiles)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateForFiles = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Automatically create folder note when you create a note')
|
||||
.setDesc('Automatically create a folder note when a note is created. It has to be a file type that you selected in the supported file types')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.autoCreateForFiles)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.autoCreateForFiles = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,111 +1,111 @@
|
|||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from './SettingsTab';
|
||||
export async function renderPath(settingsTab: SettingsTab) {
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
new Setting(containerEl)
|
||||
.setName('Open folder note through path')
|
||||
.setDesc('Open a folder note when clicking on a folder name in the path if it is a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openFolderNoteOnClickInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openFolderNoteOnClickInPath = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
const containerEl = settingsTab.settingsPage;
|
||||
new Setting(containerEl)
|
||||
.setName('Open folder note through path')
|
||||
.setDesc('Open a folder note when clicking on a folder name in the path if it is a folder note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openFolderNoteOnClickInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openFolderNoteOnClickInPath = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Open sidebar when opening a folder note through path (Mobile only)')
|
||||
.setDesc('Open the sidebar when opening a folder note through the path on mobile')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openSidebar.mobile)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openSidebar.mobile = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Open sidebar when opening a folder note through path (Mobile only)')
|
||||
.setDesc('Open the sidebar when opening a folder note through the path on mobile')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openSidebar.mobile)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openSidebar.mobile = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Open sidebar when opening a folder note through path (Desktop only)')
|
||||
.setDesc('Open the sidebar when opening a folder note through the path on desktop')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openSidebar.desktop)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openSidebar.desktop = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Open sidebar when opening a folder note through path (Desktop only)')
|
||||
.setDesc('Open the sidebar when opening a folder note through the path on desktop')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.openSidebar.desktop)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.openSidebar.desktop = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Change folder name in the path')
|
||||
.setDesc('Automatically rename a folder name in the path above a note when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.path)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.path = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
settingsTab.plugin.updateBreadcrumbs();
|
||||
} else {
|
||||
settingsTab.plugin.updateBreadcrumbs(true);
|
||||
}
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Change folder name in the path')
|
||||
.setDesc('Automatically rename a folder name in the path above a note when the folder note is renamed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.frontMatterTitle.path)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.frontMatterTitle.path = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
settingsTab.plugin.updateBreadcrumbs();
|
||||
} else {
|
||||
settingsTab.plugin.updateBreadcrumbs(true);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
settingsTab.settingsPage.createEl('h3', { text: 'Style settings' });
|
||||
settingsTab.settingsPage.createEl('h3', { text: 'Style settings' });
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Underline folders in the path')
|
||||
.setDesc('Add an underline to folders that have a folder note in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolderInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolderInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Underline folders in the path')
|
||||
.setDesc('Add an underline to folders that have a folder note in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolderInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolderInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Bold folders in the path')
|
||||
.setDesc('Make the folder name bold in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.boldNameInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.boldNameInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-bold-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-bold-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName('Bold folders in the path')
|
||||
.setDesc('Make the folder name bold in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.boldNameInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.boldNameInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-bold-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-bold-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Cursive the name of folder notes in the path')
|
||||
.setDesc('Make the folder name cursive in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.cursiveNameInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.cursiveNameInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-cursive-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-cursive-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Cursive the name of folder notes in the path')
|
||||
.setDesc('Make the folder name cursive in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.cursiveNameInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.cursiveNameInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-cursive-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-cursive-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export const DEFAULT_SETTINGS: FolderNotesSettings = {
|
|||
disableCollapseIcon: true,
|
||||
alwaysCollapse: false,
|
||||
autoSync: true,
|
||||
allowDragAndDrop: true
|
||||
allowDragAndDrop: true,
|
||||
},
|
||||
useSubmenus: true,
|
||||
syncMove: true,
|
||||
|
|
@ -191,15 +191,15 @@ export class SettingsTab extends PluginSettingTab {
|
|||
TABS = {
|
||||
GENERAL: {
|
||||
name: 'General',
|
||||
id: 'general'
|
||||
id: 'general',
|
||||
},
|
||||
FOLDER_OVERVIEW: {
|
||||
name: 'Folder overview',
|
||||
id: 'folder_overview'
|
||||
id: 'folder_overview',
|
||||
},
|
||||
EXCLUDE_FOLDERS: {
|
||||
name: 'Exclude folders',
|
||||
id: 'exclude_folders'
|
||||
id: 'exclude_folders',
|
||||
},
|
||||
FILE_EXPLORER: {
|
||||
name: 'File explorer',
|
||||
|
|
@ -207,9 +207,9 @@ export class SettingsTab extends PluginSettingTab {
|
|||
},
|
||||
PATH: {
|
||||
name: 'Path',
|
||||
id: 'path'
|
||||
}
|
||||
}
|
||||
id: 'path',
|
||||
},
|
||||
};
|
||||
renderSettingsPage(tabId: string) {
|
||||
this.settingsPage.empty();
|
||||
switch (tabId.toLocaleLowerCase()) {
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
import { Modal, App, ButtonComponent, Setting } from "obsidian";
|
||||
import FolderNotesPlugin from "src/main";
|
||||
import { Modal, App, ButtonComponent, Setting } from 'obsidian';
|
||||
import FolderNotesPlugin from 'src/main';
|
||||
|
||||
export default class BackupWarningModal extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
title: string;
|
||||
desc: string;
|
||||
callback: (...args: any[]) => void;
|
||||
args: any[];
|
||||
plugin: FolderNotesPlugin;
|
||||
title: string;
|
||||
desc: string;
|
||||
callback: (...args: any[]) => void;
|
||||
args: any[];
|
||||
|
||||
constructor(plugin: FolderNotesPlugin, title: string, description: string, callback: (...args: any[]) => void, args: any[] = []) {
|
||||
super(plugin.app);
|
||||
this.plugin = plugin;
|
||||
this.title = title;
|
||||
this.callback = callback;
|
||||
this.args = args;
|
||||
this.desc = description;
|
||||
}
|
||||
constructor(plugin: FolderNotesPlugin, title: string, description: string, callback: (...args: any[]) => void, args: any[] = []) {
|
||||
super(plugin.app);
|
||||
this.plugin = plugin;
|
||||
this.title = title;
|
||||
this.callback = callback;
|
||||
this.args = args;
|
||||
this.desc = description;
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
this.modalEl.addClass('fn-backup-warning-modal');
|
||||
const { contentEl } = this;
|
||||
onOpen() {
|
||||
this.modalEl.addClass('fn-backup-warning-modal');
|
||||
const { contentEl } = this;
|
||||
|
||||
contentEl.createEl("h2", { text: this.title });
|
||||
contentEl.createEl('h2', { text: this.title });
|
||||
|
||||
contentEl.createEl('p', { text: this.desc });
|
||||
contentEl.createEl('p', { text: this.desc });
|
||||
|
||||
this.insertCustomHtml();
|
||||
this.insertCustomHtml();
|
||||
|
||||
contentEl.createEl('p', { text: 'Make sure to backup your vault before using this feature.' }).style.color = '#fb464c';
|
||||
|
||||
const buttonContainer = contentEl.createDiv({ cls: 'fn-modal-button-container' });
|
||||
const confirmButton = new ButtonComponent(buttonContainer);
|
||||
confirmButton.setButtonText("Confirm")
|
||||
.setCta()
|
||||
.onClick(() => {
|
||||
this.callback(...this.args)
|
||||
this.close();
|
||||
});
|
||||
const buttonContainer = contentEl.createDiv({ cls: 'fn-modal-button-container' });
|
||||
const confirmButton = new ButtonComponent(buttonContainer);
|
||||
confirmButton.setButtonText('Confirm')
|
||||
.setCta()
|
||||
.onClick(() => {
|
||||
this.callback(...this.args);
|
||||
this.close();
|
||||
});
|
||||
|
||||
const cancelButton = new ButtonComponent(buttonContainer);
|
||||
cancelButton.setButtonText("Cancel")
|
||||
.onClick(() => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
const cancelButton = new ButtonComponent(buttonContainer);
|
||||
cancelButton.setButtonText('Cancel')
|
||||
.onClick(() => {
|
||||
this.close();
|
||||
});
|
||||
}
|
||||
|
||||
insertCustomHtml(): void {
|
||||
insertCustomHtml(): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export {}
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
import BackupWarningModal from "./BackupWarning";
|
||||
import FolderNotesPlugin from "src/main";
|
||||
import { Setting } from "obsidian";
|
||||
import BackupWarningModal from './BackupWarning';
|
||||
import FolderNotesPlugin from 'src/main';
|
||||
import { Setting } from 'obsidian';
|
||||
|
||||
export default class RenameFolderNotesModal extends BackupWarningModal {
|
||||
constructor(plugin: FolderNotesPlugin, title: string, description: string, callback: (...args: any[]) => void, args: any[] = []) {
|
||||
super(plugin, title, description, callback, args);
|
||||
}
|
||||
constructor(plugin: FolderNotesPlugin, title: string, description: string, callback: (...args: any[]) => void, args: any[] = []) {
|
||||
super(plugin, title, description, callback, args);
|
||||
}
|
||||
|
||||
insertCustomHtml(): void {
|
||||
const { contentEl } = this;
|
||||
new Setting(contentEl)
|
||||
.setName('Old Folder Note Name')
|
||||
.setDesc('Every folder note that matches this name will be renamed to the new folder note name.')
|
||||
.addText(text => text
|
||||
.setPlaceholder('Enter the old folder note name')
|
||||
.setValue(this.plugin.settings.oldFolderNoteName || '')
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.oldFolderNoteName = value;
|
||||
})
|
||||
);
|
||||
insertCustomHtml(): void {
|
||||
const { contentEl } = this;
|
||||
new Setting(contentEl)
|
||||
.setName('Old Folder Note Name')
|
||||
.setDesc('Every folder note that matches this name will be renamed to the new folder note name.')
|
||||
.addText((text) => text
|
||||
.setPlaceholder('Enter the old folder note name')
|
||||
.setValue(this.plugin.settings.oldFolderNoteName || '')
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.oldFolderNoteName = value;
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('New Folder Note Name')
|
||||
.setDesc('Every folder note that matches the old folder note name will be renamed to this name.')
|
||||
.addText(text => text
|
||||
.setPlaceholder('Enter the new folder note name')
|
||||
.setValue(this.plugin.settings.folderNoteName || '')
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.folderNoteName = value;
|
||||
this.plugin.settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
new Setting(contentEl)
|
||||
.setName('New Folder Note Name')
|
||||
.setDesc('Every folder note that matches the old folder note name will be renamed to this name.')
|
||||
.addText((text) => text
|
||||
.setPlaceholder('Enter the new folder note name')
|
||||
.setValue(this.plugin.settings.folderNoteName || '')
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.folderNoteName = value;
|
||||
this.plugin.settingsTab.display();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class FolderSuggest extends TextInputSuggest<TFolder> {
|
|||
if (
|
||||
folder instanceof TFolder &&
|
||||
folder.path.toLowerCase().contains(lower_input_str) &&
|
||||
(!this.plugin.settings.excludeFolders.find((f) => f.path === folder.path) || this.whitelistSuggester)
|
||||
(!this.plugin.settings.excludeFolders.find((f) => f.path === folder.path) || this.whitelistSuggester)
|
||||
) {
|
||||
folders.push(folder);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
|
||||
getSuggestions(input_str: string): TFile[] {
|
||||
const { templateFolder, templaterPlugin } = getTemplatePlugins(this.app);
|
||||
|
||||
|
||||
let files: TFile[] = [];
|
||||
const lower_input_str = input_str.toLowerCase();
|
||||
|
||||
|
||||
if ((!templateFolder || templateFolder.trim() === '') && !templaterPlugin) {
|
||||
console.log('Template folder not found');
|
||||
console.log(lower_input_str)
|
||||
console.log(lower_input_str);
|
||||
files = this.plugin.app.vault.getFiles().filter((file) =>
|
||||
file.path.toLowerCase().includes(lower_input_str)
|
||||
);
|
||||
|
|
@ -45,28 +45,28 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
} else {
|
||||
folder = this.plugin.app.vault.getAbstractFileByPath(templateFolder) as TFolder;
|
||||
}
|
||||
|
||||
|
||||
Vault.recurseChildren(folder, (file: TAbstractFile) => {
|
||||
if (file instanceof TFile && file.path.toLowerCase().includes(lower_input_str)) {
|
||||
files.push(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
|
||||
renderSuggestion(file: TFile, el: HTMLElement): void {
|
||||
const { templateFolder, templaterPlugin } = getTemplatePlugins(this.app);
|
||||
|
||||
|
||||
if ((!templateFolder || templateFolder.trim() === '') && !templaterPlugin) {
|
||||
el.setText(`${file.parent?.path}/${file.name.replace('.md', '')}`);
|
||||
} else {
|
||||
el.setText(file.name.replace('.md', ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
selectSuggestion(file: TFile): void {
|
||||
this.inputEl.value = file.name.replace('.md', '');
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ export async function applyTemplate(
|
|||
templaterPlugin,
|
||||
} = getTemplatePlugins(plugin.app);
|
||||
const templateContent = await plugin.app.vault.read(templateFile);
|
||||
if (templateContent.includes('==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠==')) {
|
||||
return;
|
||||
if (templateContent.includes('==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠==')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prioritize Templater if both plugins are enabled
|
||||
|
|
|
|||
Loading…
Reference in a new issue