How benji300/joplin-note-tabs works
Main Components of the Plugin
a. Plugin Interface/Integration Layer:
• Represented by the “api” directory which includes TypeScript declaration files (e.g. Joplin.d.ts, JoplinClipboard.d.ts, etc.). These files define how the plugin interacts with core Joplin APIs such as commands, settings, UI elements, and data storage.
b. Core Business Logic:
• The “src” directory holds the core TypeScript files (index.ts, noteTabs.ts, panel.ts, settings.ts, lastActiveNote.ts). These files encapsulate the functionality for managing note tabs, handling user actions (like pinning/unpinning), and interfacing with Joplin’s commands.
c. User Interface and Styling:
• UI elements for the panels are handled in “src/webview.js” and its accompanying CSS files (webview.css, webview_auto.css, webview_vertical.css). This part covers the visual representation and responsive behaviors (horizontal or vertical layouts) of the note tabs.
d. Configuration and Manifest:
• Files such as “src/manifest.json” and “plugin.config.json” provide the metadata and configuration needed by Joplin to load and execute the plugin. They include required version information and define how the plugin is registered.
e. Assets:
• The “assets” directory contains supporting media (like screencast.mp4) and screenshots, which illustrate the UI and can be referenced in the design documentation.
f. Build and Development Tools:
• Tools like “webpack.config.js” and “tsconfig.json” indicate that the project is built using TypeScript and bundled with Webpack. The package.json and accompanying scripts (e.g., “npm run dist” for building the plugin) show standard Node.js tooling.
Relationships and Interactions Between Components
• The plugin integration layer (API declarations) allows the “src” business logic to call proper Joplin APIs which, in turn, affect the UI.
• UI components (webviews) are rendered using the output generated from the business logic. For example, note selections and tab management logic in “noteTabs.ts” or “panel.ts” trigger UI updates.
• Configuration files (manifest.json, plugin.config.json) serve as entry points that tell Joplin how to load and initialize the plugin, which then bootstraps the entire business logic sequence.
• Build scripts (webpack.config.js) compile and bundle all the TypeScript sources, ensuring the API integration, business logic, and UI components are packaged into the correct format for distribution.
Architectural Patterns and Design Principles
• Separation of Concerns: The clear division between API definitions, business logic, UI components, and configuration indicates a modular design.
• Plugin Architecture: The design leverages Joplin’s plugin system, requiring clear interfaces (through API declarations) and adherence to Joplin’s command, settings, and view integration models.
• Event-Driven Interactions: The use of commands (such as tabsPinNote, tabsSwitchRight, etc.) suggests event-based communication where user actions trigger events that flow from the UI to the business logic and back to modify the UI.