-
Notifications
You must be signed in to change notification settings - Fork 20
/
TextEditorGroupDisplay.razor
52 lines (47 loc) · 1.87 KB
/
TextEditorGroupDisplay.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@using Luthetus.Common.RazorLib.Tabs.Displays
@using Luthetus.TextEditor.RazorLib.TextEditors.Displays
<div class="luth_te_text-editor-group @CssClassString"
style="@CssStyleString"
id="@HtmlId">
@{
var textEditorGroup = TextEditorGroupStateWrap.Value.GroupList.FirstOrDefault(
x => x.GroupKey == TextEditorGroupKey);
}
@if (textEditorGroup is not null)
{
<div class="luth_te_text-editor-group-tabs-list">
<TabListDisplay @ref="_tabListDisplay"
TabList="@GetTabList(textEditorGroup)"/>
</div>
<div class="luth_te_text-editor-group-active-view-model">
@{
var textEditorModel = TextEditorService.ViewModelApi.GetModelOrDefault(
textEditorGroup.ActiveViewModelKey);
if (textEditorModel is null)
{
<text>No editors are open currently</text>
}
else
{
// Add a ShouldRenderBoundary here? (2024-08-04)
// If this group component re-renders, could it cause a double render
// due to the TextEditorViewModelDisplay re-rendering because:
// - It is a child of this component
// - It is subscribed to the state change
//
// (2024-09-07)
// It turns out that this component specifically tells the TabListDisplay to invoke
// its StateHasChanged when the view model changes.
<TextEditorViewModelDisplay TextEditorViewModelKey="textEditorGroup.ActiveViewModelKey"
ViewModelDisplayOptions="ViewModelDisplayOptions"/>
}
}
</div>
}
else
{
<div>
Group not found
</div>
}
</div>