add: Monaco编辑器

This commit is contained in:
jackfiled 2023-10-14 22:12:19 +08:00
parent d102b47da8
commit d8edc6c28b
6 changed files with 34 additions and 1 deletions

View File

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AntDesign" Version="0.15.5" /> <PackageReference Include="AntDesign" Version="0.15.5" />
<PackageReference Include="BlazorMonaco" Version="3.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,19 @@
@page "/editor"
<Layout>
<Content>
<div class="editor-zone">
<StandaloneCodeEditor ConstructionOptions="GetEditorConstructionOptions" Id="my-editor-instance"/>
</div>
</Content>
</Layout>
@code {
private StandaloneEditorConstructionOptions GetEditorConstructionOptions(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
Language = "yaml"
};
}
}

View File

@ -0,0 +1,3 @@
.editor-zone {
min-height: calc(100vh - 64px);
}

View File

@ -27,7 +27,10 @@
<a class="dismiss">🗙</a> <a class="dismiss">🗙</a>
</div> </div>
<script src="_framework/blazor.server.js"></script>
<script src="_content/AntDesign/js/ant-design-blazor.js"></script> <script src="_content/AntDesign/js/ant-design-blazor.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="_framework/blazor.server.js"></script>
</body> </body>
</html> </html>

View File

@ -2,5 +2,8 @@
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using AntDesign @using AntDesign
@using BlazorMonaco
@using BlazorMonaco.Editor
@using BlazorMonaco.Languages
@using Frontend @using Frontend
@using Frontend.Shared @using Frontend.Shared

View File

@ -30,3 +30,7 @@
body { body {
overflow: hidden; overflow: hidden;
} }
.monaco-editor-container {
min-height: 100%;
}