BlazorMonaco
BlazorMonaco copied to clipboard
JSON Formatting Ignores TabSize in StandaloneEditorConstructionOptions
Description
I'm encountering an issue with JSON formatting in BlazorMonaco. I have defined the StandaloneEditorConstructionOptions as follows:
private StandaloneEditorConstructionOptions ConfigureMonacoEditor(StandaloneCodeEditor editor)
{
return new StandaloneEditorConstructionOptions
{
Language = "json",
Value = Value,//default value
TabSize = 8, // Set TabSize to 8
//other config
};
}
<StandaloneCodeEditor @ref="codeEditor"
ConstructionOptions="ConfigureMonacoEditor"/>
<button onclick="@Format">Format</button>
public async Task Format()
{
await codeEditor.Trigger("editor", "editor.action.formatDocument");
}
I also have a button that formats the content inside the editor. My expectation is that when I click this button, the JSON content inside the editor should be formatted using the TabSize = 8 configuration.
Issue
- If I initialize the editor without a default
Value, formatting works correctly withTabSize = 8. - However, if I initialize the editor with a default
Value(e.g., a JSON string that was previously formatted withTabSize = 2), I changed the value in editor and then when I trigger the format command, the editor still formats usingTabSize = 2instead ofTabSize = 8.
Expected Behavior
- The formatting should always respect the
TabSizedefined inStandaloneEditorConstructionOptions, even if the initialValuealready has a different formatting style.
Data
{
"fields": [
"Loan.Active"
],
"loanFolders": [
"My Pipeline",
"Prospects"
]
}
Question
- Is there a way to ensure that JSON formatting respects the configured
TabSize = 8, regardless of the initial content? - Do I need to explicitly set some additional editor options or call a specific API to enforce this setting?