fix: explicit tag scanning with delete UI
- Remove auto-parsing on collapse - Add "Scan for #tags" button that parses from current textarea content - Always show tags section with delete buttons - Show help text when no tags exist Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,11 +128,9 @@
|
||||
debouncedSave();
|
||||
}
|
||||
|
||||
async function toggleExpand() {
|
||||
function toggleExpand() {
|
||||
if (expanded) {
|
||||
// Collapsing - parse hashtags from content
|
||||
await handleParseTags();
|
||||
// Reset edit state to current entry values
|
||||
// Collapsing - reset edit state to current entry values
|
||||
editTitle = entry.title || '';
|
||||
editContent = entry.content;
|
||||
editType = entry.type;
|
||||
@@ -210,9 +208,10 @@
|
||||
}
|
||||
|
||||
async function handleParseTags() {
|
||||
// Parse hashtags from content
|
||||
// Parse hashtags from current content in textarea
|
||||
const formData = new FormData();
|
||||
formData.append('id', entry.id);
|
||||
formData.append('content', editContent);
|
||||
|
||||
await fetch('?/parseTags', {
|
||||
method: 'POST',
|
||||
@@ -520,9 +519,18 @@
|
||||
</div>
|
||||
|
||||
<!-- Tags section -->
|
||||
{#if entry.tags?.length > 0}
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">Tags</label>
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-medium text-gray-700">Tags</label>
|
||||
<button
|
||||
type="button"
|
||||
onclick={handleParseTags}
|
||||
class="text-sm text-blue-600 hover:text-blue-700"
|
||||
>
|
||||
Scan for #tags
|
||||
</button>
|
||||
</div>
|
||||
{#if entry.tags?.length > 0}
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{#each entry.tags as tag}
|
||||
<span class="inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-700 rounded-full text-sm">
|
||||
@@ -540,8 +548,10 @@
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<p class="text-sm text-gray-500">No tags. Use #hashtags in content and click "Scan for #tags".</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
|
||||
@@ -296,6 +296,7 @@ export const actions: Actions = {
|
||||
parseTags: async ({ request }) => {
|
||||
const formData = await request.formData();
|
||||
const id = formData.get('id')?.toString();
|
||||
const content = formData.get('content')?.toString();
|
||||
|
||||
if (!id) {
|
||||
return fail(400, { error: 'Entry ID is required' });
|
||||
@@ -306,8 +307,9 @@ export const actions: Actions = {
|
||||
return fail(404, { error: 'Entry not found' });
|
||||
}
|
||||
|
||||
// Parse hashtags from current content and merge with existing tags
|
||||
const newTags = parseHashtags(existing.content);
|
||||
// Parse hashtags from provided content (or fall back to database content)
|
||||
const textToParse = content ?? existing.content;
|
||||
const newTags = parseHashtags(textToParse);
|
||||
const existingTags = tagRepository.getByEntryId(id).map((t) => t.name.toLowerCase());
|
||||
const allTags = [...new Set([...existingTags, ...newTags])];
|
||||
tagRepository.updateEntryTags(id, allTags);
|
||||
|
||||
Reference in New Issue
Block a user