use monaco editor for quizzes

This commit is contained in:
2023-11-09 15:15:22 -07:00
parent ea6271428a
commit 4a113fc8ca
11 changed files with 87 additions and 26 deletions

View File

@@ -0,0 +1,46 @@
@using BlazorMonaco
@using BlazorMonaco.Editor
@code {
[Parameter, EditorRequired]
public string Value { get; set; }
[Parameter, EditorRequired]
public Action<string> OnChange { get; set; }
private StandaloneCodeEditor _editor = null!;
private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
Language = "markdown",
Theme = "vs-dark",
TabSize = 2,
Value = Value,
Minimap = new EditorMinimapOptions { Enabled = false },
LineNumbers = "off",
LineDecorationsWidth = 0,
WordWrap = "on",
AutomaticLayout = true,
FontFamily = "DM Mono, monospace",
FontSize = 16,
};
}
private async Task OnDidChangeModelContent()
{
var newValue = await _editor.GetValue();
OnChange(newValue);
}
}
<StandaloneCodeEditor
@ref="_editor"
Id="sample-code-editor-123"
ConstructionOptions="EditorConstructionOptions"
OnDidChangeModelContent="OnDidChangeModelContent"
/>