serdarciplak / BlazorMonaco

Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
https://serdarciplak.github.io/BlazorMonaco/
MIT License
441 stars 99 forks source link

How to create and access IDiffNavigator interface? #49

Closed lbrysh closed 2 years ago

lbrysh commented 2 years ago

Hello,

Is there a way to create "createDiffNavigator" and access its functionality?

lbrysh commented 2 years ago

In index.html add script section:

In your Blazor component where MonacoDiffEditor is initialized at the end of EditorOnDidInit method add:

    string navOptionJson = JsonSerializer.Serialize(new { FollowsCaret = true, IgnoreCharChanges = true, AlwaysRevealFirst = true }, new JsonSerializerOptions
    {
        IgnoreNullValues = true,
        PropertyNamingPolicy = JsonNamingPolicy.CamelCase
    });

    var navOptionsDict = JsonSerializer.Deserialize<JsonElement>(navOptionJson);

    await jsRuntime.InvokeVoidAsync("CreateDiffNavigator", m_diffEditor.Id, navOptionsDict);