File size: 6,677 Bytes
0b194e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/*

   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;