From efcbe9df4302964cb31d110f151789b7cc870957 Mon Sep 17 00:00:00 2001 From: Aleix Soler Date: Fri, 23 May 2025 18:54:24 +0200 Subject: [PATCH] chore: restore pane view --- main.ts | 51 +++++++++---------- views/status-pane-view/index.ts | 2 + .../status-pane-view-controller.ts | 32 +++--------- 3 files changed, 32 insertions(+), 53 deletions(-) create mode 100644 views/status-pane-view/index.ts diff --git a/main.ts b/main.ts index c7e34a4..4106fce 100644 --- a/main.ts +++ b/main.ts @@ -11,6 +11,9 @@ import { MetadataIntegration } from './integrations/metadata-cache'; import { WorkspaceIntegration } from './integrations/workspace'; import { FileContextMenuIntegration } from 'integrations/context-menu/file-context-menu-integration'; import { NoteStatusSettingTab } from 'integrations/settings/settings-tab'; +// +// Importar vistas +import { StatusPaneViewController } from './views/status-pane-view'; // Importar componentes UI import { StatusBar } from 'components/status-bar'; @@ -40,15 +43,9 @@ export default class NoteStatus extends Plugin { try { await this.loadSettings(); this.initializeServices(); - - // 2. Registrar vistas y componentes UI - // this.registerViews(); - + this.registerViews(); this.initializeUI(); - - // 3. Inicializar integraciones this.initializeIntegrations(); - // 4. Registrar comandos // this.registerCommands(); @@ -72,15 +69,15 @@ export default class NoteStatus extends Plugin { } private registerViews() { - // Registrar vista del panel de estado - // this.registerView('status-pane', (leaf) => { - // return new StatusPaneView(leaf, this); - // }); + // Register status pane view + this.registerView('status-pane', (leaf) => { + return new StatusPaneViewController(leaf, this); + }); - // Añadir ícono en la barra lateral - // this.addRibbonIcon('status-pane', 'Open status pane', () => { - // this.openStatusPane(); - // }); + // Add ribbon icon + this.addRibbonIcon('status-pane', 'Open status pane', () => { + this.openStatusPane(); + }); // Añadir pestaña de configuración // this.addSettingTab(new NoteStatusSettingTab(this.app, this, this.statusService)); @@ -229,18 +226,18 @@ export default class NoteStatus extends Plugin { } private async openStatusPane() { - // // Comprobar si ya está abierto - // const existing = this.app.workspace.getLeavesOfType('status-pane')[0]; - // if (existing) { - // this.app.workspace.setActiveLeaf(existing); - // return; - // } + // Check if already open + const existing = this.app.workspace.getLeavesOfType('status-pane')[0]; + if (existing) { + this.app.workspace.setActiveLeaf(existing); + return; + } - // // Crear una nueva hoja - // const leaf = this.app.workspace.getLeftLeaf(false); - // if (leaf) { - // await leaf.setViewState({ type: 'status-pane', active: true }); - // } + // Create new leaf + const leaf = this.app.workspace.getLeftLeaf(false); + if (leaf) { + await leaf.setViewState({ type: 'status-pane', active: true }); + } } async saveSettings() { @@ -283,4 +280,4 @@ export default class NoteStatus extends Plugin { // // Limpiar componentes UI // this.statusBar.unload(); } -} \ No newline at end of file +} diff --git a/views/status-pane-view/index.ts b/views/status-pane-view/index.ts new file mode 100644 index 0000000..93b29c9 --- /dev/null +++ b/views/status-pane-view/index.ts @@ -0,0 +1,2 @@ +export { StatusPaneView } from './status-pane-view'; +export { StatusPaneViewController } from './status-pane-view-controller'; diff --git a/views/status-pane-view/status-pane-view-controller.ts b/views/status-pane-view/status-pane-view-controller.ts index 99cfb20..7f59312 100644 --- a/views/status-pane-view/status-pane-view-controller.ts +++ b/views/status-pane-view/status-pane-view-controller.ts @@ -1,4 +1,4 @@ -import { TFile, WorkspaceLeaf, View, Menu, Notice } from 'obsidian'; +import { TFile, WorkspaceLeaf, View, Notice } from 'obsidian'; import { NoteStatusSettings } from '../../models/types'; import { StatusService } from '../../services/status-service'; import NoteStatus from 'main'; @@ -9,7 +9,7 @@ export class StatusPaneViewController extends View { private settings: NoteStatusSettings; private statusService: StatusService; private plugin: NoteStatus; - private searchQuery: string = ''; + private searchQuery = ''; private paginationState = { itemsPerPage: 100, currentPage: {} as Record @@ -47,6 +47,10 @@ export class StatusPaneViewController extends View { this.renderer.createHeader(containerEl, this.settings.compactView, { onSearch: (query) => { + this.paginationState = { + itemsPerPage: 100, + currentPage: {} as Record + } this.searchQuery = query; this.renderGroups(query); }, @@ -103,7 +107,6 @@ export class StatusPaneViewController extends View { window.dispatchEvent(new CustomEvent('note-status:settings-changed')); }, onContextMenu: (e, file) => { - this.showFileContextMenu(e, file); }, onPageChange: (status, page) => { this.paginationState.currentPage[status] = page; @@ -140,29 +143,6 @@ export class StatusPaneViewController extends View { return filteredGroups; } - private showFileContextMenu(e: MouseEvent, file: TFile): void { - const menu = new Menu(); - - menu.addItem((item) => - item.setTitle('Change status') - .setIcon('tag') - .onClick(() => { - const position = { x: e.clientX, y: e.clientY }; - this.plugin.statusContextMenu.showForSingleFile(file, position); - }) - ); - - menu.addItem((item) => - item.setTitle('Open in new tab') - .setIcon('lucide-external-link') - .onClick(() => { - this.app.workspace.openLinkText(file.path, file.path, 'tab'); - }) - ); - - menu.showAtMouseEvent(e); - } - updateSettings(settings: NoteStatusSettings): void { this.settings = settings; this.containerEl.toggleClass('note-status-compact-view', settings.compactView);