buddy-workbench 0.1.103 → 0.1.104
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/package.json +1 -1
- package/server/routes/clipboard.js +2 -1
- package/server/services/clipboard-history.js +40 -4
- package/ui/dist/assets/index-B42QH0U9.js +596 -0
- package/ui/dist/assets/index-wYHxbQof.css +1 -0
- package/ui/dist/assets/{xmindAdapter-EBLxkv6_.js → xmindAdapter-986W7fJ6.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/ui/dist/sw.js +2 -2
- package/ui/dist/assets/index-D3H0JsaL.js +0 -596
- package/ui/dist/assets/index-DFWISIW6.css +0 -1
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import express, { Router } from 'express';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
-
import { clipboardDates, clipboardItems, clipboardOriginal, deleteClipboardItem, saveClipboardImage, clipboardImagePath, allTaggedClipboardItems, updateClipboardItemTags, markClipboardCopied, copyClipboardImage } from '../services/clipboard-history.js';
|
|
3
|
+
import { clipboardDates, clipboardItems, searchClipboardItems, clipboardOriginal, deleteClipboardItem, saveClipboardImage, clipboardImagePath, allTaggedClipboardItems, updateClipboardItemTags, markClipboardCopied, copyClipboardImage } from '../services/clipboard-history.js';
|
|
4
4
|
|
|
5
5
|
const router = Router();
|
|
6
6
|
router.get('/', (req, res) => res.json({ dates: clipboardDates(), items: clipboardItems(req.query.date) }));
|
|
7
|
+
router.get('/search', (req, res) => res.json({ items: searchClipboardItems(req.query.q) }));
|
|
7
8
|
router.get('/tagged', (_req, res) => res.json({ items: allTaggedClipboardItems() }));
|
|
8
9
|
|
|
9
10
|
router.post('/image', express.raw({ type: 'image/*', limit: '10mb' }), (req, res) => {
|
|
@@ -210,6 +210,36 @@ function getEditorUrl(editor = 'vscode', path = '') {
|
|
|
210
210
|
|
|
211
211
|
function dayItems(date) { return readJson(dayFile(date), []); }
|
|
212
212
|
|
|
213
|
+
function getClipboardEditorDetails() {
|
|
214
|
+
const settings = readSettings();
|
|
215
|
+
const editor = settings.defaultEditor || 'vscode';
|
|
216
|
+
return {
|
|
217
|
+
editor,
|
|
218
|
+
editorName: editor === 'idea' ? 'IntelliJ IDEA' : editor === 'devin' ? 'Devin' : 'VS Code'
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function withClipboardEditorDetails(item, date, editorDetails) {
|
|
223
|
+
const itemWithDate = date ? { ...item, date } : item;
|
|
224
|
+
if (!item.contentFile) return itemWithDate;
|
|
225
|
+
const { editor, editorName } = editorDetails || getClipboardEditorDetails();
|
|
226
|
+
return {
|
|
227
|
+
...itemWithDate,
|
|
228
|
+
editorUrl: getEditorUrl(editor, join(paths.clipboardDir, 'content', item.contentFile)),
|
|
229
|
+
editorName
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function clipboardSearchValue(item) {
|
|
234
|
+
const values = [item.text, item.preview, ...(Array.isArray(item.tags) ? item.tags : [])];
|
|
235
|
+
if (item.contentFile) {
|
|
236
|
+
try {
|
|
237
|
+
values.push(readFileSync(join(paths.clipboardDir, 'content', item.contentFile), 'utf8'));
|
|
238
|
+
} catch {}
|
|
239
|
+
}
|
|
240
|
+
return values.filter(Boolean).join('\n').toLowerCase();
|
|
241
|
+
}
|
|
242
|
+
|
|
213
243
|
async function getClipboardText() {
|
|
214
244
|
if (process.platform === 'win32') {
|
|
215
245
|
try { return await readWindowsClipboard(); } catch { return ''; }
|
|
@@ -237,10 +267,16 @@ async function getClipboardText() {
|
|
|
237
267
|
}
|
|
238
268
|
|
|
239
269
|
export function clipboardItems(date = today()) {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
270
|
+
const editorDetails = getClipboardEditorDetails();
|
|
271
|
+
return dayItems(date).map((item) => withClipboardEditorDetails(item, undefined, editorDetails));
|
|
272
|
+
}
|
|
273
|
+
export function searchClipboardItems(query) {
|
|
274
|
+
const normalizedQuery = String(query || '').trim().toLowerCase();
|
|
275
|
+
if (!normalizedQuery) return [];
|
|
276
|
+
const editorDetails = getClipboardEditorDetails();
|
|
277
|
+
return clipboardDates().flatMap((date) => dayItems(date)
|
|
278
|
+
.filter((item) => clipboardSearchValue(item).includes(normalizedQuery))
|
|
279
|
+
.map((item) => withClipboardEditorDetails(item, date, editorDetails)));
|
|
244
280
|
}
|
|
245
281
|
export function allTaggedClipboardItems() {
|
|
246
282
|
const settings = readSettings();
|