diff --git a/src/main.js b/src/main.js
index 8582c8f..42cf052 100644
--- a/src/main.js
+++ b/src/main.js
@@ -3880,6 +3880,17 @@ ipcMain.on('open-table-generator', () => {
openTableGenerator();
});
+// IPC Handler for loading document templates
+ipcMain.handle('load-template', async (event, filename) => {
+ try {
+ const templatePath = path.join(__dirname, 'templates', filename);
+ return fs.readFileSync(templatePath, 'utf-8');
+ } catch (err) {
+ console.error('Failed to load template:', err);
+ return null;
+ }
+});
+
// IPC Handler for saving pasted/dropped images
ipcMain.handle('save-pasted-image', async (event, { base64, ext }) => {
try {
diff --git a/src/preload.js b/src/preload.js
index 41800f5..c076d34 100644
--- a/src/preload.js
+++ b/src/preload.js
@@ -94,7 +94,10 @@ const ALLOWED_SEND_CHANNELS = [
'insert-generated-content',
// Image paste/drop
- 'save-pasted-image'
+ 'save-pasted-image',
+
+ // Templates
+ 'load-template'
];
const ALLOWED_RECEIVE_CHANNELS = [
diff --git a/src/renderer.js b/src/renderer.js
index 967d273..d30a910 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -11,6 +11,7 @@ const hljs = require('highlight.js');
const { createEditor } = require('./editor/codemirror-setup');
const { undo, redo } = require('@codemirror/commands');
const { SidebarManager } = require('./sidebar/sidebar-manager');
+const { renderTemplatesPanel } = require('./sidebar/templates-panel');
const { CommandPalette } = require('./command-palette');
const { PrintPreview } = require('./print-preview');
@@ -1109,7 +1110,15 @@ document.addEventListener('DOMContentLoaded', () => {
});
sidebarManager.registerPanel('templates', {
title: 'Templates',
- render: (container) => { container.innerHTML = '
Templates coming soon...
'; }
+ render: (container) => renderTemplatesPanel(container, async (file) => {
+ const templateContent = await ipcRenderer.invoke('load-template', file);
+ if (templateContent) {
+ const content = templateContent.replace(/\{\{DATE\}\}/g, new Date().toISOString().split('T')[0]);
+ tabManager.createNewTab();
+ const tab = tabManager.tabs.get(tabManager.activeTabId);
+ tabManager.setEditorContent(tab.id, content);
+ }
+ })
});
// Image paste handler
diff --git a/src/sidebar/templates-panel.js b/src/sidebar/templates-panel.js
new file mode 100644
index 0000000..b882cba
--- /dev/null
+++ b/src/sidebar/templates-panel.js
@@ -0,0 +1,34 @@
+const fs = require('fs');
+const path = require('path');
+
+const templates = [
+ { name: 'Blog Post', file: 'blog-post.md', description: 'Article with frontmatter' },
+ { name: 'Meeting Notes', file: 'meeting-notes.md', description: 'Agenda, notes, action items' },
+ { name: 'Technical Spec', file: 'technical-spec.md', description: 'Requirements and architecture' },
+ { name: 'Changelog', file: 'changelog.md', description: 'Keep a Changelog format' },
+ { name: 'README', file: 'readme.md', description: 'Project documentation' },
+ { name: 'Project Plan', file: 'project-plan.md', description: 'Goals, milestones, timeline' },
+ { name: 'API Docs', file: 'api-docs.md', description: 'API endpoint documentation' },
+ { name: 'Tutorial', file: 'tutorial.md', description: 'Step-by-step guide' },
+ { name: 'Release Notes', file: 'release-notes.md', description: 'Version release summary' },
+ { name: 'Comparison', file: 'comparison.md', description: 'Feature comparison table' },
+];
+
+function renderTemplatesPanel(container, onSelect) {
+ container.innerHTML = `
+
+ ${templates.map(t => `
+
+
${t.name}
+
${t.description}
+
+ `).join('')}
+
+ `;
+
+ container.querySelectorAll('.template-item').forEach(el => {
+ el.addEventListener('click', () => onSelect(el.dataset.file));
+ });
+}
+
+module.exports = { renderTemplatesPanel, templates };
diff --git a/src/styles-sidebar.css b/src/styles-sidebar.css
index 533fbdd..e735570 100644
--- a/src/styles-sidebar.css
+++ b/src/styles-sidebar.css
@@ -130,3 +130,34 @@ body[class*="dark"] .sidebar-panel-header {
border-color: #333;
color: #ccc;
}
+
+/* Panel list items (templates, etc.) */
+.panel-list-item {
+ padding: 10px 12px;
+ border-radius: 6px;
+ cursor: pointer;
+ margin-bottom: 4px;
+}
+.panel-list-item:hover {
+ background: var(--gray-200, #e5e7eb);
+}
+.panel-list-item-title {
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--gray-800, #1f2937);
+}
+.panel-list-item-desc {
+ font-size: 11px;
+ color: var(--gray-500, #6b7280);
+ margin-top: 2px;
+}
+
+body[class*="dark"] .panel-list-item:hover {
+ background: #333;
+}
+body[class*="dark"] .panel-list-item-title {
+ color: #ddd;
+}
+body[class*="dark"] .panel-list-item-desc {
+ color: #888;
+}
diff --git a/src/templates/api-docs.md b/src/templates/api-docs.md
new file mode 100644
index 0000000..0df9afd
--- /dev/null
+++ b/src/templates/api-docs.md
@@ -0,0 +1,90 @@
+# API Documentation
+
+**Base URL:** `https://api.example.com/v1`
+**Version:** 1.0
+**Date:** {{DATE}}
+
+## Authentication
+
+All requests require an API key in the header:
+
+```
+Authorization: Bearer YOUR_API_KEY
+```
+
+## Endpoints
+
+### Get All Resources
+
+```
+GET /resources
+```
+
+**Query Parameters:**
+
+| Parameter | Type | Required | Description |
+|-----------|------|----------|-------------|
+| page | integer | No | Page number (default: 1) |
+| limit | integer | No | Items per page (default: 20) |
+
+**Response:**
+
+```json
+{
+ "data": [],
+ "total": 0,
+ "page": 1
+}
+```
+
+### Get Resource by ID
+
+```
+GET /resources/:id
+```
+
+**Response:**
+
+```json
+{
+ "id": "1",
+ "name": "Resource name",
+ "created_at": "2024-01-01T00:00:00Z"
+}
+```
+
+### Create Resource
+
+```
+POST /resources
+```
+
+**Request Body:**
+
+```json
+{
+ "name": "New resource",
+ "description": "Description"
+}
+```
+
+### Update Resource
+
+```
+PUT /resources/:id
+```
+
+### Delete Resource
+
+```
+DELETE /resources/:id
+```
+
+## Error Codes
+
+| Code | Description |
+|------|-------------|
+| 400 | Bad Request |
+| 401 | Unauthorized |
+| 404 | Not Found |
+| 500 | Internal Server Error |
diff --git a/src/templates/blog-post.md b/src/templates/blog-post.md
new file mode 100644
index 0000000..09d38f2
--- /dev/null
+++ b/src/templates/blog-post.md
@@ -0,0 +1,20 @@
+---
+title: Blog Post Title
+date: {{DATE}}
+author: Your Name
+tags: []
+---
+
+# Blog Post Title
+
+## Introduction
+
+Write your introduction here.
+
+## Main Content
+
+Your main content goes here.
+
+## Conclusion
+
+Wrap up your thoughts.
diff --git a/src/templates/changelog.md b/src/templates/changelog.md
new file mode 100644
index 0000000..0697054
--- /dev/null
+++ b/src/templates/changelog.md
@@ -0,0 +1,20 @@
+# Changelog
+
+## [Unreleased]
+
+### Added
+- New feature
+
+### Changed
+- Updated feature
+
+### Fixed
+- Bug fix
+
+### Removed
+- Removed feature
+
+## [1.0.0] - {{DATE}}
+
+### Added
+- Initial release
diff --git a/src/templates/comparison.md b/src/templates/comparison.md
new file mode 100644
index 0000000..8e4d518
--- /dev/null
+++ b/src/templates/comparison.md
@@ -0,0 +1,59 @@
+# Comparison: [Option A] vs [Option B]
+
+**Date:** {{DATE}}
+**Author:** Your Name
+
+## Overview
+
+Brief description of what is being compared and why.
+
+## Feature Comparison
+
+| Feature | Option A | Option B |
+|---------|----------|----------|
+| Feature 1 | Yes | Yes |
+| Feature 2 | Yes | No |
+| Feature 3 | No | Yes |
+| Feature 4 | Partial | Yes |
+
+## Pricing
+
+| Plan | Option A | Option B |
+|------|----------|----------|
+| Free | Limited | Limited |
+| Pro | $10/mo | $15/mo |
+| Enterprise | Custom | Custom |
+
+## Pros and Cons
+
+### Option A
+
+**Pros:**
+- Pro 1
+- Pro 2
+
+**Cons:**
+- Con 1
+- Con 2
+
+### Option B
+
+**Pros:**
+- Pro 1
+- Pro 2
+
+**Cons:**
+- Con 1
+- Con 2
+
+## Performance
+
+| Metric | Option A | Option B |
+|--------|----------|----------|
+| Speed | Fast | Moderate |
+| Memory | Low | Medium |
+| Scalability | Good | Excellent |
+
+## Recommendation
+
+Based on the analysis above, [Option A/B] is recommended for [use case] because [reason].
diff --git a/src/templates/meeting-notes.md b/src/templates/meeting-notes.md
new file mode 100644
index 0000000..d135d56
--- /dev/null
+++ b/src/templates/meeting-notes.md
@@ -0,0 +1,26 @@
+# Meeting Notes
+
+**Date:** {{DATE}}
+**Attendees:**
+- Name 1
+- Name 2
+
+## Agenda
+
+1. Topic 1
+2. Topic 2
+
+## Discussion
+
+### Topic 1
+
+Notes here.
+
+## Action Items
+
+- [ ] Action item 1 — Owner — Due date
+- [ ] Action item 2 — Owner — Due date
+
+## Next Meeting
+
+Date: TBD
diff --git a/src/templates/project-plan.md b/src/templates/project-plan.md
new file mode 100644
index 0000000..0743824
--- /dev/null
+++ b/src/templates/project-plan.md
@@ -0,0 +1,54 @@
+# Project Plan: [Project Name]
+
+**Date:** {{DATE}}
+**Project Lead:** Your Name
+**Status:** Planning
+
+## Goals
+
+1. Primary goal
+2. Secondary goal
+
+## Scope
+
+### In Scope
+- Item 1
+- Item 2
+
+### Out of Scope
+- Item 1
+
+## Milestones
+
+| Milestone | Target Date | Status |
+|-----------|-------------|--------|
+| Kickoff | {{DATE}} | Not Started |
+| MVP | TBD | Not Started |
+| Launch | TBD | Not Started |
+
+## Resources
+
+| Role | Person | Allocation |
+|------|--------|------------|
+| Lead | Name | 100% |
+| Developer | Name | 50% |
+
+## Risks
+
+| Risk | Impact | Likelihood | Mitigation |
+|------|--------|------------|------------|
+| Risk 1 | High | Medium | Plan |
+
+## Timeline
+
+### Phase 1: Planning
+- [ ] Define requirements
+- [ ] Create design documents
+
+### Phase 2: Development
+- [ ] Implement core features
+- [ ] Write tests
+
+### Phase 3: Launch
+- [ ] Deploy to production
+- [ ] Monitor and iterate
diff --git a/src/templates/readme.md b/src/templates/readme.md
new file mode 100644
index 0000000..bd58b21
--- /dev/null
+++ b/src/templates/readme.md
@@ -0,0 +1,38 @@
+# Project Name
+
+Brief description of the project.
+
+## Features
+
+- Feature 1
+- Feature 2
+
+## Installation
+
+```bash
+npm install project-name
+```
+
+## Usage
+
+```javascript
+const project = require('project-name');
+```
+
+## Configuration
+
+| Option | Default | Description |
+|--------|---------|-------------|
+| option1 | true | Description |
+
+## Contributing
+
+1. Fork the repository
+2. Create your feature branch
+3. Commit your changes
+4. Push to the branch
+5. Open a Pull Request
+
+## License
+
+MIT
diff --git a/src/templates/release-notes.md b/src/templates/release-notes.md
new file mode 100644
index 0000000..003c1aa
--- /dev/null
+++ b/src/templates/release-notes.md
@@ -0,0 +1,42 @@
+# Release Notes - v1.0.0
+
+**Release Date:** {{DATE}}
+
+## Highlights
+
+Brief summary of the most important changes in this release.
+
+## New Features
+
+- **Feature 1:** Description of the new feature
+- **Feature 2:** Description of the new feature
+
+## Improvements
+
+- Improved performance of feature X
+- Updated dependency Y to version Z
+
+## Bug Fixes
+
+- Fixed issue where X would cause Y (#123)
+- Resolved crash when performing Z (#456)
+
+## Breaking Changes
+
+- Changed API endpoint from `/old` to `/new`
+- Removed deprecated method `oldMethod()`
+
+## Migration Guide
+
+### From v0.9.x to v1.0.0
+
+1. Update configuration file format
+2. Replace deprecated API calls
+
+## Known Issues
+
+- Issue description (#789)
+
+## Contributors
+
+Thanks to everyone who contributed to this release.
diff --git a/src/templates/technical-spec.md b/src/templates/technical-spec.md
new file mode 100644
index 0000000..b1ded32
--- /dev/null
+++ b/src/templates/technical-spec.md
@@ -0,0 +1,42 @@
+# Technical Specification: [Feature Name]
+
+**Version:** 1.0
+**Date:** {{DATE}}
+**Author:** Your Name
+**Status:** Draft
+
+## Overview
+
+Brief description of what this feature does.
+
+## Requirements
+
+### Functional Requirements
+1. Requirement 1
+2. Requirement 2
+
+### Non-Functional Requirements
+1. Performance requirement
+2. Security requirement
+
+## Architecture
+
+Describe the technical approach.
+
+## API Design
+
+### Endpoints
+
+| Method | Path | Description |
+|--------|------|-------------|
+| GET | /api/resource | Get resource |
+
+## Testing Strategy
+
+Describe how this will be tested.
+
+## Timeline
+
+| Phase | Duration | Deliverables |
+|-------|----------|-------------|
+| Phase 1 | 1 week | Core implementation |
diff --git a/src/templates/tutorial.md b/src/templates/tutorial.md
new file mode 100644
index 0000000..4d68a0b
--- /dev/null
+++ b/src/templates/tutorial.md
@@ -0,0 +1,71 @@
+# Tutorial: [Topic Name]
+
+**Date:** {{DATE}}
+**Difficulty:** Beginner / Intermediate / Advanced
+**Time:** ~30 minutes
+
+## Prerequisites
+
+- Prerequisite 1
+- Prerequisite 2
+
+## What You Will Learn
+
+- Learning objective 1
+- Learning objective 2
+
+## Step 1: Getting Started
+
+Description of the first step.
+
+```bash
+# Example command
+echo "Hello, World!"
+```
+
+## Step 2: Core Concepts
+
+Explain the main concepts here.
+
+### Key Concept A
+
+Details about concept A.
+
+### Key Concept B
+
+Details about concept B.
+
+## Step 3: Building the Feature
+
+Walk through the implementation.
+
+```javascript
+// Example code
+function example() {
+ return 'Hello';
+}
+```
+
+## Step 4: Testing
+
+How to verify everything works.
+
+## Common Issues
+
+### Issue 1
+**Problem:** Description of the problem.
+**Solution:** How to fix it.
+
+### Issue 2
+**Problem:** Description of the problem.
+**Solution:** How to fix it.
+
+## Next Steps
+
+- Suggested follow-up 1
+- Suggested follow-up 2
+
+## Resources
+
+- [Resource 1](https://example.com)
+- [Resource 2](https://example.com)