SegmentContextMenu

A context menu for transcript segment operations. Reads segment and speaker data directly from `AppState` using the provided segment index, then renders a positioned dropdown containing segment metadata and action items for changing speaker, splitting, editing, and merging. Actions are decoupled from application logic via callbacks supplied by the caller.

Constructor

new SegmentContextMenu(x, y, segIdx, callbacks)

Parameters:
NameTypeDescription
xnumberPreferred left position in viewport pixels.
ynumberPreferred top position in viewport pixels.
segIdxnumberIndex into `AppState.transcript.loadedSegments`.
callbacksobject
Properties
NameTypeDescription
onChangeSpeakerfunctionCalled with the selected speaker `id` when a speaker row is clicked.
onSplitfunctionCalled when the Split Segment item is clicked. Omit or pass `null` to suppress the item (e.g. when the segment has only one word).
onEditfunctionCalled when the Edit Text item is clicked.
onMergePrevfunctionCalled when Merge With Previous is clicked. Pass `null` to suppress the item.
onMergeNextfunctionCalled when Merge With Next is clicked. Pass `null` to suppress the item.
onAddLinkfunctionCalled when Add Link is clicked. Pass `null` to suppress the item.
onSplitParagraphfunctionCalled when Split Paragraph Here is clicked. Pass `null` to suppress the item.
onMergeParagraphPrevfunctionCalled when Merge Paragraph with Previous is clicked. Pass `null` to suppress the item.
onZoomfunctionCalled when Zoom to Sentence is clicked. Pass `null` to suppress the item.
Example
const menu = new SegmentContextMenu(event.clientX, event.clientY, segIdx, {
  onChangeSpeaker: (id) => { changeSpeaker(segIdx, id); menu.close(); },
  onSplit:         () => { enterSplitMode(segIdx, anchor); },
  onEdit:          () => { makeSegmentEditable(segIdx); },
  onMergePrev:     () => { ... },
  onMergeNext:     () => { ... },
});

// Later:
menu.close();

Classes

SegmentContextMenu

Methods

close()

Removes the context menu from the DOM and resets internal state.