The Typora Plugin system is a comprehensive extensibility framework for the Typora Markdown editor. It provides a plugin-based architecture that augments Typora's native functionality with over 60 base plugins and a custom plugin development system. The system operates through a three-tier model: Core Plugin Infrastructure (configuration, loading, utilities), Plugin Base Classes (IPlugin, BasePlugin, BaseCustomPlugin), and Feature Plugins (window management, search, visualization, etc.).
This page provides an architectural overview of the entire plugin system. For detailed information about specific subsystems, see:
The plugin system follows a layered architecture where plugins depend on a shared infrastructure layer, which in turn interfaces with Typora's native APIs.
Typora Native Layer to Code Entity Space
Sources: plugin/global/core/plugin.js1-104 plugin/global/core/plugin.js31-39 plugin/right_click_menu.js1-27 plugin/global/core/utils/index.js5-23
The architecture consists of four primary layers:
| Layer | Purpose | Key Components |
|---|---|---|
| Typora Native | Editor APIs provided by Typora | File, ClientCommand, JSBridge, File.editor |
| Core Infrastructure | Configuration, loading, shared services | LoadPlugins(), utils, settings, i18n |
| Plugin Base | Standardized plugin interfaces | IPlugin, BasePlugin, BaseCustomPlugin |
| Feature Plugins | Concrete implementations | 60+ base plugins + custom plugins |
The plugin system bootstraps through a multi-phase loading pipeline defined in plugin/global/core/plugin.js.
Plugin Bootstrap Flow
Sources: plugin/global/core/plugin.js41-64 plugin/global/core/plugin.js66-98
All plugins implement the IPlugin interface with lifecycle methods:
| Phase | Method | Purpose | Required |
|---|---|---|---|
| 1 | beforeProcess() | Pre-initialization checks, async data loading | No |
| 2 | style() | Return CSS string for inline injection | No |
| 3 | styleTemplate() | Return template arguments for dynamic CSS | No |
| 4 | html() | Return HTML string for DOM injection | No |
| 5 | hotkey() | Register keyboard shortcuts | No |
| 6 | init() | Initialize plugin state and entities | No |
| 7 | process() | Bind event listeners and start processing | No |
Sources: plugin/global/core/plugin.js4-29
Plugins can return utils.PLUGIN_LOAD_ABORT from beforeProcess() to halt loading without error plugin/global/core/plugin.js49
The utils object provides 40+ service mixins that form the shared infrastructure layer for all plugins.
Sources: plugin/global/core/utils/index.js5-23 plugin/global/core/utils/index.js40-42
| Service | Primary Methods | Purpose |
|---|---|---|
settings | read(), write(), autoSave() | TOML configuration management |
eventHub | addEventListener(), publishEvent() | Pub/sub event system |
hotkeyHub | register(), execute() | Centralized hotkey registry |
stateRecorder | register(), unregister() | Persist plugin state across sessions |
styleTemplater | register(), render() | Dynamic CSS template rendering |
Sources: plugin/global/core/plugin.js54-58 plugin/right_click_menu.js18-19 plugin/global/core/utils/index.js5-20
The system provides multiple interaction pathways through dispatcher plugins that aggregate functionality.
Input Methods to Code Entity Space
Sources: plugin/right_click_menu.js55-101 plugin/custom/index.js32-72 plugin/global/core/utils/index.js96-116
The right_click_menu plugin constructs a 3-level cascading menu:
Plugins expose actions via staticActions or getDynamicActions(anchorNode, meta) plugin/right_click_menu.js94-96
Developers can create JavaScript plugins using BaseCustomPlugin plugin/global/core/plugin.js35-39 These are loaded from plugin/custom/plugins via the CustomPlugin bridge plugin/custom/index.js1-9
selector(context): Defines the DOM element the plugin targets plugin/custom/index.js57-58callback(anchorNode): Executed when the plugin is triggered plugin/custom/index.js80Feature-rich plugins extend BasePlugin and implement the call(action, meta) method to handle multiple internal actions plugin/global/core/plugin.js31-33
The system includes a vast array of base plugins organized by functional category:
| Category | Plugins | Description |
|---|---|---|
| Window Management | window_tab | Multi-tab interface and session persistence README.md20 |
| Search & Navigation | search_multi, ripgrep | Advanced file search and regex-based searching README.md21-71 |
| Content Structure | collapse_paragraph, auto_number | Section folding and automatic numbering README.md22-53 |
| Visualization | markmap, echarts, kanban | Mind maps, charts, and project management README.md37-50 |
| Display Modes | read_only, dark, blur | Visual adjustments and mode toggles README.md48-62 |
| Automation | commander, article_uploader | Shell command execution and blog publishing README.md31-72 |
Sources: README.md18-73
The eventHub provides pub/sub communication for coordinating between disparate plugins plugin/global/core/utils/index.js9
addEventListener(type, callback): Listen for system events like allPluginsHadInjected plugin/right_click_menu.js19The stateRecorder allows plugins to persist and restore state across Typora sessions plugin/global/core/utils/index.js10
register({ name, selector, stateGetter, stateRestorer }): Hook into the global state persistence lifecycle.Sources: plugin/global/core/utils/index.js5-23 plugin/right_click_menu.js19
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.