fix: parse hashtags only on blur/submit, add tag delete UI

- Parse hashtags when content textarea loses focus (blur)
- Parse hashtags when QuickCapture form is submitted
- Add tag display with delete buttons in expanded entry view
- Remove automatic hashtag parsing during typing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Thomas Richter
2026-02-01 22:27:02 +01:00
parent 4a57000c38
commit 79c9b12702
3 changed files with 118 additions and 14 deletions

View File

@@ -54,12 +54,6 @@ export const actions: Actions = {
type: type || 'thought'
});
// Parse hashtags from content and save them
const hashtags = parseHashtags(content);
if (hashtags.length > 0) {
tagRepository.updateEntryTags(entry.id, hashtags);
}
return { success: true, entryId: entry.id };
},
@@ -115,12 +109,6 @@ export const actions: Actions = {
entryRepository.update(id, updates);
// Re-parse hashtags if content changed
if (contentChanged && updates.content) {
const hashtags = parseHashtags(updates.content as string);
tagRepository.updateEntryTags(id, hashtags);
}
return { success: true };
},
@@ -303,5 +291,55 @@ export const actions: Actions = {
} catch {
return fail(400, { error: 'Invalid tags format' });
}
},
parseTags: async ({ request }) => {
const formData = await request.formData();
const id = formData.get('id')?.toString();
if (!id) {
return fail(400, { error: 'Entry ID is required' });
}
const existing = entryRepository.getById(id);
if (!existing) {
return fail(404, { error: 'Entry not found' });
}
// Parse hashtags from current content and merge with existing tags
const newTags = parseHashtags(existing.content);
const existingTags = tagRepository.getByEntryId(id).map((t) => t.name.toLowerCase());
const allTags = [...new Set([...existingTags, ...newTags])];
tagRepository.updateEntryTags(id, allTags);
return { success: true };
},
removeTag: async ({ request }) => {
const formData = await request.formData();
const id = formData.get('id')?.toString();
const tagName = formData.get('tagName')?.toString();
if (!id) {
return fail(400, { error: 'Entry ID is required' });
}
if (!tagName) {
return fail(400, { error: 'Tag name is required' });
}
const existing = entryRepository.getById(id);
if (!existing) {
return fail(404, { error: 'Entry not found' });
}
// Get current tags and remove the specified one
const currentTags = tagRepository.getByEntryId(id).map((t) => t.name);
const updatedTags = currentTags.filter(
(t) => t.toLowerCase() !== tagName.toLowerCase()
);
tagRepository.updateEntryTags(id, updatedTags);
return { success: true };
}
};