Spaces:
Running
Running
| /* | |
| ELYSIA MARKDOWN STUDIO v1.0 - Templates Module | |
| Document templates library | |
| */ | |
| import Utils from "./utils.js"; | |
| import DB from "./db.js"; | |
| const Templates = { | |
| builtInTemplates: [ | |
| { | |
| name: "README", | |
| category: "GitHub", | |
| description: "Standard project README template", | |
| content: `# Project Title | |
| ## Description | |
| A brief description of what this project does and who it's for. | |
| ## Features | |
| - Feature 1 | |
| - Feature 2 | |
| - Feature 3 | |
| ## Installation | |
| \`\`\`bash | |
| npm install | |
| \`\`\` | |
| ## Usage | |
| \`\`\`javascript | |
| const example = require('example'); | |
| \`\`\` | |
| ## Contributing | |
| Contributions are welcome! Please feel free to submit a Pull Request. | |
| ## License | |
| MIT License | |
| ` | |
| }, | |
| { | |
| name: "Blog Post", | |
| category: "Writing", | |
| description: "Blog post structure", | |
| content: `# Post Title | |
| **Published:** ${new Date().toLocaleDateString()} | |
| **Author:** Your Name | |
| **Tags:** tag1, tag2, tag3 | |
| ## Introduction | |
| Hook the reader with an engaging introduction... | |
| ## Main Content | |
| ### Section 1 | |
| Content for section 1... | |
| ### Section 2 | |
| Content for section 2... | |
| ### Section 3 | |
| Content for section 3... | |
| ## Conclusion | |
| Summarize key points and call to action... | |
| --- | |
| *Found this helpful? Share it with others!* | |
| ` | |
| }, | |
| { | |
| name: "Meeting Notes", | |
| category: "Productivity", | |
| description: "Meeting notes template", | |
| content: `# Meeting Notes | |
| **Date:** ${new Date().toLocaleDateString()} | |
| **Time:** HH:MM | |
| **Attendees:** Name 1, Name 2, Name 3 | |
| **Location:** Zoom/Office/etc. | |
| ## Agenda | |
| 1. Topic 1 | |
| 2. Topic 2 | |
| 3. Topic 3 | |
| ## Discussion | |
| ### Topic 1 | |
| - Point 1 | |
| - Point 2 | |
| ### Topic 2 | |
| - Point 1 | |
| - Point 2 | |
| ## Action Items | |
| - [ ] Task 1 - Assigned to: Person A - Due: Date | |
| - [ ] Task 2 - Assigned to: Person B - Due: Date | |
| ## Next Steps | |
| ... | |
| ## Next Meeting | |
| **Date:** TBD | |
| **Topics:** ... | |
| ` | |
| }, | |
| { | |
| name: "Documentation", | |
| category: "Technical", | |
| description: "API/Software documentation", | |
| content: `# Component/API Documentation | |
| ## Overview | |
| Brief description of the component/API... | |
| ## Installation | |
| \`\`\`bash | |
| npm install package-name | |
| \`\`\` | |
| ## Quick Start | |
| \`\`\`javascript | |
| import { Component } from 'package-name'; | |
| const example = new Component({ | |
| option1: 'value1', | |
| option2: 'value2' | |
| }); | |
| \`\`\` | |
| ## API Reference | |
| ### Method 1 | |
| **Description:** What this method does | |
| **Parameters:** | |
| - \`param1\` (Type): Description | |
| - \`param2\` (Type): Description | |
| **Returns:** Return type and description | |
| **Example:** | |
| \`\`\`javascript | |
| example.method1(param1, param2); | |
| \`\`\` | |
| ### Method 2 | |
| ... | |
| ## Examples | |
| ### Example 1: Basic Usage | |
| \`\`\`javascript | |
| // Code example | |
| \`\`\` | |
| ### Example 2: Advanced Usage | |
| \`\`\`javascript | |
| // Code example | |
| \`\`\` | |
| ## Configuration | |
| | Option | Type | Default | Description | | |
| |--------|------|---------|-------------| | |
| | option1 | String | 'default' | Description | | |
| | option2 | Number | 0 | Description | | |
| ## Troubleshooting | |
| **Issue 1:** Description | |
| **Solution:** How to fix | |
| **Issue 2:** Description | |
| **Solution:** How to fix | |
| ## License | |
| MIT | |
| ` | |
| }, | |
| { | |
| name: "Academic Paper", | |
| category: "Academic", | |
| description: "Research paper structure", | |
| content: `# Paper Title | |
| **Author:** Your Name | |
| **Affiliation:** University/Institution | |
| **Date:** ${new Date().toLocaleDateString()} | |
| ## Abstract | |
| Brief summary of the research (150-250 words)... | |
| ## 1. Introduction | |
| ### 1.1 Background | |
| Context and motivation for the research... | |
| ### 1.2 Research Question | |
| What this paper aims to answer... | |
| ### 1.3 Contributions | |
| Key contributions of this work... | |
| ## 2. Related Work | |
| Review of existing literature and how this work differs... | |
| ## 3. Methodology | |
| ### 3.1 Approach | |
| Description of the approach taken... | |
| ### 3.2 Implementation | |
| Technical details... | |
| ## 4. Results | |
| ### 4.1 Experiment 1 | |
| Description and results... | |
| ### 4.2 Experiment 2 | |
| Description and results... | |
| ## 5. Discussion | |
| Analysis and interpretation of results... | |
| ## 6. Conclusion | |
| Summary of findings and future work... | |
| ## References | |
| 1. Reference 1 | |
| 2. Reference 2 | |
| 3. Reference 3 | |
| ## Appendix | |
| Additional materials, code, data... | |
| ` | |
| }, | |
| { | |
| name: "Blank", | |
| category: "Basic", | |
| description: "Empty document", | |
| content: "" | |
| } | |
| ], | |
| init() { | |
| // Templates can be opened via modal (future feature) | |
| // For now, templates are loaded in the new document flow | |
| }, | |
| async loadTemplates() { | |
| const customTemplates = await DB.getTemplates(); | |
| return [...this.builtInTemplates, ...customTemplates]; | |
| }, | |
| async showTemplatesModal() { | |
| const templates = await this.loadTemplates(); | |
| const grid = document.getElementById("templates-grid"); | |
| grid.innerHTML = templates | |
| .map( | |
| t => ` | |
| <div class="template-card" data-name="${t.name}"> | |
| <div class="template-name">${t.name}</div> | |
| <div class="template-desc">${t.description}</div> | |
| <div class="template-category">${t.category}</div> | |
| </div> | |
| ` | |
| ) | |
| .join(""); | |
| grid.querySelectorAll(".template-card").forEach(card => { | |
| card.addEventListener("click", () => { | |
| const name = card.getAttribute("data-name"); | |
| const template = templates.find(t => t.name === name); | |
| if (template) { | |
| // Use app.newDocument with template name | |
| window.app?.newDocument(template.name); | |
| Utils.modal.close("modal-templates"); | |
| Utils.toast.success(`Template "${name}" loaded!`); | |
| } | |
| }); | |
| }); | |
| Utils.modal.open("modal-templates"); | |
| }, | |
| async getTemplate(name) { | |
| // Search built-in first | |
| let template = this.builtInTemplates.find(t => t.name === name); | |
| // If not found, search custom templates | |
| if (!template) { | |
| const customTemplates = await DB.getTemplates(); | |
| template = customTemplates.find(t => t.name === name); | |
| } | |
| return template; | |
| } | |
| }; | |
| export default Templates; | |