Workspace

Central workspace controller. Owns the three editing panels (speakers, transcript, waveform) and mediates all cross-panel interactions through callbacks. Manages the active project, selection state, context menus, and the split popup.

Constructor

new Workspace(callbacks)

Parameters:
NameTypeDescription
callbacksobjectcallback functions for workspace actions
Properties
NameTypeAttributesDescription
onNewProjectfunctioncalled when the user requests a new project
onOpenProjectfunctioncalled when the user requests to open a local project
onUploadfunctioncalled with the active project when the upload button is clicked
onProjectModifiedfunctioncalled with the project when it becomes dirty and is a server project
isServerConnectedfunctionreturns true if the server is currently connected
onPresentationfunction<optional>
called when the user opens a project's presentation
getTokenfunction<optional>
async function returning the current auth token string, or null
onRenderSidebarfunction<optional>
called when the sidebar should be re-rendered

Classes

Workspace

Methods

_applyHistoryResult(command)

Fires re-render callbacks based on the command's dirtyFlags after undo/redo.
Parameters:
NameTypeDescription
commandobject | nullthe command returned by history.undo() or history.redo()

_mergeParagraphWithHistory(segIdx)

Merges the paragraph containing segIdx with the previous paragraph and pushes undo/redo.
Parameters:
NameTypeDescription
segIdxnumberindex of any segment in the paragraph to merge upward

_mergeWithHistory(idxA, idxB)

Merges two adjacent segments and pushes an undo/redo command to history. Use this instead of calling activeProject.mergeSegments() directly.
Parameters:
NameTypeDescription
idxAnumberindex of the earlier segment
idxBnumberindex of the later segment (must equal idxA + 1)

_splitParagraphWithHistory(segIdx)

Inserts a paragraph break before the segment at segIdx and pushes an undo/redo command.
Parameters:
NameTypeDescription
segIdxnumberindex of the segment that will start the new paragraph

_updateUndoRedoButtons()

Updates the enabled/disabled state of the undo and redo buttons.

clearWorkspace()

Tears down the current WaveSurfer instance and clears all audio, transcript, speaker, and UI state back to their initial values. Called when switching projects or when a project is deleted/closed.

closeCtxMenu()

Closes the active context menu

closeSplitPopup()

Close the active split popup if there is one

commitProjectName()

Commits the project name from the inline input back to the title span, updates the active project's name in state, and refreshes the sidebar. Called on blur and Enter keydown of the title input.

enterSplitMode(segIdx, anchorEl)

Opens the split popup for the given segment, closing any existing one first.
Parameters:
NameTypeDescription
segIdxnumberindex of the segment to split
anchorElHTMLElementelement to anchor the popup near

hasNext(segIdx) → {boolean}

Returns true if there is a segment after segIdx.
Parameters:
NameTypeDescription
segIdxnumberthe segment index to check
Returns:
Type: 
boolean

hasPrev(segIdx) → {boolean}

Returns true if there is a segment before segIdx.
Parameters:
NameTypeDescription
segIdxnumberthe segment index to check
Returns:
Type: 
boolean

initializeWorkspacePanels()

Constructs the three workspace panels and wires their cross-panel callbacks.

isLocalMode() → {boolean}

Returns true when the app is running in local (desktop) mode.
Returns:
Type: 
boolean

isReadOnly() → {boolean}

Returns true if the active project is in read-only mode.
Returns:
Type: 
boolean

isSplitting() → {boolean}

Returns true if a split popup is currently active.
Returns:
Type: 
boolean

(async) loadProject(project)

Loads project data from the server uplink and populates the workspace
Parameters:
NameTypeDescription
projectobjectthe project to be loaded

openEmbedDialog(selTarget)

Opens the EmbedDialog for the given text selection target.
Parameters:
NameTypeDescription
selTargetobjectselection target from TranscriptPanel#getNativeSelection()

openSegmentCtxMenu(x, y, segmentIndex, splitAnchor, linkInfo)

Opens a SegmentContextMenu for the given segment index.
Parameters:
NameTypeDefaultDescription
xnumberleft position in viewport pixels
ynumbertop position in viewport pixels
segmentIndexnumberindex into the active project's transcript segments
splitAnchorElement | Object | nullnullanchor for the split popup; defaults to the transcript segment element
linkInfoobject | nullnullwhen opening from a link span, provides onEdit/onRemove/onCopy callbacks; null otherwise

(async) saveLocalCopy(project) → {Promise.<(FileSystemFileHandle|undefined)>}

Prompts the user for a save location and packages the project as a .wfs archive.
Parameters:
NameTypeDescription
projectobjectthe project to save
Returns:
the file handle on success, or undefined if cancelled
Type: 
Promise.<(FileSystemFileHandle|undefined)>

setSelectedSeg(idx)

Sets the selected segment, syncing workspace state, transcript panel, and waveform panel.
Parameters:
NameTypeDescription
idxnumbersegment index, or -1 to clear selection

setUploadBusy(busy)

Shows or hides the upload spinner on the workspace header upload button.
Parameters:
NameTypeDescription
busybooleantrue to show spinner, false to restore the icon

unloadActiveProject()

Unloads the currently active project, alerting user to unsaved changes

updateProjectServerStatus()

Updates the badge and optional push button in the project title bar to reflect whether the active project is local-only, synced, or has unsynced changes.

wavesurferInstance() → {object}

Returns the WaveSurfer instance from the waveform panel.
Returns:
the WaveSurfer instance
Type: 
object