Editor options - Richasy/Controls-MarkdownEditBox GitHub Wiki

The definition of EditorOptions is here

In MarkdownEditBox, the properties of EditorOptions have default values, so you can get the basic configuration directly through EditorOptions.CreateOptions().

On this basis, the class also provides another simple overload method to help you modify the most basic properties:

var editorOptions = EditorOptions.CreateOptions(
                                    theme: "vs",
                                    fontFamily: "Segoe UI",
                                    fontSize: 14,
                                    lineHeight: 24
                                    );

As you know, this control is based on monaco-editor, so EditorOptions will eventually be converted to IEditorOptions in monaco-editor. But the EditorOptions is not a complete IEditorOptions, it only contains some common properties.

If the properties you need to modify are not defined, then you need to call the MarkdownEditBox.UpdateEditorOptionsAsync() method after the editor is loaded to modify the properties you need.

  1. Handle the MarkdownEditBox.EditorLoaded event.
<editor:MarkdownEditBox x:Name="MyEditor"
                        ...
                        EditorLoaded="MyEditor_EditorLoaded"
                        />
  1. Create an anonymous class to update properties in the callback
private async void MyEditor_EditorLoaded(object sender, EventArgs e)
{
    var prop = new
    {
        customProperty = "xxxxxx"
    };
    await MyEditor.UpdateEditorOptionsAsync(JsonConvert.SerializeObject(prop));
}

If you need to adjust the properties dynamically during the operation of the control, you can also use the above methods, but please note:

The property name you used must be the same as the property name of IEditorOptions in monaco-editor (using camel case naming)