mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
attempting to fix monaco
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
@* @rendermode @(new InteractiveServerRenderMode(prerender: false)) *@
|
||||
@implements IDisposable
|
||||
@using BlazorMonaco
|
||||
@using BlazorMonaco.Editor
|
||||
|
||||
@@ -9,10 +10,12 @@
|
||||
[Parameter, EditorRequired]
|
||||
public Action<string> OnChange { get; set; } = default!;
|
||||
|
||||
private string randomId = "monaco-editor-" + BitConverter.ToString(new byte[16].Select(b => (byte)new Random().Next(256)).ToArray()).Replace("-", "");
|
||||
|
||||
private string randomId = "monaco-editor-" + BitConverter.ToString(new byte[16].Select(b => (byte)new
|
||||
Random().Next(256)).ToArray()).Replace("-", "");
|
||||
|
||||
|
||||
private StandaloneCodeEditor _editor = null!;
|
||||
private StandaloneCodeEditor? _editor = null;
|
||||
|
||||
private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor)
|
||||
{
|
||||
@@ -29,7 +32,8 @@
|
||||
AutomaticLayout = true,
|
||||
FontFamily = "Roboto-mono",
|
||||
FontSize = 16,
|
||||
Padding = new EditorPaddingOptions() {
|
||||
Padding = new EditorPaddingOptions()
|
||||
{
|
||||
Top = 10
|
||||
}
|
||||
};
|
||||
@@ -37,14 +41,19 @@
|
||||
|
||||
private async Task OnDidChangeModelContent()
|
||||
{
|
||||
if (_editor == null) return;
|
||||
var newValue = await _editor.GetValue();
|
||||
OnChange(newValue);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
_editor?.Dispose();
|
||||
_editor = null;
|
||||
}
|
||||
}
|
||||
|
||||
<StandaloneCodeEditor
|
||||
@ref="_editor"
|
||||
Id="@randomId"
|
||||
ConstructionOptions="EditorConstructionOptions"
|
||||
OnDidChangeModelContent="OnDidChangeModelContent"
|
||||
/>
|
||||
|
||||
<StandaloneCodeEditor @ref="_editor" Id="@randomId" ConstructionOptions="EditorConstructionOptions"
|
||||
OnDidChangeModelContent="OnDidChangeModelContent" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user