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
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" />
|
<MudThemeProvider Theme="@AppThemeProvider.GetTheme()" IsDarkMode="true" />
|
||||||
<MudPopoverProvider/>
|
<MudPopoverProvider/>
|
||||||
<MudDialogProvider/>
|
<MudDialogProvider/>
|
||||||
<MudSnackbarProvider/>
|
<MudSnackbarProvider/>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
@* <NavMenu/> *@
|
@* <NavMenu/> *@
|
||||||
</MudDrawer>
|
</MudDrawer>
|
||||||
<MudMainContent>
|
<MudMainContent>
|
||||||
<MudContainer Class="px-8 py-6">
|
<MudContainer MaxWidth="MaxWidth.False" Class="mt-2">
|
||||||
@Body
|
@Body
|
||||||
</MudContainer>
|
</MudContainer>
|
||||||
</MudMainContent>
|
</MudMainContent>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@page "/"
|
@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
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="BlazorMonaco" Version="3.3.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" Version="9.0.0" />
|
||||||
<PackageReference Include="MudBlazor" Version="8.0.0-rc.2" />
|
<PackageReference Include="MudBlazor" Version="8.0.0-rc.2" />
|
||||||
|
|||||||
@@ -10,3 +10,6 @@
|
|||||||
@using MudBlazor
|
@using MudBlazor
|
||||||
@using SharpIDE.Photino.Layout
|
@using SharpIDE.Photino.Layout
|
||||||
@using SharpIDE.Photino.Components
|
@using SharpIDE.Photino.Components
|
||||||
|
@using BlazorMonaco
|
||||||
|
@using BlazorMonaco.Editor
|
||||||
|
@using BlazorMonaco.Languages
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</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="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||||
|
<script src="_framework/blazor.webview.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user