@@ -28,6 +28,12 @@ public sealed partial class MudHtmlEditor : IAsyncDisposable
2828 [ Parameter ]
2929 public EventCallback < string > HtmlChanged { get ; set ; }
3030
31+ [ Parameter ]
32+ public string Text { get ; set ; } = "" ;
33+
34+ [ Parameter ]
35+ public EventCallback < string > TextChanged { get ; set ; }
36+
3137 [ Parameter ]
3238 public bool Resizable { get ; set ; } = true ;
3339
@@ -44,10 +50,22 @@ public async Task SetHtml(string html)
4450 if ( _quill is not null )
4551 await _quill . InvokeVoidAsync ( "setHtml" , html ) ;
4652
47- if ( HtmlChanged . HasDelegate )
48- await HtmlChanged . InvokeAsync ( html ) ;
53+ HandleHtmlContentChanged ( html ) ;
54+ HandleTextContentChanged ( await GetText ( ) ) ;
55+ }
4956
50- Html = html ;
57+ public async Task < string > GetHtml ( )
58+ {
59+ if ( _quill is not null )
60+ return await _quill . InvokeAsync < string > ( "getHtml" ) ;
61+ return "" ;
62+ }
63+
64+ public async Task < string > GetText ( )
65+ {
66+ if ( _quill is not null )
67+ return await _quill . InvokeAsync < string > ( "getText" ) ;
68+ return "" ;
5169 }
5270
5371 protected override async Task OnAfterRenderAsync ( bool firstRender )
@@ -74,6 +92,15 @@ public async void HandleHtmlContentChanged(string html)
7492 await HtmlChanged . InvokeAsync ( html ) ;
7593 }
7694
95+ [ JSInvokable ]
96+ public async void HandleTextContentChanged ( string text )
97+ {
98+ if ( Text == text ) return ; // nothing changed
99+
100+ Text = text ;
101+ await TextChanged . InvokeAsync ( text ) ;
102+ }
103+
77104 async ValueTask IAsyncDisposable . DisposeAsync ( )
78105 {
79106 if ( _quill is not null )
0 commit comments