segment_card
Segment card component with view and split modes
Card Metadata
Left side of the card showing index and timestamp.
View Mode Content
Standard text display when card is not in split mode.
Split Mode Content
Interactive token grid with caret indicator for splitting. Uses the cjm-fasthtml-token-selector library for token rendering and navigation.
Card Actions
Hover-visible action buttons for merge and split.
Main Card Renderer
render_segment_card
def render_segment_card(
segment:TextSegment, # Segment to render
card_role:Literal, # Role of this card in viewport ("focused" or "context")
is_split_mode:bool, # Whether this card is in split mode
caret_position:int, # Caret position for split mode (word index)
split_url:str, # URL to execute split
merge_url:str, # URL to merge with previous
enter_split_url:str, # URL to enter split mode
exit_split_url:str, # URL to exit split mode
is_first_segment:bool=False, # Whether this is the first segment (can't merge)
has_boundary_above:bool=False, # Source boundary exists above this card
has_boundary_below:bool=False, # Source boundary exists below this card
)->Any: # Segment card component
Render a segment card with view or split mode content.
Card Renderer Factory
Creates a card renderer callback that captures split/merge URLs and mode state, compatible with the card stack viewport’s render_card parameter.
create_segment_card_renderer
def create_segment_card_renderer(
split_url:str='', # URL to execute split
merge_url:str='', # URL to merge with previous
enter_split_url:str='', # URL to enter split mode
exit_split_url:str='', # URL to exit split mode
is_split_mode:bool=False, # Whether split mode is active
caret_position:int=0, # Caret position for split mode (word index)
source_boundaries:Set=None, # Indices where source_id changes
)->Callable: # Card renderer callback: (item, CardRenderContext) -> FT
Create a card renderer callback for segment cards.