|
24 | 24 | </div> |
25 | 25 | } |
26 | 26 |
|
27 | | - <div class="antdx-sender-editor"> |
| 27 | + <div class="antdx-sender-editor" @ref="Editor"> |
| 28 | + @if (AttachmentsEnabled) |
| 29 | + { |
| 30 | + <InputFile class="antdx-sender-file-input" |
| 31 | + multiple="@Multiple" |
| 32 | + disabled="@(Disabled || ReadOnly)" |
| 33 | + accept="@Accept" |
| 34 | + @attributes="InputAttributes" |
| 35 | + OnChange="@HandleFiles" /> |
| 36 | + } |
| 37 | + |
28 | 38 | @if (ShowAttachmentsPanel) |
29 | 39 | { |
30 | 40 | <div class="antdx-sender-attachments-panel"> |
|
192 | 202 |
|
193 | 203 | @code { |
194 | 204 | private IJSObjectReference? _module; |
| 205 | + private IJSObjectReference? _senderDropZone; |
| 206 | + private ElementReference Editor; |
195 | 207 | private ElementReference TextArea; |
196 | 208 |
|
197 | 209 | [Parameter] public string? Value { get; set; } |
|
283 | 295 | private DotNetObjectReference<XSender>? _speechRef; |
284 | 296 | private string? _speechBaseValue; |
285 | 297 |
|
| 298 | + private IDictionary<string, object>? InputAttributes => |
| 299 | + Directory |
| 300 | + ? new Dictionary<string, object> |
| 301 | + { |
| 302 | + ["webkitdirectory"] = true, |
| 303 | + ["directory"] = true, |
| 304 | + } |
| 305 | + : null; |
| 306 | + |
286 | 307 | protected override async Task OnAfterRenderAsync(bool firstRender) |
287 | 308 | { |
288 | 309 | if (firstRender) |
|
299 | 320 | { |
300 | 321 | return; |
301 | 322 | } |
| 323 | + |
| 324 | + if (AttachmentsEnabled) |
| 325 | + { |
| 326 | + try |
| 327 | + { |
| 328 | + _senderDropZone = await _module.InvokeAsync<IJSObjectReference>( |
| 329 | + "wireAttachmentDropZone", |
| 330 | + Editor, |
| 331 | + AttachmentsDragHover, |
| 332 | + AttachmentsPastable, |
| 333 | + Disabled || ReadOnly); |
| 334 | + } |
| 335 | + catch (JSException) |
| 336 | + { |
| 337 | + } |
| 338 | + catch (InvalidOperationException) |
| 339 | + { |
| 340 | + } |
| 341 | + } |
302 | 342 | } |
303 | 343 |
|
304 | 344 | await ResizeAsync(); |
|
310 | 350 | _speechRef?.Dispose(); |
311 | 351 | _speechRef = null; |
312 | 352 |
|
| 353 | + if (_senderDropZone is not null) |
| 354 | + { |
| 355 | + await _senderDropZone.DisposeAsync(); |
| 356 | + } |
| 357 | + |
313 | 358 | if (_module is not null) |
314 | 359 | { |
315 | 360 | await _module.DisposeAsync(); |
|
456 | 501 | files = files.Take(MaxAttachments.Value).ToArray(); |
457 | 502 | } |
458 | 503 |
|
| 504 | + if (files.Count > 0) |
| 505 | + { |
| 506 | + _attachmentsPanelTouched = false; |
| 507 | + _attachmentsPanelOpen = true; |
| 508 | + } |
| 509 | + |
459 | 510 | await OnFilesSelected.InvokeAsync(files); |
460 | 511 | } |
461 | 512 |
|
|
0 commit comments