How mlosun/obsidian-sticker-package works
Project type and purpose
• This is an Obsidian plugin (“obsidian-sticker-package”) that lets users pick images from a configured vault directory and insert them into the editor as “stickers.”
• It’s built in TypeScript, bundled with esbuild, and packaged/published via GitHub Actions.
File structure
• Top level:
• main.ts – plugin entry point
• manifest.json – defines plugin id, version, permissions, entry file
• styles.css – optional styling for UI elements
• esbuild.config.mjs, tsconfig.json – build configuration
• version-bump.mjs, versions.json – versioning script/data
• .github/workflows/release.yml – CI/CD pipeline for packaging & releasing
• images/ – screenshots for the README (not shipped in plugin)
• Settings management
• File-system scanning of the Vault’s configured directory
• UI components (context-menu extension, picker modal)
• Command handlers to insert markdown
Key insights from the README
• Plugin runtime depends on Obsidian’s Plugin API to register commands, add context-menu items, and render modals.
• Users configure a directory path and default image size via a settings panel.
• At use time, the plugin scans the Vault’s folder, builds a list of image paths, and shows them in a UI picker.
Main components
A. Development & Release Pipeline
1. GitHub Repository
2. CI/CD (GitHub Actions → esbuild build → version-bump → GitHub Release)
3. Published .obsidian-plugin zip asset
B. Runtime Environment
1. Obsidian Host (Electron app)
2. Plugin Loader (reads manifest.json → loads bundle)
3. Plugin Core Modules
• Settings Module (persist via Obsidian’s API)
• File Scanner Module (reads Vault folder via Node fs)
• UI Module (context menu extension, modal picker)
• Command Handler (inserts markdown into the editor)
4. Vault File System (user’s .md files + sticker images directory)
5. Editor Canvas (where markdown is inserted)
C. External Services
• GitHub (source repo & releases)
• BRAT or manual install (user-facing install path)
Relationships and data flows
• Developer pushes code → CI builds → publishes plugin → user installs plugin
• At runtime:
1. Obsidian reads manifest.json → instantiates plugin bundle
2. Plugin registers commands & context-menu hook
3. User right-clicks in editor → Obsidian calls plugin UI Module
4. UI Module invokes File Scanner → returns image list
5. User selects an image → Command Handler formats markdown and inserts into Editor
6. Settings changes → Settings Module persists via Obsidian API
Architectural patterns & principles
• Plugin-based architecture: clear boundary between host (Obsidian) and plugin.
• Modular separation: Settings ↔ File I/O ↔ UI ↔ Editor Command.
• Single-bundle deployment via esbuild for performance & simplicity.
• CI/CD ensures reproducible releases (version bump + GitHub Actions).