Skip to content

Commit c5a8073

Browse files
committed
fix: reset file upload form after file was uploaded
1 parent 897bf6c commit c5a8073

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

libs/block-note-angular/src/lib/components/bna-file-panel/bna-file-panel.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</hlm-tabs-list>
77
<div hlmTabsContent="upload" class="p-3">
88
<input
9+
[formControl]="fileControl"
910
class="w-full"
1011
hlmInput
1112
type="file"

libs/block-note-angular/src/lib/components/bna-file-panel/bna-file-panel.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, effect } from '@angular/core';
2-
import { FormsModule } from '@angular/forms';
2+
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
33
import {
44
BlockFromConfig,
55
BlockNoteEditor,
@@ -26,13 +26,15 @@ import { BlockNoteAngularService } from '../../services/block-note-angular.servi
2626
FormsModule,
2727
HlmTabsTriggerDirective,
2828
HlmTabsContentDirective,
29+
ReactiveFormsModule,
2930
],
3031
templateUrl: './bna-file-panel.component.html',
3132
})
3233
export class BnaFilePanelComponent {
3334
private focusedBlock?: BlockFromConfig<FileBlockConfig, any, any>;
3435

3536
embedInputText = '';
37+
fileControl = new FormControl();
3638

3739
constructor(private blockNoteAngularService: BlockNoteAngularService) {
3840
effect(() => {
@@ -71,6 +73,8 @@ export class BnaFilePanelComponent {
7173
const fileUrl = await editor.uploadFile(file);
7274

7375
this.updateBlockWithEmbedFileUrl(this.focusedBlock, editor, fileUrl);
76+
this.focusedBlock = undefined;
77+
this.fileControl.reset();
7478
}
7579

7680
insertEmbedFile(embedFileUrl: string) {

0 commit comments

Comments
 (0)