mirror of
https://github.com/vkostyanetsky/ObsidianTimesheet.git
synced 2026-07-22 10:10:25 +00:00
Added core
This commit is contained in:
parent
688b3d182f
commit
7d86caff92
1 changed files with 36 additions and 3 deletions
39
src/main.ts
39
src/main.ts
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue