Added core

This commit is contained in:
Vlad Kostyanetsky 2024-04-02 09:30:26 +04:00
parent 688b3d182f
commit 7d86caff92

View file

@ -16,13 +16,46 @@ export default class Timesheet extends Plugin {
settings: TimesheetSettings;
async onload() {
await this.loadSettings();
this.addSettingTab(new TimesheetSettingTab(this.app, this));
this.addSettingsTab()
this.addInsertTimesheetCommand()
this.addTimesheetCodeblock()
}
onunload() {
async addSettingsTab() {
this.addSettingTab(new TimesheetSettingTab(this.app, this));
}
async addInsertTimesheetCommand() {
this.addCommand({
id: 'insert-timesheet',
name: 'Insert timesheet',
editorCallback: (editor: Editor, view: MarkdownView) => {
editor.replaceSelection(`\`\`\`timesheet\n\n\`\`\``);
}
});
}
async addTimesheetCodeblock() {
this.registerMarkdownCodeBlockProcessor("timesheet", async (src, el, ctx) => {
try
{
const root = el.createEl("div");
const body = root.createEl("div");
await TimesheetCodeBlock.render(this, src, body, ctx);
}
catch (error)
{
el.createEl("h3", {text: `Failed to show fast: ${error.message}`});
}
});
}
onunload() {
}
async loadSettings() {