@memberjunction/ng-conversations 5.44.0 → 5.45.1

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.
Files changed (109) hide show
  1. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts +3 -1
  2. package/dist/lib/components/artifact/artifact-share-modal.component.d.ts.map +1 -1
  3. package/dist/lib/components/artifact/artifact-share-modal.component.js +16 -12
  4. package/dist/lib/components/artifact/artifact-share-modal.component.js.map +1 -1
  5. package/dist/lib/components/collection/collection-share-modal.component.d.ts +3 -1
  6. package/dist/lib/components/collection/collection-share-modal.component.d.ts.map +1 -1
  7. package/dist/lib/components/collection/collection-share-modal.component.js +16 -12
  8. package/dist/lib/components/collection/collection-share-modal.component.js.map +1 -1
  9. package/dist/lib/components/collection/collection-tree.component.d.ts +3 -1
  10. package/dist/lib/components/collection/collection-tree.component.d.ts.map +1 -1
  11. package/dist/lib/components/collection/collection-tree.component.js +10 -7
  12. package/dist/lib/components/collection/collection-tree.component.js.map +1 -1
  13. package/dist/lib/components/collection/collection-view.component.d.ts +3 -1
  14. package/dist/lib/components/collection/collection-view.component.d.ts.map +1 -1
  15. package/dist/lib/components/collection/collection-view.component.js +10 -8
  16. package/dist/lib/components/collection/collection-view.component.js.map +1 -1
  17. package/dist/lib/components/composer/ai-composer.component.d.ts +103 -0
  18. package/dist/lib/components/composer/ai-composer.component.d.ts.map +1 -0
  19. package/dist/lib/components/composer/ai-composer.component.js +263 -0
  20. package/dist/lib/components/composer/ai-composer.component.js.map +1 -0
  21. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts +3 -4
  22. package/dist/lib/components/conversation/conversation-chat-area.component.d.ts.map +1 -1
  23. package/dist/lib/components/conversation/conversation-chat-area.component.js +36 -36
  24. package/dist/lib/components/conversation/conversation-chat-area.component.js.map +1 -1
  25. package/dist/lib/components/conversation/conversation-empty-state.component.d.ts +1 -1
  26. package/dist/lib/components/conversation/conversation-empty-state.component.d.ts.map +1 -1
  27. package/dist/lib/components/conversation/conversation-empty-state.component.js.map +1 -1
  28. package/dist/lib/components/message/message-input.component.d.ts +5 -6
  29. package/dist/lib/components/message/message-input.component.d.ts.map +1 -1
  30. package/dist/lib/components/message/message-input.component.js +35 -20
  31. package/dist/lib/components/message/message-input.component.js.map +1 -1
  32. package/dist/lib/components/message/message-item.component.d.ts +2 -3
  33. package/dist/lib/components/message/message-item.component.d.ts.map +1 -1
  34. package/dist/lib/components/message/message-item.component.js +17 -17
  35. package/dist/lib/components/message/message-item.component.js.map +1 -1
  36. package/dist/lib/components/overlay/chat-overlay.component.d.ts +1 -1
  37. package/dist/lib/components/overlay/chat-overlay.component.d.ts.map +1 -1
  38. package/dist/lib/components/overlay/chat-overlay.component.js.map +1 -1
  39. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts +11 -3
  40. package/dist/lib/components/sidebar/conversation-sidebar.component.d.ts.map +1 -1
  41. package/dist/lib/components/sidebar/conversation-sidebar.component.js +34 -10
  42. package/dist/lib/components/sidebar/conversation-sidebar.component.js.map +1 -1
  43. package/dist/lib/components/sidebar/routines-section.component.d.ts +73 -0
  44. package/dist/lib/components/sidebar/routines-section.component.d.ts.map +1 -0
  45. package/dist/lib/components/sidebar/routines-section.component.js +211 -0
  46. package/dist/lib/components/sidebar/routines-section.component.js.map +1 -0
  47. package/dist/lib/components/tasks/tasks-dropdown.component.d.ts +12 -0
  48. package/dist/lib/components/tasks/tasks-dropdown.component.d.ts.map +1 -1
  49. package/dist/lib/components/tasks/tasks-dropdown.component.js +37 -1
  50. package/dist/lib/components/tasks/tasks-dropdown.component.js.map +1 -1
  51. package/dist/lib/components/workspace/conversation-workspace.component.d.ts +11 -5
  52. package/dist/lib/components/workspace/conversation-workspace.component.d.ts.map +1 -1
  53. package/dist/lib/components/workspace/conversation-workspace.component.js +35 -26
  54. package/dist/lib/components/workspace/conversation-workspace.component.js.map +1 -1
  55. package/dist/lib/composer-plugins/agent-mention.provider.d.ts +16 -0
  56. package/dist/lib/composer-plugins/agent-mention.provider.d.ts.map +1 -0
  57. package/dist/lib/composer-plugins/agent-mention.provider.js +28 -0
  58. package/dist/lib/composer-plugins/agent-mention.provider.js.map +1 -0
  59. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts +20 -0
  60. package/dist/lib/composer-plugins/base-conversation-mention.provider.d.ts.map +1 -0
  61. package/dist/lib/composer-plugins/base-conversation-mention.provider.js +32 -0
  62. package/dist/lib/composer-plugins/base-conversation-mention.provider.js.map +1 -0
  63. package/dist/lib/composer-plugins/load-composer-plugins.d.ts +9 -0
  64. package/dist/lib/composer-plugins/load-composer-plugins.d.ts.map +1 -0
  65. package/dist/lib/composer-plugins/load-composer-plugins.js +17 -0
  66. package/dist/lib/composer-plugins/load-composer-plugins.js.map +1 -0
  67. package/dist/lib/composer-plugins/record-mention.provider.d.ts +14 -0
  68. package/dist/lib/composer-plugins/record-mention.provider.d.ts.map +1 -0
  69. package/dist/lib/composer-plugins/record-mention.provider.js +26 -0
  70. package/dist/lib/composer-plugins/record-mention.provider.js.map +1 -0
  71. package/dist/lib/composer-plugins/skill-command.provider.d.ts +15 -0
  72. package/dist/lib/composer-plugins/skill-command.provider.d.ts.map +1 -0
  73. package/dist/lib/composer-plugins/skill-command.provider.js +27 -0
  74. package/dist/lib/composer-plugins/skill-command.provider.js.map +1 -0
  75. package/dist/lib/conversations.module.d.ts +74 -73
  76. package/dist/lib/conversations.module.d.ts.map +1 -1
  77. package/dist/lib/conversations.module.js +33 -13
  78. package/dist/lib/conversations.module.js.map +1 -1
  79. package/dist/lib/services/active-tasks.service.d.ts.map +1 -1
  80. package/dist/lib/services/active-tasks.service.js +4 -1
  81. package/dist/lib/services/active-tasks.service.js.map +1 -1
  82. package/dist/lib/services/conversation-agent.service.d.ts +7 -0
  83. package/dist/lib/services/conversation-agent.service.d.ts.map +1 -1
  84. package/dist/lib/services/conversation-agent.service.js +20 -0
  85. package/dist/lib/services/conversation-agent.service.js.map +1 -1
  86. package/dist/lib/services/conversation-attachment.service.d.ts +1 -1
  87. package/dist/lib/services/conversation-attachment.service.d.ts.map +1 -1
  88. package/dist/lib/services/conversation-attachment.service.js.map +1 -1
  89. package/dist/lib/services/mention-autocomplete.service.d.ts +27 -20
  90. package/dist/lib/services/mention-autocomplete.service.d.ts.map +1 -1
  91. package/dist/lib/services/mention-autocomplete.service.js +55 -16
  92. package/dist/lib/services/mention-autocomplete.service.js.map +1 -1
  93. package/dist/public-api.d.ts +23 -3
  94. package/dist/public-api.d.ts.map +1 -1
  95. package/dist/public-api.js +38 -3
  96. package/dist/public-api.js.map +1 -1
  97. package/package.json +29 -27
  98. package/dist/lib/components/mention/mention-dropdown.component.d.ts +0 -53
  99. package/dist/lib/components/mention/mention-dropdown.component.d.ts.map +0 -1
  100. package/dist/lib/components/mention/mention-dropdown.component.js +0 -297
  101. package/dist/lib/components/mention/mention-dropdown.component.js.map +0 -1
  102. package/dist/lib/components/mention/mention-editor.component.d.ts +0 -256
  103. package/dist/lib/components/mention/mention-editor.component.d.ts.map +0 -1
  104. package/dist/lib/components/mention/mention-editor.component.js +0 -1247
  105. package/dist/lib/components/mention/mention-editor.component.js.map +0 -1
  106. package/dist/lib/components/message/message-input-box.component.d.ts +0 -132
  107. package/dist/lib/components/message/message-input-box.component.d.ts.map +0 -1
  108. package/dist/lib/components/message/message-input-box.component.js +0 -327
  109. package/dist/lib/components/message/message-input-box.component.js.map +0 -1
@@ -1,1247 +0,0 @@
1
- import { Component, Input, Output, EventEmitter, ViewChild, forwardRef } from '@angular/core';
2
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
3
- import { AIEngineBase } from '@memberjunction/ai-engine-base';
4
- import { UUIDsEqual } from '@memberjunction/global';
5
- import * as i0 from "@angular/core";
6
- import * as i1 from "../../services/mention-autocomplete.service";
7
- import * as i2 from "./mention-dropdown.component";
8
- const _c0 = ["editor"];
9
- function MentionEditorComponent_Conditional_1_For_2_Conditional_1_Template(rf, ctx) { if (rf & 1) {
10
- i0.ɵɵelement(0, "img", 8);
11
- } if (rf & 2) {
12
- const attachment_r3 = i0.ɵɵnextContext().$implicit;
13
- i0.ɵɵproperty("src", attachment_r3.thumbnailUrl, i0.ɵɵsanitizeUrl)("alt", attachment_r3.fileName);
14
- } }
15
- function MentionEditorComponent_Conditional_1_For_2_Conditional_2_Template(rf, ctx) { if (rf & 1) {
16
- i0.ɵɵelementStart(0, "div", 9);
17
- i0.ɵɵelement(1, "i", 12);
18
- i0.ɵɵelementStart(2, "span", 13);
19
- i0.ɵɵtext(3);
20
- i0.ɵɵelementEnd()();
21
- } if (rf & 2) {
22
- const attachment_r3 = i0.ɵɵnextContext().$implicit;
23
- i0.ɵɵadvance(3);
24
- i0.ɵɵtextInterpolate(attachment_r3.fileName);
25
- } }
26
- function MentionEditorComponent_Conditional_1_For_2_Template(rf, ctx) { if (rf & 1) {
27
- const _r2 = i0.ɵɵgetCurrentView();
28
- i0.ɵɵelementStart(0, "div", 7);
29
- i0.ɵɵlistener("click", function MentionEditorComponent_Conditional_1_For_2_Template_div_click_0_listener() { const attachment_r3 = i0.ɵɵrestoreView(_r2).$implicit; const ctx_r3 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r3.onAttachmentClick(attachment_r3)); });
30
- i0.ɵɵconditionalCreate(1, MentionEditorComponent_Conditional_1_For_2_Conditional_1_Template, 1, 2, "img", 8);
31
- i0.ɵɵconditionalCreate(2, MentionEditorComponent_Conditional_1_For_2_Conditional_2_Template, 4, 1, "div", 9);
32
- i0.ɵɵelementStart(3, "button", 10);
33
- i0.ɵɵlistener("click", function MentionEditorComponent_Conditional_1_For_2_Template_button_click_3_listener($event) { const attachment_r3 = i0.ɵɵrestoreView(_r2).$implicit; const ctx_r3 = i0.ɵɵnextContext(2); ctx_r3.removeAttachment(attachment_r3.id); return i0.ɵɵresetView($event.stopPropagation()); });
34
- i0.ɵɵelement(4, "i", 11);
35
- i0.ɵɵelementEnd()();
36
- } if (rf & 2) {
37
- const attachment_r3 = ctx.$implicit;
38
- i0.ɵɵadvance();
39
- i0.ɵɵconditional(attachment_r3.thumbnailUrl ? 1 : -1);
40
- i0.ɵɵadvance();
41
- i0.ɵɵconditional(!attachment_r3.thumbnailUrl ? 2 : -1);
42
- } }
43
- function MentionEditorComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
44
- i0.ɵɵelementStart(0, "div", 2);
45
- i0.ɵɵrepeaterCreate(1, MentionEditorComponent_Conditional_1_For_2_Template, 5, 2, "div", 6, i0.ɵɵrepeaterTrackByIdentity);
46
- i0.ɵɵelementEnd();
47
- } if (rf & 2) {
48
- const ctx_r3 = i0.ɵɵnextContext();
49
- i0.ɵɵadvance();
50
- i0.ɵɵrepeater(ctx_r3.pendingAttachments);
51
- } }
52
- function MentionEditorComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
53
- i0.ɵɵelementStart(0, "div", 4)(1, "div", 14);
54
- i0.ɵɵelement(2, "i", 15);
55
- i0.ɵɵelementStart(3, "span");
56
- i0.ɵɵtext(4, "Drop files here");
57
- i0.ɵɵelementEnd()()();
58
- } }
59
- function MentionEditorComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
60
- const _r5 = i0.ɵɵgetCurrentView();
61
- i0.ɵɵelementStart(0, "mj-mention-dropdown", 16);
62
- i0.ɵɵlistener("suggestionSelected", function MentionEditorComponent_Conditional_5_Template_mj_mention_dropdown_suggestionSelected_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r3 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r3.onMentionSelected($event)); })("closed", function MentionEditorComponent_Conditional_5_Template_mj_mention_dropdown_closed_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r3 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r3.closeMentionDropdown()); });
63
- i0.ɵɵelementEnd();
64
- } if (rf & 2) {
65
- const ctx_r3 = i0.ɵɵnextContext();
66
- i0.ɵɵproperty("suggestions", ctx_r3.mentionSuggestions)("position", ctx_r3.mentionDropdownPosition)("showAbove", ctx_r3.mentionDropdownShowAbove)("useFixedPositioning", true)("visible", true);
67
- } }
68
- /**
69
- * ContentEditable-based mention editor with visual chips/pills
70
- * Provides Slack/Teams-style mention UX with immutable mention tokens
71
- */
72
- export class MentionEditorComponent {
73
- mentionAutocomplete;
74
- cdr;
75
- editorRef;
76
- placeholder = 'Type @ to mention agents or users, # for entities...';
77
- disabled = false;
78
- currentUser;
79
- enableMentions = true;
80
- // Attachment settings
81
- enableAttachments = true;
82
- maxAttachments = 10;
83
- maxAttachmentSizeBytes = 20 * 1024 * 1024; // 20MB default
84
- acceptedFileTypes = 'image/*'; // MIME types to accept
85
- valueChange = new EventEmitter();
86
- mentionSelected = new EventEmitter();
87
- enterPressed = new EventEmitter();
88
- attachmentsChanged = new EventEmitter();
89
- attachmentError = new EventEmitter();
90
- attachmentClicked = new EventEmitter();
91
- // Pending attachments state
92
- pendingAttachments = [];
93
- isDragOver = false;
94
- // Mention dropdown state
95
- showMentionDropdown = false;
96
- mentionSuggestions = [];
97
- mentionDropdownPosition = { top: 0, left: 0 };
98
- mentionDropdownShowAbove = false;
99
- mentionStartIndex = -1;
100
- mentionQuery = '';
101
- /** Mention trigger characters: '@' for agents/users, '#' for entities */
102
- static MENTION_TRIGGERS = ['@', '#', '/'];
103
- /** The trigger char that opened the current mention dropdown */
104
- activeTrigger = '@';
105
- onChange = () => { };
106
- onTouched = () => { };
107
- constructor(mentionAutocomplete, cdr) {
108
- this.mentionAutocomplete = mentionAutocomplete;
109
- this.cdr = cdr;
110
- }
111
- async ngOnInit() {
112
- if (this.enableMentions && this.currentUser) {
113
- await this.mentionAutocomplete.initialize(this.currentUser);
114
- }
115
- }
116
- ngAfterViewInit() {
117
- // Auto-focus the editor
118
- setTimeout(() => {
119
- this.editorRef?.nativeElement?.focus();
120
- }, 100);
121
- }
122
- /**
123
- * Handle clicks on the container - focus the editor if clicking outside the contentEditable
124
- */
125
- onContainerClick(event) {
126
- const target = event.target;
127
- const editor = this.editorRef?.nativeElement;
128
- // Don't handle clicks on the dropdown or its children
129
- if (target.closest('mj-mention-dropdown')) {
130
- return;
131
- }
132
- // If clicking on container or any element that's not the editor itself, focus the editor
133
- if (target !== editor && !editor?.contains(target)) {
134
- editor?.focus();
135
- // Move cursor to end of content
136
- const selection = window.getSelection();
137
- const range = document.createRange();
138
- if (editor && selection) {
139
- range.selectNodeContents(editor);
140
- range.collapse(false); // Collapse to end
141
- selection.removeAllRanges();
142
- selection.addRange(range);
143
- }
144
- }
145
- }
146
- /**
147
- * Handle input changes in contentEditable
148
- */
149
- onInput() {
150
- const plainText = this.getPlainText();
151
- this.onChange(plainText);
152
- this.valueChange.emit(plainText);
153
- // Handle @mention autocomplete
154
- if (this.enableMentions && this.currentUser) {
155
- this.handleMentionInput();
156
- }
157
- }
158
- /**
159
- * Handle blur event - close dropdown when editor loses focus
160
- */
161
- onBlur() {
162
- // Call form control touched callback
163
- this.onTouched();
164
- // Close dropdown when editor loses focus
165
- // Use setTimeout to allow mousedown events on dropdown to fire first
166
- setTimeout(() => {
167
- if (this.showMentionDropdown) {
168
- this.closeMentionDropdown();
169
- }
170
- }, 200);
171
- }
172
- /**
173
- * Handle paste event - images or plain text
174
- */
175
- onPaste(event) {
176
- // Check for image data in clipboard
177
- if (this.enableAttachments && event.clipboardData?.items) {
178
- const items = Array.from(event.clipboardData.items);
179
- const imageItems = items.filter(item => item.type.startsWith('image/'));
180
- if (imageItems.length > 0) {
181
- event.preventDefault();
182
- // Process each image
183
- for (const item of imageItems) {
184
- const file = item.getAsFile();
185
- if (file) {
186
- this.processFile(file);
187
- }
188
- }
189
- return;
190
- }
191
- }
192
- // No images - handle as plain text
193
- event.preventDefault();
194
- // Get plain text from clipboard
195
- const text = event.clipboardData?.getData('text/plain') || '';
196
- if (!text)
197
- return;
198
- // Insert plain text at cursor position
199
- const selection = window.getSelection();
200
- if (!selection || selection.rangeCount === 0)
201
- return;
202
- const range = selection.getRangeAt(0);
203
- range.deleteContents();
204
- // Insert text as text node (not HTML)
205
- const textNode = document.createTextNode(text);
206
- range.insertNode(textNode);
207
- // Move cursor to end of inserted text
208
- range.setStartAfter(textNode);
209
- range.collapse(true);
210
- selection.removeAllRanges();
211
- selection.addRange(range);
212
- // Trigger input event to update model
213
- this.onInput();
214
- }
215
- /**
216
- * Handle keydown events
217
- */
218
- onKeyDown(event) {
219
- // Enter alone: Send message (if dropdown not showing)
220
- if (event.key === 'Enter' && !event.shiftKey && !this.showMentionDropdown) {
221
- event.preventDefault();
222
- const plainText = this.getPlainText();
223
- this.enterPressed.emit(plainText);
224
- return;
225
- }
226
- // Backspace: Check if deleting a mention chip
227
- if (event.key === 'Backspace') {
228
- this.handleBackspace(event);
229
- }
230
- // Handle mention dropdown navigation
231
- if (this.showMentionDropdown) {
232
- // Let the dropdown handle arrow keys, enter, escape
233
- // (We'll pass these through to mention-dropdown component)
234
- }
235
- }
236
- /**
237
- * Handle @mention input detection
238
- */
239
- handleMentionInput() {
240
- const selection = window.getSelection();
241
- if (!selection || selection.rangeCount === 0)
242
- return;
243
- const range = selection.getRangeAt(0);
244
- const textBeforeCursor = this.getTextBeforeCursor(range);
245
- // Find the nearest mention trigger before the cursor
246
- // ('@' for agents/users, '#' for entities) — whichever is closest wins
247
- let triggerIndex = -1;
248
- let triggerChar = '@';
249
- for (const t of MentionEditorComponent.MENTION_TRIGGERS) {
250
- const idx = textBeforeCursor.lastIndexOf(t);
251
- if (idx > triggerIndex) {
252
- triggerIndex = idx;
253
- triggerChar = t;
254
- }
255
- }
256
- if (triggerIndex === -1) {
257
- this.closeMentionDropdown();
258
- return;
259
- }
260
- // Check if there's a space between the trigger and cursor (means mention was completed)
261
- const textAfterTrigger = textBeforeCursor.substring(triggerIndex + 1);
262
- if (textAfterTrigger.includes(' ')) {
263
- this.closeMentionDropdown();
264
- return;
265
- }
266
- // Extract query
267
- this.mentionQuery = textAfterTrigger;
268
- this.mentionStartIndex = triggerIndex;
269
- this.activeTrigger = triggerChar;
270
- // Get suggestions for the active trigger
271
- this.mentionSuggestions = this.mentionAutocomplete.getSuggestions(this.mentionQuery, !!this.currentUser, triggerChar);
272
- if (this.mentionSuggestions.length > 0) {
273
- this.showMentionDropdown = true;
274
- this.positionMentionDropdown();
275
- }
276
- else {
277
- this.closeMentionDropdown();
278
- }
279
- }
280
- /**
281
- * Get text before cursor position
282
- */
283
- getTextBeforeCursor(range) {
284
- const tempRange = range.cloneRange();
285
- tempRange.selectNodeContents(this.editorRef.nativeElement);
286
- tempRange.setEnd(range.startContainer, range.startOffset);
287
- return tempRange.toString();
288
- }
289
- /**
290
- * Position the mention dropdown
291
- */
292
- positionMentionDropdown() {
293
- const editor = this.editorRef?.nativeElement;
294
- if (!editor)
295
- return;
296
- // Get the parent container (message-input-box-container) for alignment
297
- const container = editor.closest('.message-input-box-container');
298
- const containerRect = container?.getBoundingClientRect();
299
- const selection = window.getSelection();
300
- if (!selection || selection.rangeCount === 0)
301
- return;
302
- const range = selection.getRangeAt(0);
303
- const cursorRect = range.getBoundingClientRect();
304
- // Check space below vs above
305
- const spaceBelow = window.innerHeight - cursorRect.bottom;
306
- const spaceAbove = cursorRect.top;
307
- const dropdownHeight = Math.min(this.mentionSuggestions.length * 56, 300);
308
- this.mentionDropdownShowAbove = spaceBelow < dropdownHeight && spaceAbove > spaceBelow;
309
- if (this.mentionDropdownShowAbove) {
310
- // Position above, aligning with container top if possible
311
- this.mentionDropdownPosition = {
312
- top: containerRect ? containerRect.top + window.scrollY : cursorRect.top + window.scrollY - 4,
313
- left: cursorRect.left + window.scrollX
314
- };
315
- }
316
- else {
317
- // Position below cursor, but align bottom edge with container top
318
- this.mentionDropdownPosition = {
319
- top: containerRect ? containerRect.top + window.scrollY : cursorRect.bottom + window.scrollY + 4,
320
- left: cursorRect.left + window.scrollX
321
- };
322
- }
323
- }
324
- /**
325
- * Handle mention selection from dropdown
326
- */
327
- onMentionSelected(suggestion) {
328
- this.insertMentionChip(suggestion);
329
- this.closeMentionDropdown();
330
- this.mentionSelected.emit(suggestion);
331
- // Refocus the editor after selection
332
- setTimeout(() => {
333
- this.editorRef?.nativeElement?.focus();
334
- }, 50);
335
- }
336
- /**
337
- * Insert a mention chip at the current cursor position
338
- */
339
- insertMentionChip(suggestion) {
340
- const selection = window.getSelection();
341
- if (!selection || selection.rangeCount === 0)
342
- return;
343
- const range = selection.getRangeAt(0);
344
- // Delete the trigger + query text (use the active trigger char)
345
- const textBeforeCursor = this.getTextBeforeCursor(range);
346
- const lastAtIndex = textBeforeCursor.lastIndexOf(this.activeTrigger);
347
- const deleteLength = textBeforeCursor.length - lastAtIndex;
348
- range.setStart(range.startContainer, range.startOffset - deleteLength);
349
- range.deleteContents();
350
- // Create mention chip element
351
- const chip = this.createMentionChip(suggestion);
352
- // Insert chip
353
- range.insertNode(chip);
354
- // Add space after chip
355
- const space = document.createTextNode(' ');
356
- range.collapse(false);
357
- range.insertNode(space);
358
- // Move cursor after the space
359
- range.setStartAfter(space);
360
- range.collapse(true);
361
- selection.removeAllRanges();
362
- selection.addRange(range);
363
- // Trigger change detection
364
- this.onInput();
365
- }
366
- /**
367
- * Create a mention chip DOM element
368
- */
369
- createMentionChip(suggestion) {
370
- const chip = document.createElement('span');
371
- chip.className = 'mention-chip';
372
- chip.contentEditable = 'false'; // Make chip non-editable
373
- chip.setAttribute('data-mention-id', suggestion.id);
374
- chip.setAttribute('data-mention-type', suggestion.type);
375
- chip.setAttribute('data-mention-name', suggestion.name);
376
- // For agents, get configuration presets (AIEngine.Config() already called during app init)
377
- let presets = [];
378
- if (suggestion.type === 'agent') {
379
- presets = AIEngineBase.Instance.GetAgentConfigurationPresets(suggestion.id, true);
380
- // Store default preset
381
- // IMPORTANT: Store the AIAgentConfiguration.ID (preset ID), not AIConfigurationID
382
- // The backend mapping will convert preset ID -> AIConfigurationID
383
- const defaultPreset = presets.find(p => p.IsDefault) || presets[0];
384
- if (defaultPreset) {
385
- chip.setAttribute('data-preset-id', defaultPreset.ID || '');
386
- chip.setAttribute('data-preset-name', defaultPreset.Name || '');
387
- }
388
- }
389
- // Apply inline styles directly — color by mention type. Skills carry their own accent Color
390
- // (AISkill.Color UX metadata); when present it drives the chip, otherwise the standard skill
391
- // green (--mj-status-success). Same color logic as the saved-message badge — keep in sync with
392
- // message-item's renderMentionHTML.
393
- const skillPalette = suggestion.type === 'skill'
394
- ? { bg: suggestion.color || 'var(--mj-status-success)', border: 'rgba(255, 255, 255, 0.35)' }
395
- : null;
396
- const palette = skillPalette
397
- ? skillPalette
398
- : suggestion.type === 'user'
399
- ? { bg: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', border: 'rgba(240, 147, 251, 0.4)' }
400
- : suggestion.type === 'entity'
401
- ? { bg: 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)', border: 'rgba(17, 153, 142, 0.4)' }
402
- : suggestion.type === 'query'
403
- ? { bg: 'linear-gradient(135deg, #FF6A00 0%, #FF9E2C 100%)', border: 'rgba(255, 106, 0, 0.4)' }
404
- : { bg: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', border: 'rgba(102, 126, 234, 0.4)' };
405
- // Skills render as a sharp-cornered rectangle (vs. the rounded pill for agents/users/entities)
406
- // — the shape is the at-a-glance differentiator. Same shape in the saved-message badge.
407
- const chipRadius = suggestion.type === 'skill' ? '4px' : '16px';
408
- chip.style.cssText = `
409
- display: inline-flex;
410
- align-items: center;
411
- gap: 5px;
412
- padding: 4px 12px;
413
- margin: 0 3px;
414
- border-radius: ${chipRadius};
415
- font-size: 13px;
416
- font-weight: 600;
417
- cursor: default;
418
- user-select: none;
419
- vertical-align: middle;
420
- white-space: nowrap;
421
- pointer-events: all;
422
- background: ${palette.bg};
423
- color: white;
424
- border: 2px solid ${palette.border};
425
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
426
- `;
427
- // Add icon or image
428
- if (suggestion.type === 'agent' && suggestion.imageUrl) {
429
- // Use image if available (LogoURL from agent)
430
- const img = document.createElement('img');
431
- img.src = suggestion.imageUrl;
432
- img.alt = suggestion.displayName;
433
- img.style.cssText = 'width: 16px; height: 16px; border-radius: 50%; object-fit: cover;';
434
- chip.appendChild(img);
435
- }
436
- else if (suggestion.type === 'agent' && suggestion.icon === 'mj-icon-skip') {
437
- // Special handling for mj-icon-skip: use the SVG data URI as an image
438
- const img = document.createElement('img');
439
- img.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 101.89918457031249 96.83947368421053'%3E%3Cg transform='translate(-0.1288232421875,-0.0)'%3E%3Cpath d='M93.85,41.56c-.84,0-1.62.2-2.37.55-3-4.35-7.49-8.12-13.04-11.04l.04-7.18v-14.44h-10.24v17.6c-1.52-.43-3.07-.8-4.67-1.11V0h-10.24v24.72s-.09,0-.14,0h-4.38s-.1,0-.14,0V7.3h-10.24v18.62c-1.6.32-3.15.69-4.67,1.11v-11.67h-10.24v6.09l.04,9.6c-5.55,2.92-10.04,6.7-13.04,11.04-.75-.35-1.53-.55-2.37-.55-4.5,0-8.14,5.61-8.14,12.51s3.64,12.53,8.14,12.53c.58,0,1.14-.12,1.67-.29,4.1,6.62,11.54,12.06,20.98,15.28l.79.13v7.05c0,2.97,1.45,5.58,3.87,6.99,1.18.69,2.5,1.04,3.85,1.03,1.4,0,2.83-.37,4.15-1.12l7.54-4.29,7.56,4.3c1.31.74,2.73,1.12,4.13,1.12s2.67-.35,3.85-1.04c2.42-1.41,3.86-4.02,3.86-6.98v-7.05l.79-.13c9.44-3.22,16.89-8.66,20.98-15.28.54.17,1.09.29,1.68.29,4.5,0,8.14-5.61,8.14-12.53s-3.63-12.51-8.14-12.51' fill='%23AAAAAA'/%3E%3Cpath d='M86.69,50.87c0-12.22-13.6-19.1-28.94-20.66-4.48-.47-9.19-.54-13.52,0-15.34,1.53-28.93,8.41-28.93,20.66,0,8.55,5.7,15.55,12.68,15.55h7.94c3.05,2.5,6.93,4.1,11.08,4.71,2.65.4,5.44.46,8.01,0,4.15-.6,8.05-2.2,11.1-4.71h7.92c6.97,0,12.68-7,12.68-15.55' fill='white' opacity='0.9'/%3E%3Cpath d='M57.83,55.82c-1.19,2.58-3.8,4.35-6.84,4.35s-5.65-1.77-6.84-4.35h13.68Z' fill='%23AAAAAA'/%3E%3Cpath d='M32.52,41.14c1.74,0,3.18,2.13,3.18,4.76s-1.44,4.74-3.18,4.74-3.16-2.13-3.16-4.74,1.41-4.76,3.16-4.76' fill='%23AAAAAA'/%3E%3Cpath d='M69.46,41.14c1.74,0,3.16,2.13,3.16,4.76s-1.41,4.74-3.16,4.74-3.18-2.13-3.18-4.74,1.41-4.76,3.18-4.76' fill='%23AAAAAA'/%3E%3Cpath d='M63.91,76.15c-.82-.48-1.84-.43-2.8.12l-10.13,5.75-10.11-5.75c-.96-.55-1.98-.59-2.8-.12-.82.47-1.29,1.38-1.29,2.49v10.12c0,1.11.47,2.02,1.28,2.49.38.22.8.33,1.24.33.51,0,1.05-.15,1.57-.44l10.12-5.75,10.11,5.75c.52.29,1.05.44,1.56.44.44,0,.86-.11,1.24-.33.81-.48,1.28-1.38,1.28-2.49v-10.12c0-1.11-.47-2.02-1.28-2.49' fill='white' opacity='0.9'/%3E%3C/g%3E%3C/svg%3E";
440
- img.alt = suggestion.displayName;
441
- img.style.cssText = 'width: 16px; height: 16px; border-radius: 50%; object-fit: cover;';
442
- chip.appendChild(img);
443
- }
444
- else {
445
- // Use icon for users or agents without images
446
- const icon = document.createElement('i');
447
- icon.style.cssText = 'font-size: 12px; opacity: 0.95;';
448
- if (suggestion.type === 'agent' && suggestion.icon) {
449
- icon.className = this.getIconClasses(suggestion.icon);
450
- }
451
- else if (suggestion.type === 'user') {
452
- icon.className = 'fa-solid fa-user';
453
- }
454
- else if (suggestion.type === 'entity') {
455
- icon.className = this.getIconClasses(suggestion.icon || 'fa-solid fa-table');
456
- }
457
- else if (suggestion.type === 'query') {
458
- icon.className = this.getIconClasses(suggestion.icon || 'fa-solid fa-database');
459
- }
460
- else if (suggestion.type === 'skill') {
461
- icon.className = this.getIconClasses(suggestion.icon || 'fa-solid fa-wand-magic-sparkles');
462
- }
463
- else {
464
- icon.className = 'fa-solid fa-robot';
465
- }
466
- chip.appendChild(icon);
467
- }
468
- // Add space between icon/image and text
469
- const space = document.createTextNode(' ');
470
- chip.appendChild(space);
471
- // Add text
472
- const text = document.createTextNode(suggestion.displayName);
473
- chip.appendChild(text);
474
- // Add dropdown if 2+ presets for agents
475
- if (suggestion.type === 'agent' && presets.length >= 2) {
476
- this.addConfigurationDropdown(chip, presets);
477
- }
478
- return chip;
479
- }
480
- /**
481
- * Add configuration preset dropdown to agent chip
482
- */
483
- addConfigurationDropdown(chip, presets) {
484
- // Store default preset for comparison
485
- const defaultPreset = presets.find(p => p.IsDefault) || presets[0];
486
- // Add preset indicator text (only shown when non-default selected)
487
- const presetIndicator = document.createElement('span');
488
- presetIndicator.className = 'preset-indicator';
489
- presetIndicator.style.cssText = `
490
- display: none;
491
- font-size: 10px;
492
- font-weight: 600;
493
- font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
494
- background: rgba(255, 255, 255, 0.25);
495
- padding: 2px 6px;
496
- border-radius: 4px;
497
- margin-left: 4px;
498
- letter-spacing: 0.3px;
499
- text-transform: uppercase;
500
- border: 1px solid rgba(255, 255, 255, 0.15);
501
- `;
502
- chip.appendChild(presetIndicator);
503
- // Add dropdown chevron button
504
- const chevron = document.createElement('i');
505
- chevron.className = 'fa-solid fa-chevron-down';
506
- chevron.style.cssText = `
507
- font-size: 10px;
508
- opacity: 0.9;
509
- cursor: pointer;
510
- padding: 2px;
511
- `;
512
- chip.appendChild(chevron);
513
- // Create dropdown menu (initially hidden) - append to body for global positioning
514
- const dropdown = document.createElement('div');
515
- dropdown.className = 'preset-dropdown';
516
- dropdown.style.cssText = `
517
- display: none;
518
- position: fixed;
519
- background: white;
520
- border: 1px solid #ddd;
521
- border-radius: 8px;
522
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
523
- min-width: 200px;
524
- max-width: 300px;
525
- z-index: 10000;
526
- overflow: hidden;
527
- `;
528
- // Add preset options to dropdown
529
- presets.forEach(preset => {
530
- const option = document.createElement('div');
531
- option.className = 'preset-option';
532
- option.style.cssText = `
533
- padding: 10px 12px;
534
- cursor: pointer;
535
- display: flex;
536
- align-items: center;
537
- gap: 8px;
538
- transition: background 0.2s;
539
- `;
540
- // Check if this is the selected preset
541
- const currentPresetId = chip.getAttribute('data-preset-id');
542
- const isSelected = UUIDsEqual(preset.ID, currentPresetId);
543
- // Add checkmark for selected option
544
- const checkmark = document.createElement('i');
545
- checkmark.className = 'fa-solid fa-check';
546
- checkmark.style.cssText = `
547
- font-size: 12px;
548
- color: #667eea;
549
- opacity: ${isSelected ? '1' : '0'};
550
- width: 14px;
551
- `;
552
- option.appendChild(checkmark);
553
- // Add preset text content
554
- const textContainer = document.createElement('div');
555
- textContainer.style.cssText = 'flex: 1;';
556
- const displayName = document.createElement('div');
557
- displayName.textContent = preset.DisplayName || preset.Name;
558
- displayName.style.cssText = `
559
- font-weight: 600;
560
- color: #333;
561
- font-size: 13px;
562
- `;
563
- textContainer.appendChild(displayName);
564
- if (preset.Description) {
565
- const description = document.createElement('div');
566
- description.textContent = preset.Description;
567
- description.style.cssText = `
568
- font-size: 11px;
569
- color: #666;
570
- margin-top: 2px;
571
- `;
572
- textContainer.appendChild(description);
573
- }
574
- option.appendChild(textContainer);
575
- // Hover effects
576
- option.addEventListener('mouseenter', () => {
577
- option.style.background = '#f5f5f5';
578
- });
579
- option.addEventListener('mouseleave', () => {
580
- option.style.background = 'white';
581
- });
582
- // Click handler to select preset
583
- option.addEventListener('click', (e) => {
584
- e.stopPropagation();
585
- // Update chip data attributes
586
- // IMPORTANT: Store preset.ID (AIAgentConfiguration.ID), not AIConfigurationID
587
- chip.setAttribute('data-preset-id', preset.ID || '');
588
- chip.setAttribute('data-preset-name', preset.Name || '');
589
- // Update preset indicator visibility and text
590
- const isDefault = UUIDsEqual(preset.ID, defaultPreset.ID);
591
- if (isDefault) {
592
- presetIndicator.style.display = 'none';
593
- }
594
- else {
595
- presetIndicator.style.display = 'inline';
596
- presetIndicator.textContent = preset.DisplayName || preset.Name;
597
- }
598
- // Update checkmarks
599
- dropdown.querySelectorAll('.preset-option').forEach((opt, idx) => {
600
- const check = opt.querySelector('i.fa-check');
601
- if (check) {
602
- check.style.opacity = idx === presets.indexOf(preset) ? '1' : '0';
603
- }
604
- });
605
- // Close dropdown
606
- dropdown.style.display = 'none';
607
- });
608
- dropdown.appendChild(option);
609
- });
610
- // Append dropdown to document body for global positioning
611
- document.body.appendChild(dropdown);
612
- // Helper function to position dropdown relative to chip
613
- const positionDropdown = () => {
614
- const chipRect = chip.getBoundingClientRect();
615
- const viewportHeight = window.innerHeight;
616
- const spaceBelow = viewportHeight - chipRect.bottom;
617
- // Set left position (same for both above/below)
618
- dropdown.style.left = `${chipRect.left}px`;
619
- // First, show dropdown to measure its actual height
620
- const wasHidden = dropdown.style.display === 'none';
621
- if (wasHidden) {
622
- dropdown.style.visibility = 'hidden';
623
- dropdown.style.display = 'block';
624
- }
625
- const dropdownHeight = dropdown.offsetHeight;
626
- const spaceAbove = chipRect.top;
627
- // Position dropdown above chip if not enough space below
628
- if (spaceBelow < dropdownHeight && spaceAbove > spaceBelow) {
629
- // Show above - position so bottom of dropdown is 4px above top of chip
630
- dropdown.style.top = `${chipRect.top - dropdownHeight - 4}px`;
631
- }
632
- else {
633
- // Show below (default) - position 4px below bottom of chip
634
- dropdown.style.top = `${chipRect.bottom + 4}px`;
635
- }
636
- // Restore visibility
637
- if (wasHidden) {
638
- dropdown.style.visibility = 'visible';
639
- }
640
- };
641
- // Toggle dropdown on chevron click
642
- chevron.addEventListener('click', (e) => {
643
- e.stopPropagation();
644
- const isVisible = dropdown.style.display === 'block';
645
- if (isVisible) {
646
- dropdown.style.display = 'none';
647
- }
648
- else {
649
- positionDropdown();
650
- dropdown.style.display = 'block';
651
- }
652
- });
653
- // Close dropdown when clicking outside
654
- const closeDropdown = (e) => {
655
- if (!dropdown.contains(e.target) && !chip.contains(e.target)) {
656
- dropdown.style.display = 'none';
657
- }
658
- };
659
- document.addEventListener('click', closeDropdown);
660
- // Cleanup: remove dropdown from body and event listeners when chip is removed
661
- const observer = new MutationObserver((mutations) => {
662
- mutations.forEach((mutation) => {
663
- mutation.removedNodes.forEach((node) => {
664
- if (node === chip) {
665
- document.removeEventListener('click', closeDropdown);
666
- if (dropdown.parentNode) {
667
- dropdown.parentNode.removeChild(dropdown);
668
- }
669
- observer.disconnect();
670
- }
671
- });
672
- });
673
- });
674
- if (chip.parentNode) {
675
- observer.observe(chip.parentNode, { childList: true });
676
- }
677
- }
678
- /**
679
- * Get icon classes with proper FA prefix
680
- */
681
- getIconClasses(iconClass) {
682
- if (!iconClass)
683
- return 'fa-solid fa-robot';
684
- if (iconClass.includes('fa-')) {
685
- if (iconClass.match(/\b(fa-solid|fa-regular|fa-light|fa-brands)\b/)) {
686
- return iconClass;
687
- }
688
- return `fa-solid ${iconClass}`;
689
- }
690
- return iconClass;
691
- }
692
- /**
693
- * Handle backspace key - delete entire chip if cursor is right after one
694
- */
695
- handleBackspace(event) {
696
- const selection = window.getSelection();
697
- if (!selection || selection.rangeCount === 0)
698
- return;
699
- const range = selection.getRangeAt(0);
700
- // Check if cursor is right after a mention chip
701
- if (range.collapsed && range.startOffset > 0) {
702
- const prevNode = range.startContainer.childNodes[range.startOffset - 1];
703
- if (prevNode && prevNode.classList?.contains('mention-chip')) {
704
- event.preventDefault();
705
- prevNode.remove();
706
- this.onInput();
707
- }
708
- }
709
- }
710
- /**
711
- * Close mention dropdown
712
- */
713
- closeMentionDropdown() {
714
- this.showMentionDropdown = false;
715
- this.mentionSuggestions = [];
716
- this.mentionStartIndex = -1;
717
- this.mentionQuery = '';
718
- this.activeTrigger = '@';
719
- }
720
- /**
721
- * Convert editor HTML to plain text with @mentions
722
- */
723
- getPlainText() {
724
- const editor = this.editorRef?.nativeElement;
725
- if (!editor)
726
- return '';
727
- let text = '';
728
- const nodes = editor.childNodes;
729
- for (let i = 0; i < nodes.length; i++) {
730
- const node = nodes[i];
731
- if (node.nodeType === Node.TEXT_NODE) {
732
- text += node.textContent || '';
733
- }
734
- else if (node.nodeType === Node.ELEMENT_NODE) {
735
- const element = node;
736
- if (element.classList.contains('mention-chip')) {
737
- const name = element.getAttribute('data-mention-name') || '';
738
- const mentionType = element.getAttribute('data-mention-type');
739
- const prefix = mentionType === 'entity' || mentionType === 'query' ? '#' : '@';
740
- // Use quoted format if name has spaces
741
- text += name.includes(' ') ? `${prefix}"${name}"` : `${prefix}${name}`;
742
- }
743
- else if (element.tagName === 'BR') {
744
- text += '\n';
745
- }
746
- else if (element.tagName === 'DIV') {
747
- // Handle line breaks from contentEditable
748
- if (i > 0)
749
- text += '\n';
750
- text += this.getNodeText(element);
751
- }
752
- else {
753
- text += element.textContent || '';
754
- }
755
- }
756
- }
757
- return text;
758
- }
759
- /**
760
- * Get text from a node recursively
761
- */
762
- getNodeText(node) {
763
- let text = '';
764
- const children = node.childNodes;
765
- for (let i = 0; i < children.length; i++) {
766
- const child = children[i];
767
- if (child.nodeType === Node.TEXT_NODE) {
768
- text += child.textContent || '';
769
- }
770
- else if (child.nodeType === Node.ELEMENT_NODE) {
771
- const element = child;
772
- if (element.classList.contains('mention-chip')) {
773
- const name = element.getAttribute('data-mention-name') || '';
774
- const mentionType = element.getAttribute('data-mention-type');
775
- const prefix = mentionType === 'entity' || mentionType === 'query' ? '#' : '@';
776
- text += name.includes(' ') ? `${prefix}"${name}"` : `${prefix}${name}`;
777
- }
778
- else {
779
- text += this.getNodeText(element);
780
- }
781
- }
782
- }
783
- return text;
784
- }
785
- /**
786
- * Set editor content from plain text (for programmatic updates)
787
- */
788
- setEditorContent(text) {
789
- const editor = this.editorRef?.nativeElement;
790
- if (!editor)
791
- return;
792
- // For now, just set as plain text
793
- // TODO: Parse @mentions and render as chips
794
- editor.textContent = text;
795
- }
796
- // ControlValueAccessor implementation
797
- writeValue(value) {
798
- if (value) {
799
- this.setEditorContent(value);
800
- }
801
- else if (this.editorRef?.nativeElement) {
802
- this.editorRef.nativeElement.textContent = '';
803
- }
804
- }
805
- registerOnChange(fn) {
806
- this.onChange = fn;
807
- }
808
- registerOnTouched(fn) {
809
- this.onTouched = fn;
810
- }
811
- setDisabledState(isDisabled) {
812
- this.disabled = isDisabled;
813
- if (this.editorRef?.nativeElement) {
814
- this.editorRef.nativeElement.contentEditable = (!isDisabled).toString();
815
- }
816
- }
817
- /**
818
- * Focus the editor
819
- */
820
- focus() {
821
- this.editorRef?.nativeElement?.focus();
822
- }
823
- /**
824
- * Clear the editor content and pending attachments
825
- */
826
- clear() {
827
- if (this.editorRef?.nativeElement) {
828
- this.editorRef.nativeElement.textContent = '';
829
- this.onInput();
830
- }
831
- this.clearPendingAttachments();
832
- }
833
- /**
834
- * Extract mention chips with their configuration data
835
- * Returns array of objects containing mention info and preset configuration
836
- */
837
- getMentionChipsData() {
838
- const editor = this.editorRef?.nativeElement;
839
- if (!editor)
840
- return [];
841
- const chips = [];
842
- const mentionElements = editor.querySelectorAll('.mention-chip');
843
- mentionElements.forEach(chip => {
844
- const element = chip;
845
- const id = element.getAttribute('data-mention-id') || '';
846
- const type = element.getAttribute('data-mention-type') || '';
847
- const name = element.getAttribute('data-mention-name') || '';
848
- const presetId = element.getAttribute('data-preset-id') || undefined;
849
- const presetName = element.getAttribute('data-preset-name') || undefined;
850
- chips.push({
851
- id,
852
- type,
853
- name,
854
- ...(presetId ? { presetId } : {}),
855
- ...(presetName ? { presetName } : {})
856
- });
857
- });
858
- return chips;
859
- }
860
- /**
861
- * Get the plain text value with mentions encoded as JSON
862
- * This format preserves configuration information when messages are saved
863
- * Format: @{type:"agent",id:"uuid",name:"Agent Name",configId:"uuid",config:"High"}
864
- */
865
- getPlainTextWithJsonMentions() {
866
- const editor = this.editorRef?.nativeElement;
867
- if (!editor)
868
- return '';
869
- let plainText = '';
870
- const childNodes = Array.from(editor.childNodes);
871
- for (const node of childNodes) {
872
- if (node.nodeType === Node.TEXT_NODE) {
873
- // Regular text node
874
- plainText += node.textContent || '';
875
- }
876
- else if (node.nodeType === Node.ELEMENT_NODE) {
877
- const element = node;
878
- if (element.classList.contains('mention-chip')) {
879
- // Extract mention data attributes
880
- const type = element.getAttribute('data-mention-type') || '';
881
- const id = element.getAttribute('data-mention-id') || '';
882
- const name = element.getAttribute('data-mention-name') || '';
883
- const presetId = element.getAttribute('data-preset-id');
884
- const presetName = element.getAttribute('data-preset-name');
885
- // Build JSON mention object (compact format - no spaces)
886
- const mentionObj = {
887
- type,
888
- id,
889
- name
890
- };
891
- // Add configuration fields if present (for agents with non-default presets)
892
- if (presetId) {
893
- mentionObj.configId = presetId;
894
- }
895
- if (presetName) {
896
- mentionObj.config = presetName;
897
- }
898
- // Encode as JSON mention
899
- // Don't remove spaces from the JSON string - spaces in values (like agent names) need to be preserved
900
- plainText += `@${JSON.stringify(mentionObj)}`;
901
- }
902
- else {
903
- // Other HTML element (e.g., <br>)
904
- if (element.tagName === 'BR') {
905
- plainText += '\n';
906
- }
907
- else {
908
- plainText += element.textContent || '';
909
- }
910
- }
911
- }
912
- }
913
- return plainText;
914
- }
915
- // ==================== Attachment Handling Methods ====================
916
- /**
917
- * Handle drag over event
918
- */
919
- onDragOver(event) {
920
- if (!this.enableAttachments)
921
- return;
922
- event.preventDefault();
923
- event.stopPropagation();
924
- this.isDragOver = true;
925
- }
926
- /**
927
- * Handle drag leave event
928
- */
929
- onDragLeave(event) {
930
- event.preventDefault();
931
- event.stopPropagation();
932
- this.isDragOver = false;
933
- }
934
- /**
935
- * Handle drop event
936
- */
937
- onDrop(event) {
938
- if (!this.enableAttachments)
939
- return;
940
- event.preventDefault();
941
- event.stopPropagation();
942
- this.isDragOver = false;
943
- if (event.dataTransfer?.files) {
944
- const files = Array.from(event.dataTransfer.files);
945
- for (const file of files) {
946
- if (this.isAcceptedFile(file)) {
947
- this.processFile(file);
948
- }
949
- }
950
- }
951
- }
952
- /**
953
- * Handle file input change (from file picker)
954
- */
955
- onFileSelected(event) {
956
- const input = event.target;
957
- if (input.files) {
958
- const files = Array.from(input.files);
959
- for (const file of files) {
960
- this.processFile(file);
961
- }
962
- // Reset input so same file can be selected again
963
- input.value = '';
964
- }
965
- }
966
- /**
967
- * Process a file for attachment
968
- */
969
- async processFile(file) {
970
- // Validate file
971
- const validation = this.validateFile(file);
972
- if (!validation.valid) {
973
- this.attachmentError.emit(validation.error);
974
- return;
975
- }
976
- // Read file as data URL
977
- const dataUrl = await this.readFileAsDataUrl(file);
978
- if (!dataUrl) {
979
- this.attachmentError.emit('Failed to read file');
980
- return;
981
- }
982
- // Get image dimensions if applicable
983
- let width;
984
- let height;
985
- if (file.type.startsWith('image/')) {
986
- const dimensions = await this.getImageDimensions(dataUrl);
987
- width = dimensions.width;
988
- height = dimensions.height;
989
- }
990
- // Create pending attachment
991
- const attachment = {
992
- id: this.generateAttachmentId(),
993
- file,
994
- dataUrl,
995
- mimeType: file.type,
996
- fileName: file.name,
997
- sizeBytes: file.size,
998
- width,
999
- height,
1000
- thumbnailUrl: file.type.startsWith('image/') ? dataUrl : undefined
1001
- };
1002
- // Add to pending attachments
1003
- this.pendingAttachments.push(attachment);
1004
- this.attachmentsChanged.emit([...this.pendingAttachments]);
1005
- this.cdr.detectChanges();
1006
- }
1007
- /**
1008
- * Validate a file against settings
1009
- */
1010
- validateFile(file) {
1011
- // Check count limit
1012
- if (this.pendingAttachments.length >= this.maxAttachments) {
1013
- return {
1014
- valid: false,
1015
- error: `Maximum ${this.maxAttachments} attachments allowed`
1016
- };
1017
- }
1018
- // Check size limit
1019
- if (file.size > this.maxAttachmentSizeBytes) {
1020
- const maxMB = (this.maxAttachmentSizeBytes / (1024 * 1024)).toFixed(1);
1021
- const fileMB = (file.size / (1024 * 1024)).toFixed(1);
1022
- return {
1023
- valid: false,
1024
- error: `File size (${fileMB}MB) exceeds maximum (${maxMB}MB)`
1025
- };
1026
- }
1027
- // Check file type
1028
- if (!this.isAcceptedFile(file)) {
1029
- return {
1030
- valid: false,
1031
- error: `File type ${file.type || 'unknown'} not accepted`
1032
- };
1033
- }
1034
- return { valid: true };
1035
- }
1036
- /**
1037
- * Check if file type is accepted
1038
- */
1039
- isAcceptedFile(file) {
1040
- if (this.acceptedFileTypes === '*' || this.acceptedFileTypes === '*/*') {
1041
- return true;
1042
- }
1043
- const acceptedTypes = this.acceptedFileTypes.split(',').map(t => t.trim());
1044
- for (const accepted of acceptedTypes) {
1045
- // Handle universal wildcard */* anywhere in the list
1046
- if (accepted === '*/*') {
1047
- return true;
1048
- }
1049
- // Handle wildcard MIME types like "image/*"
1050
- if (accepted.endsWith('/*')) {
1051
- const category = accepted.slice(0, -2);
1052
- if (file.type.startsWith(category + '/')) {
1053
- return true;
1054
- }
1055
- }
1056
- else if (accepted.startsWith('.')) {
1057
- // Handle file extensions like ".png"
1058
- if (file.name.toLowerCase().endsWith(accepted.toLowerCase())) {
1059
- return true;
1060
- }
1061
- }
1062
- else if (file.type === accepted) {
1063
- // Exact MIME type match
1064
- return true;
1065
- }
1066
- }
1067
- return false;
1068
- }
1069
- /**
1070
- * Read file as data URL
1071
- */
1072
- readFileAsDataUrl(file) {
1073
- return new Promise((resolve) => {
1074
- const reader = new FileReader();
1075
- reader.onload = () => resolve(reader.result);
1076
- reader.onerror = () => resolve(null);
1077
- reader.readAsDataURL(file);
1078
- });
1079
- }
1080
- /**
1081
- * Get image dimensions
1082
- */
1083
- getImageDimensions(dataUrl) {
1084
- return new Promise((resolve) => {
1085
- const img = new Image();
1086
- img.onload = () => {
1087
- resolve({ width: img.naturalWidth, height: img.naturalHeight });
1088
- };
1089
- img.onerror = () => {
1090
- resolve({ width: 0, height: 0 });
1091
- };
1092
- img.src = dataUrl;
1093
- });
1094
- }
1095
- /**
1096
- * Generate unique attachment ID
1097
- */
1098
- generateAttachmentId() {
1099
- return `att_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
1100
- }
1101
- /**
1102
- * Remove a pending attachment by ID
1103
- */
1104
- removeAttachment(id) {
1105
- const index = this.pendingAttachments.findIndex(a => a.id === id);
1106
- if (index !== -1) {
1107
- this.pendingAttachments.splice(index, 1);
1108
- this.attachmentsChanged.emit([...this.pendingAttachments]);
1109
- this.cdr.detectChanges();
1110
- }
1111
- }
1112
- /**
1113
- * Get all pending attachments
1114
- */
1115
- getPendingAttachments() {
1116
- return [...this.pendingAttachments];
1117
- }
1118
- /**
1119
- * Add an artifact as a pending attachment programmatically.
1120
- * Used by the artifact picker to attach artifacts as conversation inputs.
1121
- */
1122
- AddArtifactAttachment(artifact) {
1123
- const attachment = {
1124
- id: crypto.randomUUID(),
1125
- file: null,
1126
- dataUrl: '',
1127
- mimeType: artifact.mimeType,
1128
- fileName: artifact.fileName,
1129
- sizeBytes: artifact.sizeBytes,
1130
- fileID: artifact.fileID,
1131
- source: 'artifact',
1132
- artifactVersionId: artifact.artifactVersionId
1133
- };
1134
- this.pendingAttachments.push(attachment);
1135
- this.attachmentsChanged.emit([...this.pendingAttachments]);
1136
- return attachment;
1137
- }
1138
- /**
1139
- * Clear all pending attachments
1140
- */
1141
- clearPendingAttachments() {
1142
- this.pendingAttachments = [];
1143
- this.attachmentsChanged.emit([]);
1144
- this.cdr.detectChanges();
1145
- }
1146
- /**
1147
- * Handle click on an attachment thumbnail
1148
- */
1149
- onAttachmentClick(attachment) {
1150
- this.attachmentClicked.emit(attachment);
1151
- }
1152
- /**
1153
- * Check if there are any pending attachments
1154
- */
1155
- hasAttachments() {
1156
- return this.pendingAttachments.length > 0;
1157
- }
1158
- /**
1159
- * Trigger file picker programmatically
1160
- */
1161
- openFilePicker() {
1162
- const input = document.createElement('input');
1163
- input.type = 'file';
1164
- // If */* is in the list, accept all files (some browsers don't handle */* correctly)
1165
- input.accept = this.acceptedFileTypes.includes('*/*') ? '' : this.acceptedFileTypes;
1166
- input.multiple = true;
1167
- input.onchange = (e) => this.onFileSelected(e);
1168
- input.click();
1169
- }
1170
- static ɵfac = function MentionEditorComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MentionEditorComponent)(i0.ɵɵdirectiveInject(i1.MentionAutocompleteService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
1171
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MentionEditorComponent, selectors: [["mj-mention-editor"]], viewQuery: function MentionEditorComponent_Query(rf, ctx) { if (rf & 1) {
1172
- i0.ɵɵviewQuery(_c0, 5);
1173
- } if (rf & 2) {
1174
- let _t;
1175
- i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.editorRef = _t.first);
1176
- } }, inputs: { placeholder: "placeholder", disabled: "disabled", currentUser: "currentUser", enableMentions: "enableMentions", enableAttachments: "enableAttachments", maxAttachments: "maxAttachments", maxAttachmentSizeBytes: "maxAttachmentSizeBytes", acceptedFileTypes: "acceptedFileTypes" }, outputs: { valueChange: "valueChange", mentionSelected: "mentionSelected", enterPressed: "enterPressed", attachmentsChanged: "attachmentsChanged", attachmentError: "attachmentError", attachmentClicked: "attachmentClicked" }, standalone: false, features: [i0.ɵɵProvidersFeature([
1177
- {
1178
- provide: NG_VALUE_ACCESSOR,
1179
- useExisting: forwardRef(() => MentionEditorComponent),
1180
- multi: true
1181
- }
1182
- ])], decls: 6, vars: 7, consts: [["editor", ""], [1, "mention-editor-container", 3, "click", "dragover", "dragleave", "drop"], [1, "pending-attachments"], ["contenteditable", "true", 1, "mention-editor", 3, "input", "keydown", "blur", "paste"], [1, "drop-overlay"], [3, "suggestions", "position", "showAbove", "useFixedPositioning", "visible"], [1, "attachment-thumbnail"], [1, "attachment-thumbnail", 3, "click"], [1, "thumbnail-image", 3, "src", "alt"], [1, "thumbnail-placeholder"], ["title", "Remove attachment", 1, "remove-attachment", 3, "click"], [1, "fa-solid", "fa-times"], [1, "fa-solid", "fa-file"], [1, "file-name"], [1, "drop-message"], [1, "fa-solid", "fa-cloud-arrow-up"], [3, "suggestionSelected", "closed", "suggestions", "position", "showAbove", "useFixedPositioning", "visible"]], template: function MentionEditorComponent_Template(rf, ctx) { if (rf & 1) {
1183
- const _r1 = i0.ɵɵgetCurrentView();
1184
- i0.ɵɵelementStart(0, "div", 1);
1185
- i0.ɵɵlistener("click", function MentionEditorComponent_Template_div_click_0_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onContainerClick($event)); })("dragover", function MentionEditorComponent_Template_div_dragover_0_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onDragOver($event)); })("dragleave", function MentionEditorComponent_Template_div_dragleave_0_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onDragLeave($event)); })("drop", function MentionEditorComponent_Template_div_drop_0_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onDrop($event)); });
1186
- i0.ɵɵconditionalCreate(1, MentionEditorComponent_Conditional_1_Template, 3, 0, "div", 2);
1187
- i0.ɵɵelementStart(2, "div", 3, 0);
1188
- i0.ɵɵlistener("input", function MentionEditorComponent_Template_div_input_2_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onInput()); })("keydown", function MentionEditorComponent_Template_div_keydown_2_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onKeyDown($event)); })("blur", function MentionEditorComponent_Template_div_blur_2_listener() { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onBlur()); })("paste", function MentionEditorComponent_Template_div_paste_2_listener($event) { i0.ɵɵrestoreView(_r1); return i0.ɵɵresetView(ctx.onPaste($event)); });
1189
- i0.ɵɵelementEnd();
1190
- i0.ɵɵconditionalCreate(4, MentionEditorComponent_Conditional_4_Template, 5, 0, "div", 4);
1191
- i0.ɵɵconditionalCreate(5, MentionEditorComponent_Conditional_5_Template, 1, 5, "mj-mention-dropdown", 5);
1192
- i0.ɵɵelementEnd();
1193
- } if (rf & 2) {
1194
- i0.ɵɵclassProp("drag-over", ctx.isDragOver);
1195
- i0.ɵɵadvance();
1196
- i0.ɵɵconditional(ctx.pendingAttachments.length > 0 ? 1 : -1);
1197
- i0.ɵɵadvance();
1198
- i0.ɵɵattribute("contenteditable", !ctx.disabled)("data-placeholder", ctx.placeholder);
1199
- i0.ɵɵadvance(2);
1200
- i0.ɵɵconditional(ctx.isDragOver ? 4 : -1);
1201
- i0.ɵɵadvance();
1202
- i0.ɵɵconditional(ctx.showMentionDropdown && ctx.enableMentions ? 5 : -1);
1203
- } }, dependencies: [i2.MentionDropdownComponent], styles: [".mention-editor-container[_ngcontent-%COMP%] {\n position: relative;\n width: 100%;\n display: block;\n}\n\n.mention-editor-container.drag-over[_ngcontent-%COMP%] {\n background: color-mix(in srgb, var(--mj-brand-primary) 5%, transparent);\n border-color: var(--mj-brand-primary);\n}\n\n.mention-editor[_ngcontent-%COMP%] {\n display: block;\n width: 100%;\n min-height: 100px;\n max-height: 300px;\n padding: 7px 3.5rem 7px 12px;\n outline: none;\n border: none;\n background: transparent;\n font-family: inherit;\n font-size: 1rem;\n line-height: 1.5;\n overflow-y: auto;\n overflow-x: hidden;\n word-wrap: break-word;\n white-space: pre-wrap;\n cursor: text;\n user-select: text;\n box-sizing: border-box;\n}\n.mention-editor[_ngcontent-%COMP%]:empty:before {\n content: attr(data-placeholder);\n color: var(--mj-text-muted);\n pointer-events: none;\n position: absolute;\n}\n.mention-editor[_ngcontent-%COMP%]:focus {\n outline: none;\n}\n.mention-editor[contenteditable=false][_ngcontent-%COMP%] {\n cursor: not-allowed;\n opacity: 0.6;\n background: var(--mj-bg-surface-sunken);\n}\n@media (max-width: 768px) {\n .mention-editor[_ngcontent-%COMP%] {\n font-size: 16px;\n padding: 5px;\n padding-right: 3rem;\n }\n}\n\n .mention-chip {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 12px;\n margin: 0 3px;\n border-radius: 16px;\n font-size: 13px;\n font-weight: 600;\n cursor: default;\n user-select: none;\n vertical-align: middle;\n white-space: nowrap;\n pointer-events: all;\n -webkit-user-modify: read-only;\n -moz-user-modify: read-only;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n border: 2px solid color-mix(in srgb, var(--mj-brand-primary) 40%, transparent);\n box-shadow: var(--mj-shadow-md);\n animation: _ngcontent-%COMP%_chipInsert 0.15s ease-out;\n}\n .mention-chip i {\n font-size: 12px;\n opacity: 0.95;\n}\n .mention-chip[data-mention-type=user] {\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n border: 2px solid color-mix(in srgb, var(--mj-brand-primary) 40%, transparent);\n}\n .mention-chip:hover {\n transform: translateY(-1px);\n box-shadow: var(--mj-shadow-lg);\n transition: all 0.2s ease;\n}\n .mention-chip:focus, .mention-chip.selected {\n outline: 2px solid var(--mj-brand-primary);\n outline-offset: 2px;\n}\n@keyframes _ngcontent-%COMP%_chipInsert {\n 0% {\n transform: scale(0.8);\n opacity: 0;\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n}\n\n.mention-editor[_ngcontent-%COMP%] .mention-chip[_ngcontent-%COMP%] + .mention-chip[_ngcontent-%COMP%] {\n margin-left: 4px;\n}\n.mention-editor[_ngcontent-%COMP%] br[_ngcontent-%COMP%] {\n display: block;\n content: \"\";\n margin: 0;\n}\n\n.mention-editor[_ngcontent-%COMP%]::-webkit-scrollbar {\n width: 6px;\n}\n.mention-editor[_ngcontent-%COMP%]::-webkit-scrollbar-track {\n background: transparent;\n}\n.mention-editor[_ngcontent-%COMP%]::-webkit-scrollbar-thumb {\n background: color-mix(in srgb, var(--mj-text-primary) 20%, transparent);\n border-radius: 3px;\n}\n.mention-editor[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover {\n background: color-mix(in srgb, var(--mj-text-primary) 30%, transparent);\n}\n\n\n\n\n.pending-attachments[_ngcontent-%COMP%] {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid color-mix(in srgb, var(--mj-text-primary) 8%, transparent);\n background: color-mix(in srgb, var(--mj-text-primary) 2%, transparent);\n}\n\n.attachment-thumbnail[_ngcontent-%COMP%] {\n position: relative;\n width: 80px;\n height: 80px;\n border-radius: 8px;\n overflow: hidden;\n cursor: pointer;\n transition: transform 0.2s, box-shadow 0.2s;\n background: var(--mj-bg-surface-sunken);\n border: 1px solid color-mix(in srgb, var(--mj-text-primary) 10%, transparent);\n}\n\n.attachment-thumbnail[_ngcontent-%COMP%]:hover {\n transform: scale(1.05);\n box-shadow: var(--mj-shadow-lg);\n}\n\n.thumbnail-image[_ngcontent-%COMP%] {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.thumbnail-placeholder[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 8px;\n color: var(--mj-text-secondary);\n}\n\n.thumbnail-placeholder[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 24px;\n margin-bottom: 4px;\n color: var(--mj-text-muted);\n}\n\n.thumbnail-placeholder[_ngcontent-%COMP%] .file-name[_ngcontent-%COMP%] {\n font-size: 10px;\n text-align: center;\n word-break: break-all;\n line-height: 1.2;\n max-height: 36px;\n overflow: hidden;\n}\n\n.remove-attachment[_ngcontent-%COMP%] {\n position: absolute;\n top: 4px;\n right: 4px;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: color-mix(in srgb, var(--mj-text-primary) 60%, transparent);\n color: var(--mj-text-inverse);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s, background 0.2s;\n}\n\n.attachment-thumbnail[_ngcontent-%COMP%]:hover .remove-attachment[_ngcontent-%COMP%] {\n opacity: 1;\n}\n\n.remove-attachment[_ngcontent-%COMP%]:hover {\n background: color-mix(in srgb, var(--mj-status-error) 90%, transparent);\n}\n\n.remove-attachment[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 10px;\n}\n\n\n\n.drop-overlay[_ngcontent-%COMP%] {\n position: absolute;\n inset: 0;\n background: color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n backdrop-filter: blur(2px);\n border: 2px dashed var(--mj-brand-primary);\n border-radius: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 100;\n pointer-events: none;\n}\n\n.drop-message[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n color: var(--mj-brand-primary);\n font-weight: 600;\n}\n\n.drop-message[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 32px;\n}\n\n.drop-message[_ngcontent-%COMP%] span[_ngcontent-%COMP%] {\n font-size: 14px;\n}"] });
1204
- }
1205
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MentionEditorComponent, [{
1206
- type: Component,
1207
- args: [{ standalone: false, selector: 'mj-mention-editor', providers: [
1208
- {
1209
- provide: NG_VALUE_ACCESSOR,
1210
- useExisting: forwardRef(() => MentionEditorComponent),
1211
- multi: true
1212
- }
1213
- ], template: "<div class=\"mention-editor-container\"\n [class.drag-over]=\"isDragOver\"\n (click)=\"onContainerClick($event)\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (drop)=\"onDrop($event)\">\n\n <!-- Pending Attachments Preview -->\n @if (pendingAttachments.length > 0) {\n <div class=\"pending-attachments\">\n @for (attachment of pendingAttachments; track attachment) {\n <div class=\"attachment-thumbnail\"\n (click)=\"onAttachmentClick(attachment)\">\n @if (attachment.thumbnailUrl) {\n <img\n [src]=\"attachment.thumbnailUrl\"\n [alt]=\"attachment.fileName\"\n class=\"thumbnail-image\">\n }\n @if (!attachment.thumbnailUrl) {\n <div class=\"thumbnail-placeholder\">\n <i class=\"fa-solid fa-file\"></i>\n <span class=\"file-name\">{{ attachment.fileName }}</span>\n </div>\n }\n <button class=\"remove-attachment\"\n (click)=\"removeAttachment(attachment.id); $event.stopPropagation()\"\n title=\"Remove attachment\">\n <i class=\"fa-solid fa-times\"></i>\n </button>\n </div>\n }\n </div>\n }\n\n <div\n #editor\n class=\"mention-editor\"\n contenteditable=\"true\"\n [attr.contenteditable]=\"!disabled\"\n [attr.data-placeholder]=\"placeholder\"\n (input)=\"onInput()\"\n (keydown)=\"onKeyDown($event)\"\n (blur)=\"onBlur()\"\n (paste)=\"onPaste($event)\"\n ></div>\n\n <!-- Drag & Drop Overlay -->\n @if (isDragOver) {\n <div class=\"drop-overlay\">\n <div class=\"drop-message\">\n <i class=\"fa-solid fa-cloud-arrow-up\"></i>\n <span>Drop files here</span>\n </div>\n </div>\n }\n\n <!-- Mention Dropdown -->\n @if (showMentionDropdown && enableMentions) {\n <mj-mention-dropdown\n [suggestions]=\"mentionSuggestions\"\n [position]=\"mentionDropdownPosition\"\n [showAbove]=\"mentionDropdownShowAbove\"\n [useFixedPositioning]=\"true\"\n [visible]=\"true\"\n (suggestionSelected)=\"onMentionSelected($event)\"\n (closed)=\"closeMentionDropdown()\">\n </mj-mention-dropdown>\n }\n</div>\n", styles: [".mention-editor-container {\n position: relative;\n width: 100%;\n display: block;\n}\n\n.mention-editor-container.drag-over {\n background: color-mix(in srgb, var(--mj-brand-primary) 5%, transparent);\n border-color: var(--mj-brand-primary);\n}\n\n.mention-editor {\n display: block;\n width: 100%;\n min-height: 100px;\n max-height: 300px;\n padding: 7px 3.5rem 7px 12px;\n outline: none;\n border: none;\n background: transparent;\n font-family: inherit;\n font-size: 1rem;\n line-height: 1.5;\n overflow-y: auto;\n overflow-x: hidden;\n word-wrap: break-word;\n white-space: pre-wrap;\n cursor: text;\n user-select: text;\n box-sizing: border-box;\n}\n.mention-editor:empty:before {\n content: attr(data-placeholder);\n color: var(--mj-text-muted);\n pointer-events: none;\n position: absolute;\n}\n.mention-editor:focus {\n outline: none;\n}\n.mention-editor[contenteditable=false] {\n cursor: not-allowed;\n opacity: 0.6;\n background: var(--mj-bg-surface-sunken);\n}\n@media (max-width: 768px) {\n .mention-editor {\n font-size: 16px;\n padding: 5px;\n padding-right: 3rem;\n }\n}\n\n::ng-deep .mention-chip {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 4px 12px;\n margin: 0 3px;\n border-radius: 16px;\n font-size: 13px;\n font-weight: 600;\n cursor: default;\n user-select: none;\n vertical-align: middle;\n white-space: nowrap;\n pointer-events: all;\n -webkit-user-modify: read-only;\n -moz-user-modify: read-only;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n border: 2px solid color-mix(in srgb, var(--mj-brand-primary) 40%, transparent);\n box-shadow: var(--mj-shadow-md);\n animation: chipInsert 0.15s ease-out;\n}\n::ng-deep .mention-chip i {\n font-size: 12px;\n opacity: 0.95;\n}\n::ng-deep .mention-chip[data-mention-type=user] {\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n border: 2px solid color-mix(in srgb, var(--mj-brand-primary) 40%, transparent);\n}\n::ng-deep .mention-chip:hover {\n transform: translateY(-1px);\n box-shadow: var(--mj-shadow-lg);\n transition: all 0.2s ease;\n}\n::ng-deep .mention-chip:focus, ::ng-deep .mention-chip.selected {\n outline: 2px solid var(--mj-brand-primary);\n outline-offset: 2px;\n}\n@keyframes chipInsert {\n 0% {\n transform: scale(0.8);\n opacity: 0;\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n}\n\n.mention-editor .mention-chip + .mention-chip {\n margin-left: 4px;\n}\n.mention-editor br {\n display: block;\n content: \"\";\n margin: 0;\n}\n\n.mention-editor::-webkit-scrollbar {\n width: 6px;\n}\n.mention-editor::-webkit-scrollbar-track {\n background: transparent;\n}\n.mention-editor::-webkit-scrollbar-thumb {\n background: color-mix(in srgb, var(--mj-text-primary) 20%, transparent);\n border-radius: 3px;\n}\n.mention-editor::-webkit-scrollbar-thumb:hover {\n background: color-mix(in srgb, var(--mj-text-primary) 30%, transparent);\n}\n\n/* ==================== Attachment Styles ==================== */\n\n.pending-attachments {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 8px 12px;\n border-bottom: 1px solid color-mix(in srgb, var(--mj-text-primary) 8%, transparent);\n background: color-mix(in srgb, var(--mj-text-primary) 2%, transparent);\n}\n\n.attachment-thumbnail {\n position: relative;\n width: 80px;\n height: 80px;\n border-radius: 8px;\n overflow: hidden;\n cursor: pointer;\n transition: transform 0.2s, box-shadow 0.2s;\n background: var(--mj-bg-surface-sunken);\n border: 1px solid color-mix(in srgb, var(--mj-text-primary) 10%, transparent);\n}\n\n.attachment-thumbnail:hover {\n transform: scale(1.05);\n box-shadow: var(--mj-shadow-lg);\n}\n\n.thumbnail-image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.thumbnail-placeholder {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n height: 100%;\n padding: 8px;\n color: var(--mj-text-secondary);\n}\n\n.thumbnail-placeholder i {\n font-size: 24px;\n margin-bottom: 4px;\n color: var(--mj-text-muted);\n}\n\n.thumbnail-placeholder .file-name {\n font-size: 10px;\n text-align: center;\n word-break: break-all;\n line-height: 1.2;\n max-height: 36px;\n overflow: hidden;\n}\n\n.remove-attachment {\n position: absolute;\n top: 4px;\n right: 4px;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n background: color-mix(in srgb, var(--mj-text-primary) 60%, transparent);\n color: var(--mj-text-inverse);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n transition: opacity 0.2s, background 0.2s;\n}\n\n.attachment-thumbnail:hover .remove-attachment {\n opacity: 1;\n}\n\n.remove-attachment:hover {\n background: color-mix(in srgb, var(--mj-status-error) 90%, transparent);\n}\n\n.remove-attachment i {\n font-size: 10px;\n}\n\n/* Drop Overlay */\n.drop-overlay {\n position: absolute;\n inset: 0;\n background: color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n backdrop-filter: blur(2px);\n border: 2px dashed var(--mj-brand-primary);\n border-radius: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 100;\n pointer-events: none;\n}\n\n.drop-message {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n color: var(--mj-brand-primary);\n font-weight: 600;\n}\n\n.drop-message i {\n font-size: 32px;\n}\n\n.drop-message span {\n font-size: 14px;\n}\n"] }]
1214
- }], () => [{ type: i1.MentionAutocompleteService }, { type: i0.ChangeDetectorRef }], { editorRef: [{
1215
- type: ViewChild,
1216
- args: ['editor', { static: false }]
1217
- }], placeholder: [{
1218
- type: Input
1219
- }], disabled: [{
1220
- type: Input
1221
- }], currentUser: [{
1222
- type: Input
1223
- }], enableMentions: [{
1224
- type: Input
1225
- }], enableAttachments: [{
1226
- type: Input
1227
- }], maxAttachments: [{
1228
- type: Input
1229
- }], maxAttachmentSizeBytes: [{
1230
- type: Input
1231
- }], acceptedFileTypes: [{
1232
- type: Input
1233
- }], valueChange: [{
1234
- type: Output
1235
- }], mentionSelected: [{
1236
- type: Output
1237
- }], enterPressed: [{
1238
- type: Output
1239
- }], attachmentsChanged: [{
1240
- type: Output
1241
- }], attachmentError: [{
1242
- type: Output
1243
- }], attachmentClicked: [{
1244
- type: Output
1245
- }] }); })();
1246
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MentionEditorComponent, { className: "MentionEditorComponent", filePath: "src/lib/components/mention/mention-editor.component.ts", lineNumber: 69 }); })();
1247
- //# sourceMappingURL=mention-editor.component.js.map