Skip to content

Commit

Permalink
feat: Add - Reset settings button
Browse files Browse the repository at this point in the history
  • Loading branch information
land0r committed Nov 14, 2024
1 parent 9131c5c commit 921c35d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ export default class FlowchartPlugin extends Plugin {
cls: 'obsidian-flowchart-container',
});
diagram.drawSVG(container, this.settings.config);
container
.querySelector('svg')
?.setAttribute('aria-label', 'Flowchart diagram');

// Apply a fix for deprecated xlink attributes
this.fixXlinkAttributes(container);
} catch (error) {
console.error('Error rendering flowchart: ', error);
el.createEl('div', {
text: 'Error rendering flowchart. Check your markup.',
cls: 'error-message',
text: 'Failed to render flowchart. Check your input.',
});
}
});
Expand Down Expand Up @@ -220,5 +224,18 @@ class FlowchartSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName('Reset Settings')
.setDesc('Reset all settings to their default values.')
.addButton((button) =>
button.setButtonText('Reset').onClick(async () => {
console.log('Before reset:', this.plugin.settings);
this.plugin.settings = JSON.parse(JSON.stringify(DEFAULT_SETTINGS));
console.log('After reset:', this.plugin.settings);
await this.plugin.saveSettings();
this.display();
})
);
}
}

0 comments on commit 921c35d

Please sign in to comment.