diff --git a/main.ts b/main.ts index c309705..6c4f726 100644 --- a/main.ts +++ b/main.ts @@ -1,23 +1,10 @@ -import { App, Editor, MarkdownView, Notice, Plugin, PluginSettingTab, Setting, WorkspaceLeaf } from 'obsidian'; +import { App, Editor, MarkdownView, Notice, Plugin, WorkspaceLeaf } from 'obsidian'; import { SpreadsheetView, VIEW_TYPE_SPREADSHEET } from "./view" -// Remember to rename these classes and interfaces! - -interface SpreadsheetPluginSettings { - mySetting: string; -} - -const DEFAULT_SETTINGS: SpreadsheetPluginSettings = { - mySetting: 'default' -} - - async function create_new_file(app, folder_path, file_no){ - - if(folder_path){ try { await app.vault.createFolder(folder_path); @@ -59,44 +46,26 @@ async function create_new_file(app, folder_path, file_no){ export default class SpreadsheetPlugin extends Plugin { - settings: SpreadsheetPluginSettings; async onload() { - await this.loadSettings(); - // This creates an icon in the left ribbon. const ribbonIconEl = this.addRibbonIcon('table', 'New Spreadsheet', (evt: MouseEvent) => { - // Called when the user clicks the icon. - create_new_file(this.app); - + create_new_file(this.app, undefined, undefined); }); - // Perform additional things with the ribbon - ribbonIconEl.addClass('my-plugin-ribbon-class'); - let that = this; + let app = this.app; this.registerEvent( this.app.workspace.on("file-menu", (menu, file) => { menu.addItem((item) => { item.setTitle("New spreadsheet").setIcon("document").onClick(function(){ - create_new_file(that.app, file.path, 0 ) + create_new_file(app, file.path, 0 ) }); }); }) ); - - - // This adds a settings tab so the user can configure various aspects of the plugin - this.addSettingTab(new SampleSettingTab(this.app, this)); - - - - // When registering intervals, this function will automatically clear the interval when the plugin is disabled. - this.registerInterval(window.setInterval(() => console.log('setInterval'), 5 * 60 * 1000)); - - this.registerView( VIEW_TYPE_SPREADSHEET, (leaf: WorkspaceLeaf) => new SpreadsheetView(leaf) @@ -112,38 +81,6 @@ export default class SpreadsheetPlugin extends Plugin { } - async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); - } - - async saveSettings() { - await this.saveData(this.settings); - } } -class SampleSettingTab extends PluginSettingTab { - plugin: SpreadsheetPlugin; - - constructor(app: App, plugin: SpreadsheetPlugin) { - super(app, plugin); - this.plugin = plugin; - } - - display(): void { - const {containerEl} = this; - - containerEl.empty(); - - new Setting(containerEl) - .setName('Setting') - .setDesc('settings') - .addText(text => text - .setPlaceholder('...') - .setValue(this.plugin.settings.mySetting) - .onChange(async (value) => { - this.plugin.settings.mySetting = value; - await this.plugin.saveSettings(); - })); - } -} diff --git a/manifest.json b/manifest.json index 00d637d..30a4a7c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { "id": "spreadsheets", "name": "Spreadsheets", - "version": "1.0.0", + "version": "1.0.1", "minAppVersion": "0.15.0", - "description": "Plugin to create spreadsheets in obsidian.", + "description": "Plugin to create spreadsheets in Obsidian.", "author": "Divam Gupta", "authorUrl": "https://divam.io", "isDesktopOnly": true diff --git a/package.json b/package.json index 547b4d7..fab356c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "spreadsheets-plugin", - "version": "1.0.0", - "description": "Plugin to create spreadsheets in obsidian", + "version": "1.0.1", + "description": "Plugin to create spreadsheets in Obsidian.", "main": "main.js", "scripts": { "dev": "node esbuild.config.mjs",