Interface
public interface IMokaJsonViewer

Namespace: Moka.Blazor.Json.Abstractions

Programmatic interface for controlling the JSON viewer component.

Properties

NameDescription
IsEditing abstract Gets whether the viewer is currently in edit mode.
SelectedPath abstract Gets the currently selected node's JSON Pointer path, or null if nothing is selected.

IsEditing

bool IMokaJsonViewer.IsEditing { get; }

Gets whether the viewer is currently in edit mode.

SelectedPath

string? IMokaJsonViewer.SelectedPath { get; }

Gets the currently selected node's JSON Pointer path, or null if nothing is selected.

Methods

NameDescription
ClearSearch() abstract Clears the current search results and highlighting.
CollapseAll() abstract Collapses all nodes in the tree.
ExpandAll() abstract Expands all nodes in the tree.
ExpandToDepth(int depth) abstract Expands all nodes up to the specified depth. Pass -1 for unlimited.
GetJson(bool indented) abstract Gets the current JSON content as a formatted string.
NavigateToAsync(string jsonPointer, CancellationToken cancellationToken) abstract Navigates to and selects the node at the specified JSON Pointer path (RFC 6901).
NextMatch() abstract Navigates to the next search match.
PreviousMatch() abstract Navigates to the previous search match.
Redo() abstract Redoes the last undone edit operation. Only available when editing is enabled.
SearchAsync(…) abstract Initiates a search with the given query.
Undo() abstract Undoes the last edit operation. Only available when editing is enabled.

ClearSearch()

void IMokaJsonViewer.ClearSearch()

Clears the current search results and highlighting.

CollapseAll()

void IMokaJsonViewer.CollapseAll()

Collapses all nodes in the tree.

ExpandAll()

void IMokaJsonViewer.ExpandAll()

Expands all nodes in the tree.

ExpandToDepth(int depth)

void IMokaJsonViewer.ExpandToDepth(int depth)

Expands all nodes up to the specified depth. Pass -1 for unlimited.

Parameters

NameTypeDescription
depthintMaximum depth to expand, or -1 for all.

GetJson(bool indented)

string IMokaJsonViewer.GetJson(bool indented = true)

Gets the current JSON content as a formatted string.

Parameters

NameTypeDescription
indentedboolWhether to pretty-print the output.

Returns: The JSON string.

ValueTask IMokaJsonViewer.NavigateToAsync(string jsonPointer, CancellationToken cancellationToken = null)

Navigates to and selects the node at the specified JSON Pointer path (RFC 6901).

Parameters

NameTypeDescription
jsonPointerstringThe JSON Pointer path, e.g. "/users/0/name".
cancellationTokenCancellationTokenCancellation token.

NextMatch()

void IMokaJsonViewer.NextMatch()

Navigates to the next search match.

PreviousMatch()

void IMokaJsonViewer.PreviousMatch()

Navigates to the previous search match.

Redo()

void IMokaJsonViewer.Redo()

Redoes the last undone edit operation. Only available when editing is enabled.

SearchAsync(string query, JsonSearchOptions? options, CancellationToken cancellationToken)

ValueTask<int> IMokaJsonViewer.SearchAsync(string query, JsonSearchOptions? options = null, CancellationToken cancellationToken = null)

Initiates a search with the given query.

Parameters

NameTypeDescription
querystringThe search query string.
optionsMoka.Blazor.Json.Abstractions.JsonSearchOptions?Search options (regex, case sensitivity, etc.).
cancellationTokenCancellationTokenCancellation token.

Returns: The number of matches found.

Undo()

void IMokaJsonViewer.Undo()

Undoes the last edit operation. Only available when editing is enabled.

Type Relationships
classDiagram
                    style IMokaJsonViewer fill:#f9f,stroke:#333,stroke-width:2px
                    MokaJsonViewer ..|> IMokaJsonViewer : implements
                
View Source
/// <summary>
///     Programmatic interface for controlling the JSON viewer component.
/// </summary>
public interface IMokaJsonViewer
{
    /// <summary>
    ///     Gets the currently selected node's JSON Pointer path, or null if nothing is selected.
    /// </summary>
    string? SelectedPath { get; }

    /// <summary>
    ///     Gets whether the viewer is currently in edit mode.
    /// </summary>
    bool IsEditing { get; }

    /// <summary>
    ///     Navigates to and selects the node at the specified JSON Pointer path (RFC 6901).
    /// </summary>
    /// <param name = "jsonPointer">The JSON Pointer path, e.g. "/users/0/name".</param>
    /// <param name = "cancellationToken">Cancellation token.</param>
    ValueTask NavigateToAsync(string jsonPointer, CancellationToken cancellationToken = default);
    /// <summary>
    ///     Expands all nodes up to the specified depth. Pass <c>-1</c> for unlimited.
    /// </summary>
    /// <param name = "depth">Maximum depth to expand, or -1 for all.</param>
    void ExpandToDepth(int depth);
    /// <summary>
    ///     Collapses all nodes in the tree.
    /// </summary>
    void CollapseAll();
    /// <summary>
    ///     Expands all nodes in the tree.
    /// </summary>
    void ExpandAll();
    /// <summary>
    ///     Initiates a search with the given query.
    /// </summary>
    /// <param name = "query">The search query string.</param>
    /// <param name = "options">Search options (regex, case sensitivity, etc.).</param>
    /// <param name = "cancellationToken">Cancellation token.</param>
    /// <returns>The number of matches found.</returns>
    ValueTask<int> SearchAsync(string query, JsonSearchOptions? options = null, CancellationToken cancellationToken = default);
    /// <summary>
    ///     Navigates to the next search match.
    /// </summary>
    void NextMatch();
    /// <summary>
    ///     Navigates to the previous search match.
    /// </summary>
    void PreviousMatch();
    /// <summary>
    ///     Clears the current search results and highlighting.
    /// </summary>
    void ClearSearch();
    /// <summary>
    ///     Undoes the last edit operation. Only available when editing is enabled.
    /// </summary>
    void Undo();
    /// <summary>
    ///     Redoes the last undone edit operation. Only available when editing is enabled.
    /// </summary>
    void Redo();
    /// <summary>
    ///     Gets the current JSON content as a formatted string.
    /// </summary>
    /// <param name = "indented">Whether to pretty-print the output.</param>
    /// <returns>The JSON string.</returns>
    string GetJson(bool indented = true);
}
Was this page helpful?