import * as React from 'react'; import { App, Plugin, WorkspaceLeaf, addIcon, PluginSettingTab, Setting } from 'obsidian'; import { createRoot, Root } from 'react-dom/client'; import { ClipperCatalogView, VIEW_TYPE_CLIPPER_CATALOG } from './ClipperCatalogView'; interface ObsidianClipperCatalogSettings { sourcePropertyName: string; ignoredDirectories: string[]; isAdvancedSettingsExpanded: boolean; } // Add this before the ObsidianClipperCatalog class definition export const ICON_NAME = 'clipper-catalog'; const DEFAULT_SETTINGS: ObsidianClipperCatalogSettings = { sourcePropertyName: 'source', ignoredDirectories: [], isAdvancedSettingsExpanded: false } export default class ObsidianClipperCatalog extends Plugin { settings: ObsidianClipperCatalogSettings; async onload() { await this.loadSettings(); // Register the custom icon addIcon(ICON_NAME, ``); this.registerView( VIEW_TYPE_CLIPPER_CATALOG, (leaf: WorkspaceLeaf) => new ClipperCatalogView(leaf, this) ); // Add ribbon icon this.addRibbonIcon(ICON_NAME, 'Clipper Catalog', (evt: MouseEvent) => { // Get active leaf or create new one in center const leaf = this.app.workspace.getLeaf('tab'); if (leaf) { leaf.setViewState({ type: VIEW_TYPE_CLIPPER_CATALOG, active: true }); this.app.workspace.revealLeaf(leaf); } }); this.addCommand({ id: 'show-all-clippings', name: 'Show All Clippings', callback: () => { // Get active leaf or create new one in center const leaf = this.app.workspace.getLeaf('tab'); if (leaf) { leaf.setViewState({ type: VIEW_TYPE_CLIPPER_CATALOG, active: true, }); this.app.workspace.revealLeaf(leaf); } } }); this.addSettingTab(new ClipperCatalogSettingTab(this.app, this)); } async loadSettings() { this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); } async saveSettings() { await this.saveData(this.settings); } } class ClipperCatalogSettingTab extends PluginSettingTab { plugin: ObsidianClipperCatalog; settingsHeaderEl: HTMLDivElement; settingsHeaderContentEl: HTMLDivElement; advancedSettingsEl: HTMLDetailsElement; advancedContentEl: HTMLDivElement; constructor(app: App, plugin: ObsidianClipperCatalog) { super(app, plugin); this.plugin = plugin; } display(): void { const {containerEl} = this; containerEl.empty(); containerEl.addClass('clipper-catalog-plugin'); containerEl.addClass('clipper-catalog-settings'); // Create Header section using