summaryrefslogtreecommitdiffhomepage
path: root/main.ts
diff options
context:
space:
mode:
authorlishid <[email protected]>2020-10-25 16:55:59 -0400
committerlishid <[email protected]>2020-10-25 16:58:31 -0400
commited3770792a7a9ce698999de42ebb6150f5ee5e9e (patch)
tree0a7e047f2806eaccc88247d8ab360d6b877fa063 /main.ts
downloadai-pulse-obsidian-plugin-ed3770792a7a9ce698999de42ebb6150f5ee5e9e.tar.gz
ai-pulse-obsidian-plugin-ed3770792a7a9ce698999de42ebb6150f5ee5e9e.zip
Initial commit!
Diffstat (limited to 'main.ts')
-rw-r--r--main.ts77
1 files changed, 77 insertions, 0 deletions
diff --git a/main.ts b/main.ts
new file mode 100644
index 0000000..575b955
--- /dev/null
+++ b/main.ts
@@ -0,0 +1,77 @@
+import { App, CustomPlugin, Modal, Notice, PluginSettingTab, Setting } from 'obsidian';
+
+export default class MyPlugin extends CustomPlugin {
+ onInit() {
+
+ }
+
+ onload() {
+ console.log('loading plugin');
+
+ this.addRibbonIcon('dice', 'Sample Plugin', () => {
+ new Notice('This is a notice!');
+ });
+
+ this.addStatusBarItem().setText('Status Bar Text');
+
+ this.addCommand({
+ id: 'open-sample-modal',
+ name: 'Open Sample Modal',
+ // callback: () => {
+ // console.log('Simple Callback');
+ // },
+ checkCallback: (checking: boolean) => {
+ let leaf = this.app.workspace.activeLeaf;
+ if (leaf) {
+ if (!checking) {
+ new SampleModal(this.app).open();
+ }
+ return true;
+ }
+ return false;
+ }
+ });
+
+ this.addSettingTab(new SampleSettingTab(this.app, this));
+ }
+
+ onunload() {
+ console.log('unloading plugin');
+ }
+}
+
+class SampleModal extends Modal {
+ constructor(app: App) {
+ super(app);
+ }
+
+ onOpen() {
+ let {contentEl} = this;
+ contentEl.setText('Woah!');
+ }
+
+ onClose() {
+ let {contentEl} = this;
+ contentEl.empty();
+ }
+}
+
+class SampleSettingTab extends PluginSettingTab {
+ display(): void {
+ let {containerEl} = this;
+
+ containerEl.empty();
+
+ containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});
+
+ new Setting(containerEl)
+ .setName('Setting #1')
+ .setDesc('It\'s a secret')
+ .addText(text => text.setPlaceholder('Enter your secret')
+ .setValue('')
+ .onChange((value) => {
+ console.log('Secret: ' + value);
+ }));
+
+ }
+}