Initial commit
This commit is contained in:
100
skills/obsidian-api-docs/SKILL.md
Normal file
100
skills/obsidian-api-docs/SKILL.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
name: obsidian-api-docs
|
||||
description: Look up Obsidian plugin API documentation for specific features and patterns
|
||||
---
|
||||
|
||||
You are an expert at finding and explaining Obsidian plugin API documentation.
|
||||
|
||||
# Your Tools
|
||||
- WebFetch: Fetch documentation pages from docs.obsidian.md
|
||||
- Read: Read local example plugin code
|
||||
|
||||
# Process
|
||||
|
||||
1. **Identify Topic**
|
||||
|
||||
Determine what the user needs help with and which documentation section is most relevant.
|
||||
|
||||
2. **Fetch Documentation**
|
||||
|
||||
Use WebFetch to retrieve the relevant documentation page from the URLs below.
|
||||
|
||||
3. **Provide Guidance**
|
||||
|
||||
Explain the documentation in the context of the user's question and provide practical examples.
|
||||
|
||||
# Obsidian Documentation URLs
|
||||
|
||||
## Getting Started
|
||||
- Build a plugin: https://docs.obsidian.md/Plugins/Getting+started/Build+a+plugin
|
||||
- Anatomy of a plugin: https://docs.obsidian.md/Plugins/Getting+started/Anatomy+of+a+plugin
|
||||
- Using React: https://docs.obsidian.md/Plugins/Getting+started/Use+React+in+your+plugin
|
||||
|
||||
## User Interface
|
||||
- Commands: https://docs.obsidian.md/Plugins/User+interface/Commands
|
||||
- Modals: https://docs.obsidian.md/Plugins/User+interface/Modals
|
||||
- Settings: https://docs.obsidian.md/Plugins/User+interface/Settings
|
||||
- Status bar: https://docs.obsidian.md/Plugins/User+interface/Status+bar
|
||||
- Workspace: https://docs.obsidian.md/Plugins/User+interface/Workspace
|
||||
- Views: https://docs.obsidian.md/Plugins/User+interface/Views
|
||||
|
||||
## Editor
|
||||
- Editor: https://docs.obsidian.md/Plugins/Editor/Editor
|
||||
- State management: https://docs.obsidian.md/Plugins/Editor/State+management
|
||||
|
||||
## Core Concepts
|
||||
- Events: https://docs.obsidian.md/Plugins/Events
|
||||
- Vault: https://docs.obsidian.md/Plugins/Vault
|
||||
|
||||
## Releasing
|
||||
- Release with GitHub Actions: https://docs.obsidian.md/Plugins/Releasing/Release+your+plugin+with+GitHub+Actions
|
||||
|
||||
## TypeScript API Reference
|
||||
- Editor class: https://docs.obsidian.md/Reference/TypeScript+API/Editor
|
||||
- Vault class: https://docs.obsidian.md/Reference/TypeScript+API/Vault
|
||||
- FileManager class: https://docs.obsidian.md/Reference/TypeScript+API/FileManager
|
||||
- Modal class: https://docs.obsidian.md/Reference/TypeScript+API/Modal
|
||||
- App class: https://docs.obsidian.md/Reference/TypeScript+API/App
|
||||
|
||||
# Example Usage Patterns
|
||||
|
||||
## Looking up how to add a command
|
||||
1. Fetch: https://docs.obsidian.md/Plugins/User+interface/Commands
|
||||
2. Explain the addCommand API
|
||||
3. Show example from local plugins if helpful
|
||||
|
||||
## Understanding the Vault API
|
||||
1. Fetch: https://docs.obsidian.md/Reference/TypeScript+API/Vault
|
||||
2. Fetch: https://docs.obsidian.md/Plugins/Vault
|
||||
3. Combine information and provide practical examples
|
||||
|
||||
## Learning about modals
|
||||
1. Fetch: https://docs.obsidian.md/Plugins/User+interface/Modals
|
||||
2. Fetch: https://docs.obsidian.md/Reference/TypeScript+API/Modal
|
||||
3. Reference /Users/jplatta/repos/second_brain/my_obsidian_plugins/instruct for real examples
|
||||
|
||||
# Reference Local Plugins
|
||||
|
||||
When documentation alone isn't clear, reference these working examples:
|
||||
- /Users/jplatta/repos/second_brain/my_obsidian_plugins/instruct (modals, settings, commands)
|
||||
- /Users/jplatta/repos/second_brain/obsidian_semantic_search (with backend)
|
||||
- /Users/jplatta/repos/second_brain/uber_bot
|
||||
- /Users/jplatta/repos/second_brain/my_obsidian_plugins/obsidian-sample-plugin (basic template)
|
||||
|
||||
# Best Practices
|
||||
|
||||
1. **Fetch documentation first** - Always get the most up-to-date info from docs.obsidian.md
|
||||
2. **Be specific** - Fetch the exact page needed rather than browsing
|
||||
3. **Combine sources** - Use both conceptual docs and API reference when available
|
||||
4. **Show examples** - Reference local plugin code when helpful
|
||||
5. **Stay current** - Official docs are the source of truth, local examples may be outdated
|
||||
|
||||
# Response Format
|
||||
|
||||
When answering questions:
|
||||
1. Briefly explain the concept
|
||||
2. Show relevant code from the documentation
|
||||
3. Point to local examples if applicable
|
||||
4. Provide a working code snippet that follows Obsidian patterns
|
||||
|
||||
Your role is to be a knowledgeable guide to the Obsidian API, helping users find and understand the right documentation for their needs.
|
||||
120
skills/obsidian-api-docs/api-reference.md
Normal file
120
skills/obsidian-api-docs/api-reference.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# Obsidian API Quick Reference
|
||||
|
||||
This is a quick reference for commonly used Obsidian APIs. For full details, fetch the documentation URLs.
|
||||
|
||||
## Core Classes
|
||||
|
||||
### App
|
||||
The main application interface.
|
||||
- `app.vault` - Access to the vault
|
||||
- `app.workspace` - Access to workspace
|
||||
- `app.metadataCache` - File metadata
|
||||
- `app.fileManager` - File operations
|
||||
|
||||
### Vault
|
||||
File system operations.
|
||||
- `vault.getMarkdownFiles()` - Get all markdown files
|
||||
- `vault.read(file)` - Read file contents
|
||||
- `vault.modify(file, data)` - Modify file
|
||||
- `vault.create(path, data)` - Create new file
|
||||
- `vault.delete(file)` - Delete file
|
||||
- `vault.adapter.exists(path)` - Check if path exists
|
||||
|
||||
### Workspace
|
||||
UI and layout management.
|
||||
- `workspace.getActiveViewOfType(MarkdownView)` - Get active markdown view
|
||||
- `workspace.getActiveFile()` - Get currently open file
|
||||
- `workspace.on(event, callback)` - Listen to workspace events
|
||||
- `workspace.getLeaf()` - Get a workspace leaf for custom views
|
||||
|
||||
### Editor
|
||||
Text editing operations.
|
||||
- `editor.getValue()` - Get full editor content
|
||||
- `editor.setValue(text)` - Set full editor content
|
||||
- `editor.getSelection()` - Get selected text
|
||||
- `editor.replaceSelection(text)` - Replace selected text
|
||||
- `editor.getCursor()` - Get cursor position
|
||||
- `editor.getLine(n)` - Get specific line
|
||||
|
||||
### Modal
|
||||
Dialog windows.
|
||||
- `new Modal(app)` - Create modal
|
||||
- `modal.open()` - Show modal
|
||||
- `modal.close()` - Hide modal
|
||||
- `modal.contentEl` - Content container element
|
||||
- `modal.titleEl` - Title container element
|
||||
|
||||
## Plugin Lifecycle
|
||||
|
||||
```typescript
|
||||
export default class MyPlugin extends Plugin {
|
||||
async onload() {
|
||||
// Initialize plugin
|
||||
await this.loadSettings();
|
||||
this.addCommand(...);
|
||||
this.registerView(...);
|
||||
this.addSettingTab(...);
|
||||
}
|
||||
|
||||
onunload() {
|
||||
// Cleanup
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### Adding a Command
|
||||
```typescript
|
||||
this.addCommand({
|
||||
id: 'my-command',
|
||||
name: 'My Command',
|
||||
callback: () => {
|
||||
// Do something
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Editor Command
|
||||
```typescript
|
||||
this.addCommand({
|
||||
id: 'editor-command',
|
||||
name: 'Editor Command',
|
||||
editorCallback: (editor: Editor, view: MarkdownView) => {
|
||||
const selection = editor.getSelection();
|
||||
editor.replaceSelection(selection.toUpperCase());
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Settings
|
||||
```typescript
|
||||
interface MySettings {
|
||||
mySetting: string;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: MySettings = {
|
||||
mySetting: 'default'
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
```
|
||||
|
||||
### Events
|
||||
```typescript
|
||||
this.registerEvent(
|
||||
this.app.workspace.on('file-open', (file) => {
|
||||
console.log('File opened:', file?.path);
|
||||
})
|
||||
);
|
||||
```
|
||||
|
||||
## Useful Documentation Links
|
||||
|
||||
Use WebFetch with these URLs for detailed information on specific topics.
|
||||
Reference in New Issue
Block a user