From 07ad2b927b242ac9c16c538d890dc0ac83dcd5a2 Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:08:54 +0100 Subject: [PATCH] Remove duplicated commands --- manifest.json | 4 +- src/Commands.ts | 67 +-------------------------------- src/functions/styleFunctions.ts | 2 +- src/main.ts | 5 ++- src/obsidian-folder-overview | 2 +- 5 files changed, 9 insertions(+), 71 deletions(-) diff --git a/manifest.json b/manifest.json index 1632a52..c50f1bd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "folder-notes", "name": "Folder notes", - "version": "1.7.34", + "version": "1.7.35", "minAppVersion": "0.15.0", "description": "Create notes within folders that can be accessed without collapsing the folder, similar to the functionality offered in Notion.", "author": "Lost Paul", @@ -9,4 +9,4 @@ "fundingUrl": "https://ko-fi.com/paul305844", "helpUrl": "https://lostpaul.github.io/obsidian-folder-notes/", "isDesktopOnly": false -} +} \ No newline at end of file diff --git a/src/Commands.ts b/src/Commands.ts index 35e293d..531a137 100644 --- a/src/Commands.ts +++ b/src/Commands.ts @@ -36,24 +36,6 @@ export class Commands { } }); - console.log('registering commands') - this.plugin.addCommand({ - id: 'open-folder-overview-view', - name: 'Change folder overview settings', - callback: () => { - this.plugin.activateOverviewView(); - } - }); - - - this.plugin.addCommand({ - id: 'open-folder-overview-view', - name: 'Change folder overview settings', - callback: () => { - this.plugin.activateOverviewView(); - } - }); - this.plugin.addCommand({ id: 'create-folder-note', name: 'Create folder note with a new folder for the active note in the current folder', @@ -133,33 +115,7 @@ export class Commands { openFolderNote(this.plugin, folderNote); } }); - this.plugin.addCommand({ - id: 'insert-folder-overview-fn', - name: 'Insert folder overview', - editorCheckCallback: (checking: boolean, editor: Editor) => { - const line = editor.getCursor().line; - const lineText = editor.getLine(line); - if (lineText.trim() === '' || lineText.trim() === '>') { - if (!checking) { - let json = Object.assign({}, this.plugin.settings.defaultOverview); - json.id = crypto.randomUUID(); - const yaml = stringifyYaml(json) - if (lineText.trim() === '') { - editor.replaceSelection(`\`\`\`folder-overview\n${yaml}\`\`\`\n`); - } else if (lineText.trim() === '>') { - // add > to the beginning of each line - const lines = yaml.split('\n'); - const newLines = lines.map((line) => { - return `> ${line}`; - }); - editor.replaceSelection(`\`\`\`folder-overview\n${newLines.join('\n')}\`\`\`\n`); - } - } - return true; - } - return false; - }, - }) + this.plugin.addCommand({ id: 'create-folder-note-from-selected-text', name: 'Create folder note from selected text', @@ -445,27 +401,6 @@ export class Commands { const text = editor.getSelection().trim(); const line = editor.getCursor().line; const lineText = editor.getLine(line); - if (lineText.trim() === '' || lineText.trim() === '>') { - menu.addItem((item) => { - item.setTitle('Create folder overview') - .setIcon('edit') - .onClick(() => { - let json = Object.assign({}, this.plugin.settings.defaultOverview); - json.id = crypto.randomUUID(); - const yaml = stringifyYaml(json) - if (lineText.trim() === '') { - editor.replaceSelection(`\`\`\`folder-overview\n${yaml}\`\`\`\n`); - } else if (lineText.trim() === '>') { - // add > to the beginning of each line - const lines = yaml.split('\n'); - const newLines = lines.map((line) => { - return `> ${line}`; - }); - editor.replaceSelection(`\`\`\`folder-overview\n${newLines.join('\n')}\`\`\`\n`); - } - }); - }); - } if (!text || text.trim() === '') return; menu.addItem((item) => { item.setTitle('Create folder note') diff --git a/src/functions/styleFunctions.ts b/src/functions/styleFunctions.ts index 4a3921f..4ca8fca 100644 --- a/src/functions/styleFunctions.ts +++ b/src/functions/styleFunctions.ts @@ -1,5 +1,5 @@ import { TFile, TFolder } from 'obsidian'; -import FolderNotesPlugin from 'src/main'; +import FolderNotesPlugin from '../main'; import { getExcludedFolder } from 'src/ExcludeFolders/functions/folderFunctions'; import { getFolder, getFolderNote } from 'src/functions/folderNoteFunctions'; import { getFileExplorer } from './utils'; diff --git a/src/main.ts b/src/main.ts index b314990..effc7b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,7 +19,9 @@ import { getExcludedFolder } from './ExcludeFolders/functions/folderFunctions'; 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'; +import { getFolderPathFromString } from './functions/utils'; +import { registerOverviewCommands } from './obsidian-folder-overview/src/Commands'; + export default class FolderNotesPlugin extends Plugin { observer: MutationObserver; settings: FolderNotesSettings; @@ -61,6 +63,7 @@ export default class FolderNotesPlugin extends Plugin { } new Commands(this.app, this).registerCommands(); + registerOverviewCommands(this); this.app.workspace.onLayoutReady(this.onLayoutReady.bind(this)); diff --git a/src/obsidian-folder-overview b/src/obsidian-folder-overview index 61d1bba..fe16567 160000 --- a/src/obsidian-folder-overview +++ b/src/obsidian-folder-overview @@ -1 +1 @@ -Subproject commit 61d1bba885c403055f6a292f0d5447023946182c +Subproject commit fe16567ee66f046e7407050e595f23b470ef5add