This commit is contained in:
Matt Parker [SSW]
2025-01-10 20:23:38 +10:00
parent 006b2dddaa
commit b78f30af35
6 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,39 @@
<style>
#my-editor-id {
height: calc(100vh - 100px);
}
</style>
<StandaloneCodeEditor Id="my-editor-id" ConstructionOptions="@EditorConstructionOptions" />
@code {
[Parameter, EditorRequired]
public string FilePath { get; set; } = null!;
private string? _fileContent;
private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
AutomaticLayout = true,
Language = "csharp",
Theme = "vs-dark",
ScrollBeyondLastLine = false,
FontSize = 18,
Value = _fileContent
};
}
protected override async Task OnInitializedAsync()
{
var fileInfo = new FileInfo(FilePath);
if (!fileInfo.Exists)
{
throw new FileNotFoundException($"File not found: {FilePath}");
}
var fileContent = await File.ReadAllTextAsync(FilePath);
_fileContent = fileContent;
}
}

View File

@@ -1,6 +1,6 @@
@inherits LayoutComponentBase
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" />
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" IsDarkMode="true" />
<MudPopoverProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
@@ -14,7 +14,7 @@
@* <NavMenu/> *@
</MudDrawer>
<MudMainContent>
<MudContainer Class="px-8 py-6">
<MudContainer MaxWidth="MaxWidth.False" Class="mt-2">
@Body
</MudContainer>
</MudMainContent>

View File

@@ -1,6 +1,6 @@
@page "/"
<MudText>Welcome to a new Photino Blazor app!</MudText>
<CodeViewer FilePath="D:\matth\Documents\Git\amazon\src\Utilities\ClientPortal.Utilities.DebugConsole\DataversePlayground.cs" />
@code
{

View File

@@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BlazorMonaco" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.0" />
<PackageReference Include="MudBlazor" Version="8.0.0-rc.2" />

View File

@@ -10,3 +10,6 @@
@using MudBlazor
@using SharpIDE.Photino.Layout
@using SharpIDE.Photino.Components
@using BlazorMonaco
@using BlazorMonaco.Editor
@using BlazorMonaco.Languages

View File

@@ -18,7 +18,10 @@
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webview.js"></script>
<script src="_content/BlazorMonaco/jsInterop.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
<script src="_framework/blazor.webview.js"></script>
</body>
</html>