From 6116069fff53f55514cdc548f5725319c62caae2 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Sun, 22 Feb 2026 16:13:25 +0100 Subject: [PATCH] ui optimizations --- ka-note/VERSION | 2 +- ka-note/client/src/lib/actions/mentionCore.ts | 11 ++++--- ka-note/client/src/lib/actions/refClick.ts | 3 +- .../lib/components/EditableMarkdown.svelte | 1 + .../src/lib/components/HistoryItem.svelte | 1 + .../src/lib/components/MarkdownEditor.svelte | 31 ++++++++++++++----- .../src/lib/components/TopicCard.svelte | 10 ++++-- .../client/src/lib/editor/tiptapMention.ts | 3 +- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/ka-note/VERSION b/ka-note/VERSION index f8b811d..ee52711 100644 --- a/ka-note/VERSION +++ b/ka-note/VERSION @@ -1 +1 @@ -1.0.41 \ No newline at end of file +1.0.50 \ No newline at end of file diff --git a/ka-note/client/src/lib/actions/mentionCore.ts b/ka-note/client/src/lib/actions/mentionCore.ts index 6d66947..37e5dc3 100644 --- a/ka-note/client/src/lib/actions/mentionCore.ts +++ b/ka-note/client/src/lib/actions/mentionCore.ts @@ -39,7 +39,7 @@ export async function fetchMentionItems(query: string): Promise<{ items: Mention .filter(c => !c.deletedAt && !c.archivedAt && (c.type === 'person' || c.type === 'project' || c.type === 'company')) .toArray(); - const q = query.toLowerCase(); + const q = query.replace(/_/g, ' ').toLowerCase(); const items = all .map(buildMentionItem) .filter(m => m.mentionName.toLowerCase().includes(q)) @@ -48,10 +48,11 @@ export async function fetchMentionItems(query: string): Promise<{ items: Mention const exactMatch = items.some(m => m.mentionName.toLowerCase() === q); const createOptions: CreateOption[] = []; if (query.length > 0 && !exactMatch) { + const displayName = query.replace(/_/g, ' '); createOptions.push( - { type: 'person', label: `+ Person "${query}" anlegen`, query }, - { type: 'project', label: `+ Projekt "${query}" anlegen`, query }, - { type: 'company', label: `+ Firma "${query}" anlegen`, query } + { type: 'person', label: `+ Person "${displayName}" anlegen`, query }, + { type: 'project', label: `+ Projekt "${displayName}" anlegen`, query }, + { type: 'company', label: `+ Firma "${displayName}" anlegen`, query } ); } @@ -59,7 +60,7 @@ export async function fetchMentionItems(query: string): Promise<{ items: Mention } export async function createMentionContext(opt: CreateOption): Promise { - const name = opt.query; + const name = opt.query.replace(/_/g, ' '); const slug = name.toLowerCase().replace(/\s+/g, '-'); const id = opt.type === 'company' ? `f-${slug}` : opt.type === 'person' ? `u-${slug}` : `p-${slug}`; const contextName = opt.type === 'company' ? `Firma ${name}` : opt.type === 'person' ? `Person ${name}` : `Project ${name}`; diff --git a/ka-note/client/src/lib/actions/refClick.ts b/ka-note/client/src/lib/actions/refClick.ts index 3616f60..c346fbb 100644 --- a/ka-note/client/src/lib/actions/refClick.ts +++ b/ka-note/client/src/lib/actions/refClick.ts @@ -158,7 +158,8 @@ function showCreatePopup(name: string, type: 'person' | 'project' | 'company', x async function handlePersonClick(name: string, event: MouseEvent, sourceEl: HTMLElement) { const ctx = await findContextByMentionName(name, 'person'); if (ctx) { - const ratingCtx = findRatingContext(sourceEl); + const isEmployee = (ctx.meta as Record | null)?.personSubType === 'employee'; + const ratingCtx = isEmployee ? findRatingContext(sourceEl) : null; showPersonPopup(name, ctx.id, ratingCtx, event.clientX, event.clientY, sourceEl); } else { showCreatePopup(name, 'person', event.clientX, event.clientY); diff --git a/ka-note/client/src/lib/components/EditableMarkdown.svelte b/ka-note/client/src/lib/components/EditableMarkdown.svelte index 85fb1ba..38608a2 100644 --- a/ka-note/client/src/lib/components/EditableMarkdown.svelte +++ b/ka-note/client/src/lib/components/EditableMarkdown.svelte @@ -63,6 +63,7 @@ {placeholder} {minHeight} onchange={(md) => editorContent = md} + onsave={save} /> {:else} diff --git a/ka-note/client/src/lib/components/HistoryItem.svelte b/ka-note/client/src/lib/components/HistoryItem.svelte index abe8d92..01ffd92 100644 --- a/ka-note/client/src/lib/components/HistoryItem.svelte +++ b/ka-note/client/src/lib/components/HistoryItem.svelte @@ -43,6 +43,7 @@ editText = md} + onsave={saveEdit} minHeight="100px" />
diff --git a/ka-note/client/src/lib/components/MarkdownEditor.svelte b/ka-note/client/src/lib/components/MarkdownEditor.svelte index 09cf3a8..14a9e29 100644 --- a/ka-note/client/src/lib/components/MarkdownEditor.svelte +++ b/ka-note/client/src/lib/components/MarkdownEditor.svelte @@ -14,8 +14,10 @@ placeholder?: string; minHeight?: string; onchange?: (markdown: string) => void; + onsave?: () => void; + onsavearchive?: () => void; } - let { content = '', placeholder = '', minHeight = '80px', onchange }: Props = $props(); + let { content = '', placeholder = '', minHeight = '80px', onchange, onsave, onsavearchive }: Props = $props(); let element: HTMLDivElement; let editor: Editor | null = null; @@ -42,7 +44,7 @@ onchange?.(md); } - async function handlePaste(_view: any, event: ClipboardEvent): Promise { + function handlePaste(_view: any, event: ClipboardEvent): boolean { const items = event.clipboardData?.items; if (!items) return false; @@ -50,12 +52,14 @@ if (item.type.startsWith('image/')) { event.preventDefault(); const blob = item.getAsFile(); - if (!blob) continue; - - const id = await storeImage(blob); - const url = await getImageUrl(id); - if (url && editor) { - editor.chain().focus().setImage({ src: url }).run(); + if (blob) { + storeImage(blob) + .then((id) => getImageUrl(id)) + .then((url) => { + if (url && editor) { + editor.chain().focus().setImage({ src: url }).run(); + } + }); } return true; } @@ -82,6 +86,17 @@ content: initialContent, editorProps: { handlePaste, + handleKeyDown: (_view, event) => { + if (event.key === 'Enter' && (event.ctrlKey || event.metaKey) && event.shiftKey) { + onsavearchive?.(); + return true; + } + if (event.key === 'Enter' && (event.ctrlKey || event.metaKey)) { + onsave?.(); + return true; + } + return false; + }, attributes: { style: `min-height: ${minHeight}` } diff --git a/ka-note/client/src/lib/components/TopicCard.svelte b/ka-note/client/src/lib/components/TopicCard.svelte index 0e3b845..061c1ad 100644 --- a/ka-note/client/src/lib/components/TopicCard.svelte +++ b/ka-note/client/src/lib/components/TopicCard.svelte @@ -187,9 +187,11 @@ > {/if} {#if isProcessed} - BESPROCHEN { e.stopPropagation(); processedTopicIds.remove(topic.id); }} + >BESPROCHEN {/if}
@@ -212,6 +214,8 @@ bind:this={noteEditor} placeholder="- Notiz... (z.B. '-> NAME' or '@P:PROJECT')" onchange={(md) => (noteText = md)} + onsave={handleSaveOnly} + onsavearchive={handleDone} /> {#if showDailyControls} diff --git a/ka-note/client/src/lib/editor/tiptapMention.ts b/ka-note/client/src/lib/editor/tiptapMention.ts index d9a48d8..8bf8c8c 100644 --- a/ka-note/client/src/lib/editor/tiptapMention.ts +++ b/ka-note/client/src/lib/editor/tiptapMention.ts @@ -93,7 +93,8 @@ export const TiptapMention = Extension.create({ const opt = createOptions[index - items.length]; if (!opt) return; await createMentionContext(opt); - const tag = opt.type === 'company' ? quoteMention('@F:', opt.query) : opt.type === 'person' ? quoteMention('@', opt.query) : quoteMention('@P:', opt.query); + const displayName = opt.query.replace(/_/g, ' '); + const tag = opt.type === 'company' ? quoteMention('@F:', displayName) : opt.type === 'person' ? quoteMention('@', displayName) : quoteMention('@P:', displayName); console.log('[tiptap-mention] inserting after create:', tag); editor.chain().focus() .deleteRange({ from: savedFrom, to: savedTo })