Initial commit
This commit is contained in:
24
commands/add-command.md
Normal file
24
commands/add-command.md
Normal file
@@ -0,0 +1,24 @@
|
||||
You are helping the user add a new command to their Obsidian plugin.
|
||||
|
||||
1. Ask the user for:
|
||||
- Command id (kebab-case)
|
||||
- Command display name
|
||||
- Whether it needs an editor callback (operates on editor content)
|
||||
- Whether it needs a check callback (conditional execution)
|
||||
- Hotkey (optional)
|
||||
|
||||
2. Read the main.ts file to understand the current plugin structure
|
||||
|
||||
3. Add the command using this.addCommand() in the onload() method:
|
||||
- For simple commands: use callback
|
||||
- For editor commands: use editorCallback with Editor and MarkdownView params
|
||||
- For conditional commands: use checkCallback with checking parameter
|
||||
|
||||
4. Implement the command logic based on user requirements
|
||||
|
||||
Example patterns:
|
||||
- Simple command: Opens modal, shows notice, triggers action
|
||||
- Editor command: Reads/modifies selected text or cursor position
|
||||
- Check command: Only available in certain contexts (e.g., when markdown view is active)
|
||||
|
||||
Reference the instruct plugin for complex command examples.
|
||||
27
commands/add-modal.md
Normal file
27
commands/add-modal.md
Normal file
@@ -0,0 +1,27 @@
|
||||
You are helping the user create a modal for their Obsidian plugin.
|
||||
|
||||
1. Ask the user what type of modal they need:
|
||||
- Simple Modal: Display information
|
||||
- Input Modal: Collect user input
|
||||
- SuggestModal: Searchable dropdown/autocomplete
|
||||
- Custom Modal: Complex UI with forms/buttons
|
||||
|
||||
2. Create the modal class:
|
||||
- Extend Modal or SuggestModal from 'obsidian'
|
||||
- Implement constructor with App and any needed params
|
||||
- Implement onOpen() for rendering UI
|
||||
- Implement onClose() for cleanup
|
||||
- For SuggestModal: implement getSuggestions(), renderSuggestion(), onChooseSuggestion()
|
||||
|
||||
3. Add UI components in onOpen():
|
||||
- Use contentEl.createEl() for elements
|
||||
- Use TextAreaComponent, ButtonComponent, etc. for controls
|
||||
- Style with CSS classes or inline styles
|
||||
- Add event handlers for interactions
|
||||
|
||||
4. Integrate with the plugin:
|
||||
- Trigger modal with new YourModal(this.app).open()
|
||||
- Pass data to modal via constructor
|
||||
- Handle modal results via callbacks or promises
|
||||
|
||||
Reference instruct plugin for InstructionModal and FindInstructionModal examples.
|
||||
48
commands/add-react-component.md
Normal file
48
commands/add-react-component.md
Normal file
@@ -0,0 +1,48 @@
|
||||
You are helping the user add a React component to their Obsidian plugin.
|
||||
|
||||
1. Verify React is set up:
|
||||
- Check package.json for react and react-dom dependencies
|
||||
- Check for @types/react in devDependencies
|
||||
- Verify esbuild config handles JSX
|
||||
|
||||
2. Ask the user about the component:
|
||||
- Component purpose and UI
|
||||
- Where it will be rendered (modal, view, sidebar, etc.)
|
||||
- Props and state needed
|
||||
- Any Obsidian API integration
|
||||
|
||||
3. Create the React component:
|
||||
- Create .tsx file in appropriate directory
|
||||
- Use functional components with hooks
|
||||
- Import necessary Obsidian types
|
||||
- Implement component logic
|
||||
|
||||
4. Integrate with Obsidian:
|
||||
- Use ReactDOM.render() to mount component
|
||||
- Create ItemView extension if it's a custom view
|
||||
- Properly unmount component in cleanup
|
||||
- Use Obsidian's styling system for consistency
|
||||
|
||||
Example pattern:
|
||||
```typescript
|
||||
import { ItemView } from 'obsidian';
|
||||
import * as React from 'react';
|
||||
import { createRoot, Root } from 'react-dom/client';
|
||||
|
||||
export class MyReactView extends ItemView {
|
||||
root: Root | null = null;
|
||||
|
||||
onOpen() {
|
||||
const container = this.containerEl.children[1];
|
||||
container.empty();
|
||||
this.root = createRoot(container);
|
||||
this.root.render(<MyComponent />);
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.root?.unmount();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference example plugins for React integration patterns.
|
||||
28
commands/add-settings.md
Normal file
28
commands/add-settings.md
Normal file
@@ -0,0 +1,28 @@
|
||||
You are helping the user add settings to their Obsidian plugin.
|
||||
|
||||
1. Ask the user what settings they need:
|
||||
- Text inputs (API keys, paths, etc.)
|
||||
- Number inputs (limits, thresholds)
|
||||
- Toggles (boolean options)
|
||||
- Dropdowns (predefined choices)
|
||||
- Sliders (ranged values)
|
||||
|
||||
2. Update the plugin structure:
|
||||
- Add settings interface with proper types
|
||||
- Update DEFAULT_SETTINGS constant
|
||||
- Add settings tab class extending PluginSettingTab
|
||||
- Register the settings tab in onload()
|
||||
- Implement display() method with Setting components
|
||||
|
||||
3. Implement setting controls using Obsidian's Setting API:
|
||||
- addText() for text inputs
|
||||
- addToggle() for boolean switches
|
||||
- addDropdown() for select options
|
||||
- addSlider() for numeric ranges
|
||||
- addTextArea() for multi-line input
|
||||
|
||||
4. Ensure proper saving/loading:
|
||||
- Call saveSettings() onChange
|
||||
- Use proper TypeScript types
|
||||
|
||||
Reference the instruct plugin for comprehensive settings examples.
|
||||
40
commands/add-tests.md
Normal file
40
commands/add-tests.md
Normal file
@@ -0,0 +1,40 @@
|
||||
You are helping the user add Jest tests to their Obsidian plugin.
|
||||
|
||||
1. Set up Jest if not already configured:
|
||||
- Add jest, ts-jest, @types/jest to devDependencies
|
||||
- Create jest.config.js with TypeScript support
|
||||
- Add test script to package.json
|
||||
- Create __tests__ directory
|
||||
|
||||
2. Ask the user what to test:
|
||||
- Utility functions (pure logic)
|
||||
- Settings management
|
||||
- Data processing
|
||||
- Modal logic
|
||||
- Command handlers (if testable)
|
||||
|
||||
3. Create test files:
|
||||
- Name files *.test.ts or *.spec.ts
|
||||
- Import functions/classes to test
|
||||
- Mock Obsidian API where needed
|
||||
- Write describe/it blocks
|
||||
|
||||
4. Write basic tests covering:
|
||||
- Happy path scenarios
|
||||
- Edge cases
|
||||
- Error handling
|
||||
- State management
|
||||
|
||||
Example test structure:
|
||||
```typescript
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
|
||||
describe('MyUtility', () => {
|
||||
it('should process data correctly', () => {
|
||||
const result = myFunction(input);
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Keep tests simple and focused. Don't aim for comprehensive coverage, just basic validation.
|
||||
12
commands/new-plugin.md
Normal file
12
commands/new-plugin.md
Normal file
@@ -0,0 +1,12 @@
|
||||
You are helping the user create a new Obsidian plugin using the official template.
|
||||
|
||||
Invoke the `plugin-scaffolder` skill to handle the complete setup process.
|
||||
|
||||
The skill will:
|
||||
1. Clone https://github.com/obsidianmd/obsidian-sample-plugin
|
||||
2. Customize it with the user's plugin details
|
||||
3. Optionally add React support
|
||||
4. Optionally add a backend server
|
||||
5. Install dependencies and provide next steps
|
||||
|
||||
This approach is simpler and more maintainable than creating files manually.
|
||||
56
commands/setup-release.md
Normal file
56
commands/setup-release.md
Normal file
@@ -0,0 +1,56 @@
|
||||
You are helping the user set up GitHub Actions for releasing their Obsidian plugin.
|
||||
|
||||
1. Verify prerequisites:
|
||||
- Plugin has a git repository
|
||||
- GitHub repository is created
|
||||
- manifest.json is properly configured
|
||||
- package.json version matches manifest.json
|
||||
|
||||
2. Create release workflow:
|
||||
- Create .github/workflows/release.yml
|
||||
- Configure workflow to trigger on version tags
|
||||
- Set up Node.js build environment
|
||||
- Run build process
|
||||
- Create GitHub release with built artifacts
|
||||
|
||||
3. Create necessary files:
|
||||
- versions.json to track version history
|
||||
- version-bump.mjs script to sync versions
|
||||
- Update package.json scripts
|
||||
|
||||
4. Provide release instructions:
|
||||
- How to update version numbers
|
||||
- How to create git tags
|
||||
- How to push tags to trigger release
|
||||
- What files need to be updated
|
||||
|
||||
Use this workflow template:
|
||||
```yaml
|
||||
name: Release Obsidian plugin
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: Create release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh release create "${{ github.ref_name }}" \
|
||||
--title "${{ github.ref_name }}" \
|
||||
--draft \
|
||||
main.js manifest.json styles.css
|
||||
```
|
||||
|
||||
Reference: https://docs.obsidian.md/Plugins/Releasing/Release+your+plugin+with+GitHub+Actions
|
||||
Reference in New Issue
Block a user