using AvaloniaEdit.Document;
using MarkdownEditor.Models;

namespace MarkdownEditor.Services;

/// <summary>
/// Interface for markdown text formatting operations.
/// Handles insertion of markdown syntax around selected text or at cursor positions.
/// </summary>
public interface IMarkdownFormattingService
{
    /// <summary>
    /// Wraps the selected text with before and after strings (e.g., ** for bold).
    /// </summary>
    /// <param name="document">The text document to modify.</param>
    /// <param name="selection">The current text selection.</param>
    /// <param name="before">The string to insert before the selection.</param>
    /// <param name="after">The string to insert after the selection.</param>
    /// <returns>The new text selection after the operation.</returns>
    TextSelection WrapSelection(TextDocument document, TextSelection selection, string before, string after);

    /// <summary>
    /// Adds a prefix to the beginning of the current line (e.g., # for heading).
    /// </summary>
    /// <param name="document">The text document to modify.</param>
    /// <param name="selection">The current text selection to determine the line.</param>
    /// <param name="prefix">The prefix string to add to the line.</param>
    /// <returns>The new text selection after the operation.</returns>
    TextSelection AddLinePrefix(TextDocument document, TextSelection selection, string prefix);

    /// <summary>
    /// Gets the selected text from the document.
    /// </summary>
    /// <param name="document">The text document.</param>
    /// <param name="selection">The text selection range.</param>
    /// <returns>The selected text, or empty string if selection is invalid.</returns>
    string GetSelectedText(TextDocument document, TextSelection selection);
}

