E2E workflow for creating docs

This commit is contained in:
Andras Schmelczer 2024-12-08 22:05:05 +00:00
parent f9dafdfc88
commit 0db1380d27
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
3 changed files with 108 additions and 49 deletions

View file

@ -10,8 +10,8 @@ import {
WorkspaceLeaf,
} from "obsidian";
import * as plugin from "../../backend/sync_wasm/pkg/sync_wasm.js";
import * as wasmBin from "../../backend/sync_wasm/pkg/sync_wasm_bg.wasm";
import * as plugin from "../../backend/sync_lib/pkg/sync_lib.js";
import * as wasmBin from "../../backend/sync_lib/pkg/sync_lib_bg.wasm";
import { getSystemErrorName } from "util";
import { SyncSettingsTab } from "./settings/settings-tab.js";
import { SyncView } from "./views/sync-view.js";
@ -22,6 +22,7 @@ import {
} from "./settings/settings.js";
import { Logger } from "./logger.js";
import { SyncEventHandler } from "./events/sync-event-handler.js";
import { Syncer } from "./syncer/syncer.js";
export default class SyncPlugin extends Plugin {
async onload() {
@ -29,7 +30,26 @@ export default class SyncPlugin extends Plugin {
await plugin.default(Promise.resolve((wasmBin as any).default));
const eventHandler = new SyncEventHandler();
// 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");
},
});
const settingsContainer = new SettingsContainer(
this,
await this.loadData()
);
this.addSettingTab(
new SyncSettingsTab(this.app, this, settingsContainer)
);
const syncer = new Syncer(settingsContainer);
const eventHandler = new SyncEventHandler(syncer);
[
this.app.vault.on(
@ -50,49 +70,22 @@ export default class SyncPlugin extends Plugin {
),
].forEach((event) => this.registerEvent(event));
// This creates an icon in the left ribbon.
const ribbonIconEl = this.addRibbonIcon(
"dice",
"Sample Plugin",
(evt: MouseEvent) => {
// Called when the user clicks the icon.
new Notice("This is a notice!");
}
);
// 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 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");
},
});
const settingsContainer = new SettingsContainer(
this,
await this.loadData()
);
this.addSettingTab(
new SyncSettingsTab(this.app, this, settingsContainer)
);
// 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.registerView(SyncView.TYPE, (leaf) => new SyncView(leaf));
this.addRibbonIcon("dice", "Activate view", () => {
this.activateView();
});
const ribbonIconEl = this.addRibbonIcon(
"dice",
"Sample Plugin",
(evt: MouseEvent) => {
this.activateView();
new Notice("This is a notice!");
}
);
ribbonIconEl.addClass("my-plugin-ribbon-class");
}
onunload() {}