domma-cms 0.6.16 → 0.6.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/js/api.js +1 -1
- package/admin/js/app.js +4 -4
- package/admin/js/lib/markdown-toolbar.js +14 -14
- package/admin/js/views/collection-editor.js +5 -3
- package/admin/js/views/collections.js +1 -1
- package/admin/js/views/page-editor.js +27 -27
- package/config/plugins.json +16 -0
- package/config/site.json +1 -1
- package/package.json +2 -2
- package/plugins/analytics/stats.json +1 -1
- package/plugins/contacts/admin/templates/contacts.html +126 -0
- package/plugins/contacts/admin/views/contacts.js +710 -0
- package/plugins/contacts/config.js +6 -0
- package/plugins/contacts/data/contacts.json +20 -0
- package/plugins/contacts/plugin.js +351 -0
- package/plugins/contacts/plugin.json +23 -0
- package/plugins/docs/admin/templates/docs.html +69 -0
- package/plugins/docs/admin/views/docs.js +276 -0
- package/plugins/docs/config.js +8 -0
- package/plugins/docs/data/documents/452f49b7-9c93-4a67-874d-27f882891ad2.json +11 -0
- package/plugins/docs/data/documents/57e003f0-68f2-47dc-9c36-ed4b10ed3deb.json +11 -0
- package/plugins/docs/data/folders.json +9 -0
- package/plugins/docs/data/templates.json +1 -0
- package/plugins/docs/plugin.js +375 -0
- package/plugins/docs/plugin.json +23 -0
- package/plugins/notes/admin/templates/notes.html +92 -0
- package/plugins/notes/admin/views/notes.js +304 -0
- package/plugins/notes/config.js +6 -0
- package/plugins/notes/data/notes.json +1 -0
- package/plugins/notes/plugin.js +177 -0
- package/plugins/notes/plugin.json +23 -0
- package/plugins/todo/admin/templates/todo.html +164 -0
- package/plugins/todo/admin/views/todo.js +328 -0
- package/plugins/todo/config.js +7 -0
- package/plugins/todo/data/todos.json +1 -0
- package/plugins/todo/plugin.js +155 -0
- package/plugins/todo/plugin.json +23 -0
- package/server/routes/api/auth.js +2 -0
- package/server/routes/api/collections.js +55 -0
- package/server/routes/api/forms.js +3 -0
- package/server/routes/api/settings.js +16 -1
- package/server/routes/public.js +2 -0
- package/server/services/markdown.js +169 -8
- package/server/services/plugins.js +3 -2
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { createStore } from '../_lib/dataStore.js';
|
|
2
|
+
import defaultConfig from './config.js';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
import fs from 'fs/promises';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const dataDir = path.join(__dirname, 'data');
|
|
11
|
+
const documentsDir = path.join(dataDir, 'documents');
|
|
12
|
+
const versionsDir = path.join(dataDir, 'versions');
|
|
13
|
+
|
|
14
|
+
const foldersStore = createStore(path.join(dataDir, 'folders.json'));
|
|
15
|
+
const templatesStore = createStore(path.join(dataDir, 'templates.json'));
|
|
16
|
+
|
|
17
|
+
function countWords(html) {
|
|
18
|
+
if (!html) return 0;
|
|
19
|
+
const text = html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
|
20
|
+
return text ? text.split(' ').length : 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function readDoc(id) {
|
|
24
|
+
try {
|
|
25
|
+
const raw = await fs.readFile(path.join(documentsDir, `${id}.json`), 'utf8');
|
|
26
|
+
return JSON.parse(raw);
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function writeDoc(doc) {
|
|
33
|
+
await fs.mkdir(documentsDir, { recursive: true });
|
|
34
|
+
await fs.writeFile(path.join(documentsDir, `${doc.id}.json`), JSON.stringify(doc, null, 2));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function listDocs() {
|
|
38
|
+
await fs.mkdir(documentsDir, { recursive: true });
|
|
39
|
+
const files = await fs.readdir(documentsDir);
|
|
40
|
+
const docs = [];
|
|
41
|
+
for (const file of files) {
|
|
42
|
+
if (!file.endsWith('.json')) continue;
|
|
43
|
+
try {
|
|
44
|
+
const raw = await fs.readFile(path.join(documentsDir, file), 'utf8');
|
|
45
|
+
docs.push(JSON.parse(raw));
|
|
46
|
+
} catch {
|
|
47
|
+
// skip corrupt files
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return docs;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default async function docsPlugin(fastify, options) {
|
|
54
|
+
const prefix = '';
|
|
55
|
+
const {authenticate} = options.auth;
|
|
56
|
+
const config = {...defaultConfig, ...(options.settings || {})};
|
|
57
|
+
|
|
58
|
+
// -------------------------
|
|
59
|
+
// Documents
|
|
60
|
+
// -------------------------
|
|
61
|
+
|
|
62
|
+
// GET /documents
|
|
63
|
+
fastify.get(`${prefix}/documents`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
64
|
+
const {folder, q} = req.query;
|
|
65
|
+
let docs = await listDocs();
|
|
66
|
+
|
|
67
|
+
if (config.scope === 'user') {
|
|
68
|
+
docs = docs.filter(d => d.userId === req.user.id);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (folder !== undefined) {
|
|
72
|
+
docs = docs.filter(d => (folder === '' || folder === 'null' ? !d.folderId : d.folderId === folder));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (q) {
|
|
76
|
+
const term = q.toLowerCase();
|
|
77
|
+
docs = docs.filter(d =>
|
|
78
|
+
(d.title || '').toLowerCase().includes(term) ||
|
|
79
|
+
(d.content || '').toLowerCase().includes(term)
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
docs.sort((a, b) => new Date(b.updatedAt) - new Date(a.updatedAt));
|
|
84
|
+
return reply.send(docs);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// POST /documents
|
|
88
|
+
fastify.post(`${prefix}/documents`, { preHandler: [authenticate] }, async (req, reply) => {
|
|
89
|
+
const { title = 'Untitled', content = '', folderId = null, tags = [] } = req.body || {};
|
|
90
|
+
const now = new Date().toISOString();
|
|
91
|
+
const doc = {
|
|
92
|
+
id: randomUUID(),
|
|
93
|
+
title,
|
|
94
|
+
content,
|
|
95
|
+
folderId: folderId || null,
|
|
96
|
+
tags,
|
|
97
|
+
userId: req.user.id,
|
|
98
|
+
wordCount: countWords(content),
|
|
99
|
+
createdAt: now,
|
|
100
|
+
updatedAt: now
|
|
101
|
+
};
|
|
102
|
+
await writeDoc(doc);
|
|
103
|
+
return reply.code(201).send(doc);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// GET /documents/:id
|
|
107
|
+
fastify.get(`${prefix}/documents/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
108
|
+
const doc = await readDoc(req.params.id);
|
|
109
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
110
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
111
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
112
|
+
}
|
|
113
|
+
return reply.send(doc);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// PUT /documents/:id
|
|
117
|
+
fastify.put(`${prefix}/documents/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
118
|
+
const doc = await readDoc(req.params.id);
|
|
119
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
120
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
121
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const body = req.body || {};
|
|
125
|
+
|
|
126
|
+
// Auto-create version if content changed
|
|
127
|
+
if (body.content !== undefined && body.content !== doc.content) {
|
|
128
|
+
const docVersionsDir = path.join(versionsDir, doc.id);
|
|
129
|
+
await fs.mkdir(docVersionsDir, { recursive: true });
|
|
130
|
+
const existing = await fs.readdir(docVersionsDir).catch(() => []);
|
|
131
|
+
const nums = existing.map(f => parseInt(f)).filter(n => !isNaN(n));
|
|
132
|
+
const nextNum = nums.length ? Math.max(...nums) + 1 : 1;
|
|
133
|
+
if (nextNum <= (config.maxVersions || 50)) {
|
|
134
|
+
await fs.writeFile(
|
|
135
|
+
path.join(docVersionsDir, `${nextNum}.json`),
|
|
136
|
+
JSON.stringify({ num: nextNum, content: doc.content, createdAt: new Date().toISOString() }, null, 2)
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const updated = {
|
|
142
|
+
...doc,
|
|
143
|
+
title: body.title !== undefined ? body.title : doc.title,
|
|
144
|
+
content: body.content !== undefined ? body.content : doc.content,
|
|
145
|
+
folderId: body.folderId !== undefined ? body.folderId : doc.folderId,
|
|
146
|
+
tags: body.tags !== undefined ? body.tags : doc.tags,
|
|
147
|
+
updatedAt: new Date().toISOString()
|
|
148
|
+
};
|
|
149
|
+
updated.wordCount = countWords(updated.content);
|
|
150
|
+
await writeDoc(updated);
|
|
151
|
+
return reply.send(updated);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// DELETE /documents/:id
|
|
155
|
+
fastify.delete(`${prefix}/documents/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
156
|
+
const doc = await readDoc(req.params.id);
|
|
157
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
158
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
159
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
160
|
+
}
|
|
161
|
+
// Delete doc file
|
|
162
|
+
await fs.rm(path.join(documentsDir, `${doc.id}.json`), { force: true });
|
|
163
|
+
// Delete all versions
|
|
164
|
+
await fs.rm(path.join(versionsDir, doc.id), { recursive: true, force: true });
|
|
165
|
+
return reply.send({ ok: true });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// POST /documents/:id/duplicate
|
|
169
|
+
fastify.post(`${prefix}/documents/:id/duplicate`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
170
|
+
const doc = await readDoc(req.params.id);
|
|
171
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
172
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
173
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
174
|
+
}
|
|
175
|
+
const now = new Date().toISOString();
|
|
176
|
+
const copy = {
|
|
177
|
+
...doc,
|
|
178
|
+
id: randomUUID(),
|
|
179
|
+
title: `${doc.title} (Copy)`,
|
|
180
|
+
createdAt: now,
|
|
181
|
+
updatedAt: now
|
|
182
|
+
};
|
|
183
|
+
await writeDoc(copy);
|
|
184
|
+
return reply.code(201).send(copy);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// -------------------------
|
|
188
|
+
// Versions
|
|
189
|
+
// -------------------------
|
|
190
|
+
|
|
191
|
+
// GET /documents/:id/versions
|
|
192
|
+
fastify.get(`${prefix}/documents/:id/versions`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
193
|
+
const doc = await readDoc(req.params.id);
|
|
194
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
195
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
196
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const docVersionsDir = path.join(versionsDir, doc.id);
|
|
200
|
+
const files = await fs.readdir(docVersionsDir).catch(() => []);
|
|
201
|
+
const versions = [];
|
|
202
|
+
for (const file of files) {
|
|
203
|
+
if (!file.endsWith('.json')) continue;
|
|
204
|
+
try {
|
|
205
|
+
const raw = await fs.readFile(path.join(docVersionsDir, file), 'utf8');
|
|
206
|
+
versions.push(JSON.parse(raw));
|
|
207
|
+
} catch {
|
|
208
|
+
// skip
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
versions.sort((a, b) => b.num - a.num);
|
|
212
|
+
return reply.send(versions);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// GET /documents/:id/versions/:num
|
|
216
|
+
fastify.get(`${prefix}/documents/:id/versions/:num`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
217
|
+
const doc = await readDoc(req.params.id);
|
|
218
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
219
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
220
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const versionFile = path.join(versionsDir, doc.id, `${req.params.num}.json`);
|
|
224
|
+
try {
|
|
225
|
+
const raw = await fs.readFile(versionFile, 'utf8');
|
|
226
|
+
return reply.send(JSON.parse(raw));
|
|
227
|
+
} catch {
|
|
228
|
+
return reply.code(404).send({ error: 'Version not found' });
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// POST /documents/:id/versions/:num/restore
|
|
233
|
+
fastify.post(`${prefix}/documents/:id/versions/:num/restore`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
234
|
+
const doc = await readDoc(req.params.id);
|
|
235
|
+
if (!doc) return reply.code(404).send({ error: 'Document not found' });
|
|
236
|
+
if (config.scope === 'user' && doc.userId !== req.user.id) {
|
|
237
|
+
return reply.code(404).send({ error: 'Document not found' });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const versionFile = path.join(versionsDir, doc.id, `${req.params.num}.json`);
|
|
241
|
+
let version;
|
|
242
|
+
try {
|
|
243
|
+
const raw = await fs.readFile(versionFile, 'utf8');
|
|
244
|
+
version = JSON.parse(raw);
|
|
245
|
+
} catch {
|
|
246
|
+
return reply.code(404).send({ error: 'Version not found' });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Save current state as a new version first
|
|
250
|
+
const docVersionsDir = path.join(versionsDir, doc.id);
|
|
251
|
+
await fs.mkdir(docVersionsDir, { recursive: true });
|
|
252
|
+
const existing = await fs.readdir(docVersionsDir).catch(() => []);
|
|
253
|
+
const nums = existing.map(f => parseInt(f)).filter(n => !isNaN(n));
|
|
254
|
+
const nextNum = nums.length ? Math.max(...nums) + 1 : 1;
|
|
255
|
+
if (nextNum <= (config.maxVersions || 50)) {
|
|
256
|
+
await fs.writeFile(
|
|
257
|
+
path.join(docVersionsDir, `${nextNum}.json`),
|
|
258
|
+
JSON.stringify({ num: nextNum, content: doc.content, createdAt: new Date().toISOString() }, null, 2)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Restore
|
|
263
|
+
const restored = {
|
|
264
|
+
...doc,
|
|
265
|
+
content: version.content,
|
|
266
|
+
wordCount: countWords(version.content),
|
|
267
|
+
updatedAt: new Date().toISOString()
|
|
268
|
+
};
|
|
269
|
+
await writeDoc(restored);
|
|
270
|
+
return reply.send(restored);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
// -------------------------
|
|
274
|
+
// Folders
|
|
275
|
+
// -------------------------
|
|
276
|
+
|
|
277
|
+
// GET /folders
|
|
278
|
+
fastify.get(`${prefix}/folders`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
279
|
+
let folders = await foldersStore.readArray();
|
|
280
|
+
if (config.scope === 'user') {
|
|
281
|
+
folders = folders.filter(f => f.userId === req.user.id);
|
|
282
|
+
}
|
|
283
|
+
return reply.send(folders);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// POST /folders
|
|
287
|
+
fastify.post(`${prefix}/folders`, { preHandler: [authenticate] }, async (req, reply) => {
|
|
288
|
+
const { name, parentId = null } = req.body || {};
|
|
289
|
+
if (!name || !name.trim()) return reply.code(400).send({ error: 'Name is required' });
|
|
290
|
+
const folder = {
|
|
291
|
+
id: randomUUID(),
|
|
292
|
+
name: name.trim(),
|
|
293
|
+
parentId: parentId || null,
|
|
294
|
+
userId: req.user.id,
|
|
295
|
+
createdAt: new Date().toISOString()
|
|
296
|
+
};
|
|
297
|
+
await foldersStore.appendItem(folder);
|
|
298
|
+
return reply.code(201).send(folder);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// PUT /folders/:id
|
|
302
|
+
fastify.put(`${prefix}/folders/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
303
|
+
const folders = await foldersStore.readArray();
|
|
304
|
+
const folder = folders.find(f => f.id === req.params.id);
|
|
305
|
+
if (!folder) return reply.code(404).send({ error: 'Folder not found' });
|
|
306
|
+
if (config.scope === 'user' && folder.userId !== req.user.id) {
|
|
307
|
+
return reply.code(404).send({ error: 'Folder not found' });
|
|
308
|
+
}
|
|
309
|
+
const { name } = req.body || {};
|
|
310
|
+
if (!name || !name.trim()) return reply.code(400).send({ error: 'Name is required' });
|
|
311
|
+
const updated = await foldersStore.updateItem(req.params.id, { name: name.trim() });
|
|
312
|
+
return reply.send(updated);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// DELETE /folders/:id
|
|
316
|
+
fastify.delete(`${prefix}/folders/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
317
|
+
const folders = await foldersStore.readArray();
|
|
318
|
+
const folder = folders.find(f => f.id === req.params.id);
|
|
319
|
+
if (!folder) return reply.code(404).send({ error: 'Folder not found' });
|
|
320
|
+
if (config.scope === 'user' && folder.userId !== req.user.id) {
|
|
321
|
+
return reply.code(404).send({ error: 'Folder not found' });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Move docs in this folder to root
|
|
325
|
+
const docs = await listDocs();
|
|
326
|
+
for (const doc of docs) {
|
|
327
|
+
if (doc.folderId === req.params.id) {
|
|
328
|
+
await writeDoc({ ...doc, folderId: null, updatedAt: new Date().toISOString() });
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
await foldersStore.deleteItem(req.params.id);
|
|
333
|
+
return reply.send({ ok: true });
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// -------------------------
|
|
337
|
+
// Templates
|
|
338
|
+
// -------------------------
|
|
339
|
+
|
|
340
|
+
// GET /templates
|
|
341
|
+
fastify.get(`${prefix}/templates`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
342
|
+
let templates = await templatesStore.readArray();
|
|
343
|
+
if (config.scope === 'user') {
|
|
344
|
+
templates = templates.filter(t => t.userId === req.user.id);
|
|
345
|
+
}
|
|
346
|
+
return reply.send(templates);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// POST /templates
|
|
350
|
+
fastify.post(`${prefix}/templates`, { preHandler: [authenticate] }, async (req, reply) => {
|
|
351
|
+
const { name, content = '' } = req.body || {};
|
|
352
|
+
if (!name || !name.trim()) return reply.code(400).send({ error: 'Name is required' });
|
|
353
|
+
const template = {
|
|
354
|
+
id: randomUUID(),
|
|
355
|
+
name: name.trim(),
|
|
356
|
+
content,
|
|
357
|
+
userId: req.user.id,
|
|
358
|
+
createdAt: new Date().toISOString()
|
|
359
|
+
};
|
|
360
|
+
await templatesStore.appendItem(template);
|
|
361
|
+
return reply.code(201).send(template);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// DELETE /templates/:id
|
|
365
|
+
fastify.delete(`${prefix}/templates/:id`, {preHandler: [authenticate]}, async (req, reply) => {
|
|
366
|
+
const templates = await templatesStore.readArray();
|
|
367
|
+
const template = templates.find(t => t.id === req.params.id);
|
|
368
|
+
if (!template) return reply.code(404).send({ error: 'Template not found' });
|
|
369
|
+
if (config.scope === 'user' && template.userId !== req.user.id) {
|
|
370
|
+
return reply.code(404).send({ error: 'Template not found' });
|
|
371
|
+
}
|
|
372
|
+
await templatesStore.deleteItem(req.params.id);
|
|
373
|
+
return reply.send({ ok: true });
|
|
374
|
+
});
|
|
375
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docs",
|
|
3
|
+
"displayName": "Docs",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Document editor with folders, version history, templates, and find & replace.",
|
|
6
|
+
"author": "Darryl Waterhouse",
|
|
7
|
+
"date": "2026-03-24",
|
|
8
|
+
"icon": "book-open",
|
|
9
|
+
"admin": {
|
|
10
|
+
"sidebar": [
|
|
11
|
+
{ "id": "docs", "text": "Docs", "icon": "book-open", "url": "#/plugins/docs", "section": "#/plugins/docs" }
|
|
12
|
+
],
|
|
13
|
+
"routes": [
|
|
14
|
+
{ "path": "/plugins/docs", "view": "plugin-docs", "title": "Docs - Domma CMS" }
|
|
15
|
+
],
|
|
16
|
+
"views": {
|
|
17
|
+
"plugin-docs": {
|
|
18
|
+
"entry": "docs/admin/views/docs.js",
|
|
19
|
+
"exportName": "docsView"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<div class="notes-plugin-wrap" style="padding: 24px; max-width: 1200px;">
|
|
2
|
+
|
|
3
|
+
<!-- Toolbar -->
|
|
4
|
+
<div class="notes-toolbar" style="display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:20px;">
|
|
5
|
+
<h2 style="margin:0;flex:0 0 auto;font-size:1.4rem;">
|
|
6
|
+
<span data-icon="file-text" data-icon-size="20" style="margin-right:8px;"></span>Notes
|
|
7
|
+
</h2>
|
|
8
|
+
<input
|
|
9
|
+
id="notes-search"
|
|
10
|
+
type="search"
|
|
11
|
+
class="form-input"
|
|
12
|
+
placeholder="Search notes…"
|
|
13
|
+
style="flex:1;min-width:180px;max-width:320px;"
|
|
14
|
+
/>
|
|
15
|
+
<button id="new-note-btn" class="btn btn-primary" style="flex-shrink:0;">
|
|
16
|
+
<span data-icon="plus" data-icon-size="15" style="margin-right:6px;"></span>New Note
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<!-- Category filter -->
|
|
21
|
+
<div id="category-filter" style="display:flex;flex-wrap:wrap;gap:6px;margin-bottom:18px;"></div>
|
|
22
|
+
|
|
23
|
+
<!-- Notes grid -->
|
|
24
|
+
<div
|
|
25
|
+
id="notes-grid"
|
|
26
|
+
style="display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px;"
|
|
27
|
+
></div>
|
|
28
|
+
|
|
29
|
+
<!-- Empty state -->
|
|
30
|
+
<div id="notes-empty" style="display:none;text-align:center;padding:60px 20px;opacity:0.6;">
|
|
31
|
+
<span data-icon="file-text" data-icon-size="48" style="display:block;margin-bottom:12px;"></span>
|
|
32
|
+
<p style="font-size:1rem;margin:0;">No notes yet. Click <strong>New Note</strong> to get started.</p>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<!-- Editor overlay -->
|
|
36
|
+
<div
|
|
37
|
+
id="note-editor"
|
|
38
|
+
style="display:none;position:fixed;inset:0;z-index:1000;background:rgba(0,0,0,0.45);
|
|
39
|
+
align-items:center;justify-content:center;padding:20px;"
|
|
40
|
+
>
|
|
41
|
+
<div class="card" style="width:100%;max-width:640px;max-height:90vh;display:flex;flex-direction:column;">
|
|
42
|
+
<div class="card-header" style="display:flex;align-items:center;justify-content:space-between;padding:16px 20px;">
|
|
43
|
+
<strong style="font-size:1rem;">Edit Note</strong>
|
|
44
|
+
<button id="cancel-note-btn" class="btn btn-sm btn-secondary" title="Close">
|
|
45
|
+
<span data-icon="x" data-icon-size="15"></span>
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="card-body" style="flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:14px;">
|
|
49
|
+
<div>
|
|
50
|
+
<label for="note-title" class="form-label" style="font-weight:500;margin-bottom:4px;display:block;">Title</label>
|
|
51
|
+
<input
|
|
52
|
+
id="note-title"
|
|
53
|
+
type="text"
|
|
54
|
+
class="form-input"
|
|
55
|
+
placeholder="Note title…"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
<div style="flex:1;display:flex;flex-direction:column;">
|
|
59
|
+
<label for="note-content" class="form-label" style="font-weight:500;margin-bottom:4px;display:block;">Content</label>
|
|
60
|
+
<textarea
|
|
61
|
+
id="note-content"
|
|
62
|
+
class="form-input"
|
|
63
|
+
placeholder="Write your note here… (Ctrl+Enter to save)"
|
|
64
|
+
style="flex:1;min-height:220px;resize:vertical;font-family:inherit;"
|
|
65
|
+
></textarea>
|
|
66
|
+
</div>
|
|
67
|
+
<div>
|
|
68
|
+
<label for="note-categories" class="form-label" style="font-weight:500;margin-bottom:4px;display:block;">Categories</label>
|
|
69
|
+
<input
|
|
70
|
+
id="note-categories"
|
|
71
|
+
type="text"
|
|
72
|
+
class="form-input"
|
|
73
|
+
placeholder="Comma-separated, e.g. work, ideas, personal"
|
|
74
|
+
/>
|
|
75
|
+
<small style="opacity:0.6;margin-top:4px;display:block;">Separate multiple categories with commas.</small>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="card-footer" style="display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 20px;">
|
|
79
|
+
<button id="delete-note-btn" class="btn btn-danger btn-sm" style="display:none;">
|
|
80
|
+
<span data-icon="trash" data-icon-size="13" style="margin-right:5px;"></span>Delete
|
|
81
|
+
</button>
|
|
82
|
+
<div style="display:flex;gap:8px;margin-left:auto;">
|
|
83
|
+
<button id="cancel-note-btn-footer" class="btn btn-secondary btn-sm">Cancel</button>
|
|
84
|
+
<button id="save-note-btn" class="btn btn-primary btn-sm">
|
|
85
|
+
<span data-icon="save" data-icon-size="13" style="margin-right:5px;"></span>Save
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
</div>
|