monaco
This commit is contained in:
39
src/SharpIDE.Photino/Components/CodeViewer.razor
Normal file
39
src/SharpIDE.Photino/Components/CodeViewer.razor
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -10,3 +10,6 @@
|
||||
@using MudBlazor
|
||||
@using SharpIDE.Photino.Layout
|
||||
@using SharpIDE.Photino.Components
|
||||
@using BlazorMonaco
|
||||
@using BlazorMonaco.Editor
|
||||
@using BlazorMonaco.Languages
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user