feat: clean up template code and establish plugin foundation (task 1)
- Fix TypeScript type inconsistencies in main.ts - Remove sample template components (SampleModal, sample commands) - Replace sample settings tab with TypstPDFExportSettingTab - Update package.json metadata to reflect actual plugin identity - Add basic plugin structure with export command and ribbon icon - Clean up template comments and unused imports This establishes a clean foundation for implementing Typst PDF export functionality by removing all sample plugin template code and setting up proper plugin structure with placeholder functionality. Addresses all subtasks in task 1 (1.1-1.5) from project roadmap. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
3 files changed
+584
-101
No files matched your search
@@ -1,81 +1,43 @@
|
||||
import { App, Editor, MarkdownView, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
|
||||
import { App, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
|
||||
|
||||
// Remember to rename these classes and interfaces!
|
||||
/**
|
||||
* Obsidian Typst PDF Export Plugin
|
||||
*
|
||||
* This plugin exports Obsidian notes to PDF using the Typst typesetting system.
|
||||
* It provides features for converting Obsidian markdown to Typst format and
|
||||
* generating high-quality PDFs with customizable styling.
|
||||
*/
|
||||
|
||||
interface obsidianTypstPDFExportSettings {
|
||||
mySetting: string;
|
||||
// Placeholder for future settings
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
|
||||
mySetting: 'default'
|
||||
// Default values will be added as settings are implemented
|
||||
}
|
||||
|
||||
export default class obsidianTypstPDFExport extends Plugin {
|
||||
settings: MyPluginSettings;
|
||||
settings: obsidianTypstPDFExportSettings;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
// This creates an icon in the left ribbon.
|
||||
const ribbonIconEl = this.addRibbonIcon('dice', 'Typst PDF Export', (evt: MouseEvent) => {
|
||||
// Called when the user clicks the icon.
|
||||
new Notice('This is a notice!');
|
||||
// Add ribbon icon for quick export access
|
||||
this.addRibbonIcon('file-text', 'Export to PDF with Typst', () => {
|
||||
new Notice('Typst PDF Export: Coming soon!');
|
||||
});
|
||||
// Perform additional things with the ribbon
|
||||
ribbonIconEl.addClass('my-plugin-ribbon-class');
|
||||
|
||||
// This adds a status bar item to the bottom of the app. Does not work on mobile apps.
|
||||
const statusBarItemEl = this.addStatusBarItem();
|
||||
statusBarItemEl.setText('Status Bar Text');
|
||||
|
||||
// This adds a simple command that can be triggered anywhere
|
||||
// Add basic export command
|
||||
this.addCommand({
|
||||
id: 'open-sample-modal-simple',
|
||||
name: 'Open sample modal (simple)',
|
||||
id: 'export-current-note',
|
||||
name: 'Export current note to Typst PDF',
|
||||
callback: () => {
|
||||
new SampleModal(this.app).open();
|
||||
}
|
||||
});
|
||||
// This adds an editor command that can perform some operation on the current editor instance
|
||||
this.addCommand({
|
||||
id: 'sample-editor-command',
|
||||
name: 'Sample editor command',
|
||||
editorCallback: (editor: Editor, view: MarkdownView) => {
|
||||
console.log(editor.getSelection());
|
||||
editor.replaceSelection('Sample Editor Command');
|
||||
}
|
||||
});
|
||||
// This adds a complex command that can check whether the current state of the app allows execution of the command
|
||||
this.addCommand({
|
||||
id: 'open-sample-modal-complex',
|
||||
name: 'Open sample modal (complex)',
|
||||
checkCallback: (checking: boolean) => {
|
||||
// Conditions to check
|
||||
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (markdownView) {
|
||||
// If checking is true, we're simply "checking" if the command can be run.
|
||||
// If checking is false, then we want to actually perform the operation.
|
||||
if (!checking) {
|
||||
new SampleModal(this.app).open();
|
||||
}
|
||||
|
||||
// This command will only show up in Command Palette when the check function returns true
|
||||
return true;
|
||||
}
|
||||
new Notice('Typst PDF Export functionality will be implemented in future versions.');
|
||||
}
|
||||
});
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new SampleSettingTab(this.app, this));
|
||||
|
||||
// If the plugin hooks up any global DOM events (on parts of the app that doesn't belong to this plugin)
|
||||
// Using this function will automatically remove the event listener when this plugin is disabled.
|
||||
this.registerDomEvent(document, 'click', (evt: MouseEvent) => {
|
||||
console.log('click', evt);
|
||||
});
|
||||
|
||||
// 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.addSettingTab(new TypstPDFExportSettingTab(this.app, this));
|
||||
}
|
||||
|
||||
onunload() {
|
||||
@@ -91,26 +53,11 @@ export default class obsidianTypstPDFExport extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
class SampleModal extends Modal {
|
||||
constructor(app: App) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const {contentEl} = this;
|
||||
contentEl.setText('Woah!');
|
||||
}
|
||||
class TypstPDFExportSettingTab extends PluginSettingTab {
|
||||
plugin: obsidianTypstPDFExport;
|
||||
|
||||
onClose() {
|
||||
const {contentEl} = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
||||
class SampleSettingTab extends PluginSettingTab {
|
||||
plugin: MyPlugin;
|
||||
|
||||
constructor(app: App, plugin: MyPlugin) {
|
||||
constructor(app: App, plugin: obsidianTypstPDFExport) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -120,15 +67,10 @@ class SampleSettingTab extends PluginSettingTab {
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Setting #1')
|
||||
.setDesc('It\'s a secret')
|
||||
.addText(text => text
|
||||
.setPlaceholder('Enter your secret')
|
||||
.setValue(this.plugin.settings.mySetting)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.mySetting = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
containerEl.createEl('h2', {text: 'Typst PDF Export Settings'});
|
||||
|
||||
containerEl.createEl('p', {
|
||||
text: 'Settings for the Typst PDF Export plugin will be added in future versions.'
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user