diff --git a/README.md b/README.md index 9b7a521..1dc3402 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ The connection is through a YAML frontmatter key. 1. A Trello account 2. The [MetaEdit](https://github.com/chhoumann/MetaEdit) Obsidian plugin (install from inside Obsidian) + - Obsidian Trello makes use of MetaEdit's [YAML Frontmatter API](https://github.com/chhoumann/MetaEdit#api). 3. A Trello API token (see below). Before you can connect a Trello card, you need to create an API token and set it in the plugin settings. You can create a token [here][tokenurl]; make sure to copy it before closing the tab. diff --git a/src/plugin.ts b/src/plugin.ts index 965b027..f60b274 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -40,7 +40,8 @@ export class TrelloPlugin extends Plugin { async onload(): Promise { // Set up data and default data. const savedData: PluginData | undefined = await this.loadData(); - this.state = new PluginState(this, savedData || DEFAULT_DATA); + const data: PluginData = Object.assign({}, DEFAULT_DATA, savedData); + this.state = new PluginState(this, data); // Create new API instance this.api = new TrelloAPI(this); @@ -65,8 +66,8 @@ export class TrelloPlugin extends Plugin { // Register trello view type this.registerView(TRELLO_VIEW_TYPE, (leaf: WorkspaceLeaf) => (this.view = new TrelloView(this, leaf))); - // Register file handler to check if the opened card is trello connected - this.app.workspace.on('file-open', async (file) => this.handleFile(file)); + // Register file handler to check if the opened card is trello connected\ + this.registerEvent(this.app.workspace.on('file-open', async (file) => this.handleFile(file))); // Also check the current file on load this.handleFile(this.app.workspace.getActiveFile()); diff --git a/src/settings/board-select-modal.ts b/src/settings/board-select-modal.ts index 0e12343..9bd82a4 100644 --- a/src/settings/board-select-modal.ts +++ b/src/settings/board-select-modal.ts @@ -86,14 +86,14 @@ export class BoardSelectModal extends Modal { container.createDiv({ text: board.name, cls: 'trello-board-select--toggle-label' }); const toggle = container.createDiv({ cls: 'trello-board-select--toggle checkbox-container' }); if (this.newState[board.id]) { - toggle.classList.add('is-enabled'); + toggle.addClass('is-enabled'); } container.addEventListener('click', () => { if (this.newState[board.id]) { - toggle.classList.remove('is-enabled'); + toggle.removeClass('is-enabled'); delete this.newState[board.id]; } else { - toggle.classList.add('is-enabled'); + toggle.addClass('is-enabled'); this.newState[board.id] = board; } });