Skip to content

Commit bbc3a61

Browse files
dimodidimodi
authored andcommitted
Polish code examples
1 parent 8f3f351 commit bbc3a61

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

knowledge-base/editor-focus-event.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ The required approach depends on the [Editor `EditMode`](slug:editor-edit-modes-
4848
4949
@inject IJSRuntime js
5050
51-
<div @onfocusin="@OnEditorFocus1">
52-
<TelerikEditor @bind-Value="@EditorValue1"
51+
<div @onfocusin="@OnDivEditorFocus">
52+
<TelerikEditor @bind-Value="@EditorValue"
5353
Tools="@EditorToolSets.All"
5454
EditMode="@EditorEditMode.Div"
5555
Height="300px">
@@ -69,15 +69,15 @@ The required approach depends on the [Editor `EditMode`](slug:editor-edit-modes-
6969
@code {
7070
#nullable enable
7171
72-
private string EditorValue1 { get; set; } = @"<p>foo 1</p><p>bar 1</p>";
72+
private string EditorValue { get; set; } = @"<p>foo 1</p><p>bar 1</p>";
7373
74-
private async Task OnEditorFocus1()
74+
private async Task OnDivEditorFocus()
7575
{
7676
bool isEditorContentFocused = await js.InvokeAsync<bool>("isEditorDivFocused");
7777
7878
if (isEditorContentFocused)
7979
{
80-
EditorValue1 = $"<p>Editor content DIV was focused at {DateTime.Now.ToLongTimeString()}.</p>";
80+
EditorValue = $"<p>Editor content DIV was focused at {DateTime.Now.ToLongTimeString()}.</p>";
8181
}
8282
}
8383
}
@@ -100,9 +100,9 @@ The required approach depends on the [Editor `EditMode`](slug:editor-edit-modes-
100100
101101
@inject IJSRuntime js
102102
103-
<TelerikEditor @bind-Value="@EditorValue2"
103+
<TelerikEditor @bind-Value="@EditorValue"
104104
Tools="@EditorToolSets.All"
105-
Id="editor2"
105+
Id="@EditorId"
106106
Height="300px">
107107
</TelerikEditor>
108108
@@ -133,15 +133,17 @@ The required approach depends on the [Editor `EditMode`](slug:editor-edit-modes-
133133
@code {
134134
#nullable enable
135135
136-
private string EditorValue2 { get; set; } = @"<p>foo 2</p><p>bar 2</p>";
136+
private string EditorValue { get; set; } = @"<p>foo 2</p><p>bar 2</p>";
137+
138+
private const string EditorId = "iframe-editor";
137139
138140
// Replace __Main with your Razor component type
139-
private DotNetObjectReference<__Main>? DotNetRef { get; set; }
141+
private DotNetObjectReference<Home>? DotNetRef { get; set; }
140142
141143
[JSInvokable("OnEditorFocus2")]
142144
public void OnEditorFocus2()
143145
{
144-
EditorValue2 = $"<p>Editor content IFRAME was focused at {DateTime.Now.ToLongTimeString()}.</p>";
146+
EditorValue = $"<p>Editor content IFRAME was focused at {DateTime.Now.ToLongTimeString()}.</p>";
145147
StateHasChanged();
146148
}
147149
@@ -156,7 +158,7 @@ The required approach depends on the [Editor `EditMode`](slug:editor-edit-modes-
156158
{
157159
await Task.Delay(1); // wait for HTML to render
158160
159-
await js.InvokeVoidAsync("attachIframeFocusHandler", "editor2", DotNetRef);
161+
await js.InvokeVoidAsync("attachIframeFocusHandler", EditorId, DotNetRef);
160162
}
161163
162164
await base.OnAfterRenderAsync(firstRender);

0 commit comments

Comments
 (0)