Synchronize shared Monaco read-only state without replacing drafts
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
private readonly string _id = Guid.NewGuid().ToString("N");
|
||||
private string _lastSentValue = "";
|
||||
private string _lastSentAriaLabel = "";
|
||||
private bool _lastSentReadOnly;
|
||||
private string AccessibleLabel => string.IsNullOrWhiteSpace(AriaLabel) ? "Code editor" : AriaLabel;
|
||||
private bool _disposed;
|
||||
private bool _initialized;
|
||||
@@ -82,6 +83,7 @@
|
||||
_dotNetRef = DotNetObjectReference.Create(this);
|
||||
_lastSentValue = Value ?? "";
|
||||
var createdLabel = AccessibleLabel;
|
||||
var createdReadOnly = ReadOnly;
|
||||
try
|
||||
{
|
||||
await JS.InvokeVoidAsync(
|
||||
@@ -93,7 +95,7 @@
|
||||
value = Value ?? "",
|
||||
ariaLabel = createdLabel,
|
||||
language = Language,
|
||||
readOnly = ReadOnly,
|
||||
readOnly = createdReadOnly,
|
||||
equipmentId = EquipmentId,
|
||||
maxSyncBytes = ScriptEditorLimits.MaxEditorSyncBytes,
|
||||
reportMarkers = MarkersChanged.HasDelegate,
|
||||
@@ -103,6 +105,7 @@
|
||||
_dotNetRef);
|
||||
_initialized = true;
|
||||
_lastSentAriaLabel = createdLabel;
|
||||
_lastSentReadOnly = createdReadOnly;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
@@ -124,6 +127,11 @@
|
||||
_lastSentValue = Value ?? "";
|
||||
await SafeInvokeAsync("MonacoBlazor.setValue", "set editor value", _id, _lastSentValue);
|
||||
}
|
||||
if (!_disposed && _initialized && ReadOnly != _lastSentReadOnly)
|
||||
{
|
||||
_lastSentReadOnly = ReadOnly;
|
||||
await SafeInvokeAsync("MonacoBlazor.setEditorOption", "set editor read-only state", _id, "readOnly", _lastSentReadOnly);
|
||||
}
|
||||
if (!_disposed && _initialized && AccessibleLabel != _lastSentAriaLabel)
|
||||
{
|
||||
_lastSentAriaLabel = AccessibleLabel;
|
||||
|
||||
Reference in New Issue
Block a user