Full document, spreadsheet, slideshow, and diagram tooling
1/**
2 * Document Templates — built-in and user-created templates.
3 *
4 * Pure data module: template definitions and lookup functions.
5 * No DOM dependencies — UI integration is in landing.ts.
6 */
7
8export interface DocTemplate {
9 id: string;
10 name: string;
11 description: string;
12 type: 'doc' | 'sheet';
13 icon: string;
14 content: string; // HTML for docs, JSON cell data for sheets
15}
16
17export const BUILT_IN_TEMPLATES: DocTemplate[] = [
18 // --- Document Templates ---
19 {
20 id: 'meeting-notes',
21 name: 'Meeting Notes',
22 description: 'Structured meeting notes with attendees, agenda, and action items',
23 type: 'doc',
24 icon: '\uD83D\uDCCB',
25 content: '<h1>Meeting Notes</h1><p><strong>Date:</strong> </p><p><strong>Attendees:</strong> </p><h2>Agenda</h2><ol><li><p></p></li></ol><h2>Discussion</h2><p></p><h2>Action Items</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Next Steps</h2><p></p>',
26 },
27 {
28 id: 'project-brief',
29 name: 'Project Brief',
30 description: 'Project overview with goals, timeline, and stakeholders',
31 type: 'doc',
32 icon: '\uD83D\uDCC4',
33 content: '<h1>Project Brief</h1><h2>Overview</h2><p></p><h2>Goals</h2><ul><li><p></p></li></ul><h2>Scope</h2><p></p><h2>Timeline</h2><table><tr><th>Milestone</th><th>Date</th><th>Status</th></tr><tr><td></td><td></td><td></td></tr></table><h2>Stakeholders</h2><ul><li><p></p></li></ul><h2>Risks</h2><ul><li><p></p></li></ul>',
34 },
35 {
36 id: 'weekly-planner',
37 name: 'Weekly Planner',
38 description: 'Week-at-a-glance planner with daily sections',
39 type: 'doc',
40 icon: '\uD83D\uDCC5',
41 content: '<h1>Weekly Planner</h1><p><strong>Week of:</strong> </p><h2>Monday</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Tuesday</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Wednesday</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Thursday</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Friday</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Notes</h2><p></p>',
42 },
43
44 {
45 id: 'technical-spec',
46 name: 'Technical Spec',
47 description: 'Architecture, API design, and implementation plan',
48 type: 'doc',
49 icon: '\u2699',
50 content: '<h1>Technical Specification</h1><h2>Summary</h2><p>One-paragraph summary of the technical change.</p><h2>Background</h2><p></p><h2>Goals and Non-Goals</h2><h3>Goals</h3><ul><li><p></p></li></ul><h3>Non-Goals</h3><ul><li><p></p></li></ul><h2>Design</h2><h3>Architecture</h3><p></p><h3>Data Model</h3><p></p><h3>API</h3><p></p><h2>Alternatives Considered</h2><p></p><h2>Security Considerations</h2><p></p><h2>Testing Plan</h2><ul><li><p></p></li></ul>',
51 },
52 {
53 id: 'letter',
54 name: 'Letter',
55 description: 'Formal letter with greeting and signature',
56 type: 'doc',
57 icon: '\u2709',
58 content: '<p></p><p>Dear ,</p><p></p><p></p><p></p><p>Sincerely,</p><p></p><p><em>Your Name</em></p>',
59 },
60 {
61 id: 'journal',
62 name: 'Journal Entry',
63 description: 'Daily reflection, gratitude, and goals',
64 type: 'doc',
65 icon: '\u263c',
66 content: '<h1>Journal Entry</h1><h2>Thoughts</h2><p></p><h2>Grateful For</h2><ul><li><p></p></li></ul><h2>Goals for Today</h2><ul data-type="taskList"><li data-type="taskItem" data-checked="false"><p></p></li></ul><h2>Notes</h2><p></p>',
67 },
68 {
69 id: 'knowledge-base',
70 name: 'Knowledge Base Article',
71 description: 'How-to guide with prerequisites and steps',
72 type: 'doc',
73 icon: '\u2139',
74 content: '<h1>Article Title</h1><blockquote><p><strong>Summary:</strong> A one-sentence description.</p></blockquote><h2>Prerequisites</h2><ul><li><p></p></li></ul><h2>Steps</h2><ol><li><p>Step 1</p></li><li><p>Step 2</p></li><li><p>Step 3</p></li></ol><h2>Troubleshooting</h2><p><strong>Problem:</strong> </p><p><strong>Solution:</strong> </p><h2>Related Articles</h2><ul><li><p></p></li></ul>',
75 },
76
77 // --- Sheet Templates ---
78 {
79 id: 'budget-tracker',
80 name: 'Budget Tracker',
81 description: 'Monthly budget with income, expenses, and totals',
82 type: 'sheet',
83 icon: '\uD83D\uDCB0',
84 content: JSON.stringify({
85 A1: { v: 'Category', s: { bold: true } },
86 B1: { v: 'Budget', s: { bold: true } },
87 C1: { v: 'Actual', s: { bold: true } },
88 D1: { v: 'Difference', s: { bold: true } },
89 A2: { v: 'Housing' }, B2: { v: 0, s: { format: 'currency' } }, C2: { v: 0, s: { format: 'currency' } }, D2: { f: 'B2-C2', s: { format: 'currency' } },
90 A3: { v: 'Food' }, B3: { v: 0, s: { format: 'currency' } }, C3: { v: 0, s: { format: 'currency' } }, D3: { f: 'B3-C3', s: { format: 'currency' } },
91 A4: { v: 'Transport' }, B4: { v: 0, s: { format: 'currency' } }, C4: { v: 0, s: { format: 'currency' } }, D4: { f: 'B4-C4', s: { format: 'currency' } },
92 A5: { v: 'Utilities' }, B5: { v: 0, s: { format: 'currency' } }, C5: { v: 0, s: { format: 'currency' } }, D5: { f: 'B5-C5', s: { format: 'currency' } },
93 A6: { v: 'Other' }, B6: { v: 0, s: { format: 'currency' } }, C6: { v: 0, s: { format: 'currency' } }, D6: { f: 'B6-C6', s: { format: 'currency' } },
94 A7: { v: 'Total', s: { bold: true } }, B7: { f: 'SUM(B2:B6)', s: { bold: true, format: 'currency' } }, C7: { f: 'SUM(C2:C6)', s: { bold: true, format: 'currency' } }, D7: { f: 'B7-C7', s: { bold: true, format: 'currency' } },
95 }),
96 },
97 {
98 id: 'invoice',
99 name: 'Invoice',
100 description: 'Simple invoice with line items and totals',
101 type: 'sheet',
102 icon: '\uD83E\uDDFE',
103 content: JSON.stringify({
104 A1: { v: 'INVOICE', s: { bold: true, fontSize: 18 } },
105 A3: { v: 'Bill To:', s: { bold: true } },
106 A4: { v: '' },
107 A6: { v: 'Item', s: { bold: true } },
108 B6: { v: 'Quantity', s: { bold: true } },
109 C6: { v: 'Unit Price', s: { bold: true } },
110 D6: { v: 'Amount', s: { bold: true } },
111 A7: { v: '' }, B7: { v: 0 }, C7: { v: 0, s: { format: 'currency' } }, D7: { f: 'B7*C7', s: { format: 'currency' } },
112 A8: { v: '' }, B8: { v: 0 }, C8: { v: 0, s: { format: 'currency' } }, D8: { f: 'B8*C8', s: { format: 'currency' } },
113 A9: { v: '' }, B9: { v: 0 }, C9: { v: 0, s: { format: 'currency' } }, D9: { f: 'B9*C9', s: { format: 'currency' } },
114 A10: { v: '' }, B10: { v: 0 }, C10: { v: 0, s: { format: 'currency' } }, D10: { f: 'B10*C10', s: { format: 'currency' } },
115 C11: { v: 'Subtotal', s: { bold: true } }, D11: { f: 'SUM(D7:D10)', s: { bold: true, format: 'currency' } },
116 C12: { v: 'Tax (10%)', s: { bold: true } }, D12: { f: 'D11*0.1', s: { format: 'currency' } },
117 C13: { v: 'Total', s: { bold: true } }, D13: { f: 'D11+D12', s: { bold: true, format: 'currency' } },
118 }),
119 },
120];
121
122/**
123 * Get a template by ID.
124 */
125export function getTemplate(id: string): DocTemplate | null {
126 return BUILT_IN_TEMPLATES.find(t => t.id === id) || null;
127}
128
129/**
130 * Get all templates for a given document type.
131 */
132export function getTemplatesByType(type: 'doc' | 'sheet'): DocTemplate[] {
133 return BUILT_IN_TEMPLATES.filter(t => t.type === type);
134}