import type { AriaLabelingProps } from '../../core/types/a11y-props.js'; import type { BehaviorTrackingProps } from '../../core/types/behavior-tracking-props.js'; import type { DataTestId } from '../../core/types/data-props.js'; import type { Components } from '../../core/types/markdown/react-markdown.js'; import type { MaskingProps } from '../../core/types/masking-props.js'; import type { StylingProps } from '../../core/types/styling-props.js'; /** * Represents the user's text selection within a rendered Markdown document, * expressed as source positions in the original markdown string. * @public */ export interface MarkdownSelection { /** The position in the markdown source where the selection begins. */ start: MarkdownSelectionPoint; /** The position in the markdown source where the selection ends. */ end: MarkdownSelectionPoint; } /** * A position within the markdown source string, identified by both a * line/column coordinate and an absolute character offset. * Lines and columns are 1-based; the offset is 0-based. * @public */ export interface MarkdownSelectionPoint { /** The 1-based line number of this position in the markdown source string. */ line: number; /** The 1-based column number of this position within its line. */ column: number; /** The 0-based character offset from the start of the markdown source string to this position. */ offset: number; } /** * @public */ export interface MarkdownProps extends MaskingProps, DataTestId, StylingProps, AriaLabelingProps, BehaviorTrackingProps { /** The markdown content to render. */ children: string; /** * A map of HTML tags (e.g., `'a'`, `'h1'`) to custom render functions, * allowing you to override the default rendering of specific elements. * @defaultValue undefined */ customComponentMappings?: Components; /** * Callback fired whenever the user's text selection within the rendered * markdown changes. Receives a `MarkdownSelection` describing the * selected range expressed as positions in the original markdown source. */ onSelectionChange?: (selection: MarkdownSelection) => void; }