Wave 2 of the 2026-09-28 design overhaul ("records are the main
character, a quiet instrument"). Decisions: design.md.
- Shell: sidebar with primary Home / Records / Meetings (Ctrl+1..3) and a
secondary "Tools" group; every item is a button with aria-current.
The status bar is removed — its "100% LOCAL PRIVACY · ZERO CLOUD SYNC"
claim contradicted device sync; the sidebar shows only queried state.
- Navigation context (routes, params, back, useRouteRequest) so Home can
open a specific meeting or record.
- Home replaces the dashboard: dictation key, start actions, only real
problems, one-line summary, recent records and meetings, file
transcription, free-tier limits.
- Settings become a full-screen route with vertical tabs (tabs no longer
clip) and a shared row grammar; long-standing bugs fixed: team and
enterprise tiers crashed the license tab (currentTier undefined),
first-run onboarding could not be left, Pro+ saw "upgrade to Pro+".
- Records: date-grouped single list with in-place expansion, search and
tags together, mode/favorite filters, load more past 50, undoable
delete. Meetings: list with search/rename/delete, summary-first detail
(summary | transcript | documents | my notes), notes persisted locally
instead of being lost. Tools pages cleaned up; stale-closure example
chips and a 1550x mouse-distance bug fixed.
- Shared pieces: PageHeader, EmptyStateCard, SearchInput ("/" works),
ConfirmDialog, notify with undo; display-labels maps domain values to
typed i18n keys so missing keys fail to compile.
- Mono font stack falls back to Pretendard for Hangul (Korean labels no
longer render spaced out).
- i18n: new ko/en keys via scripts/i18n-add-keys.mjs (one read-merge-
write so parallel editors cannot clobber locale files).
Some renderer files also carried pre-existing in-flight changes (error
recovery deep links, meeting document hooks); they are included as-is.
217 lines
5.7 KiB
TypeScript
217 lines
5.7 KiB
TypeScript
// src/renderer/components/meeting/EditableSegment.tsx
|
|
// Phase 14.5: 전사 세그먼트 인라인 편집 컴포넌트
|
|
|
|
import { useState, useRef, useCallback } from 'react'
|
|
import { Box, TextField, Tooltip, Chip } from '@mui/material'
|
|
import { d3roPalette, d3roFontMono, d3roFontSans, d3roRadius, d3roTransition, d3roFocusRing, typoSx } from '@d3ro/ui/theme'
|
|
import { useI18n } from '@d3ro/i18n'
|
|
import { isImeComposingEvent } from '../../utils/keyboard'
|
|
|
|
// Phase 15.5: 화자별 색상 매핑 (d3roPalette SSOT)
|
|
const SPEAKER_COLORS = [
|
|
d3roPalette.tag.purple,
|
|
d3roPalette.tag.green,
|
|
d3roPalette.tag.orange,
|
|
d3roPalette.tag.red,
|
|
d3roPalette.tag.blue,
|
|
]
|
|
|
|
function getSpeakerColor(speaker: string): string {
|
|
// "화자 1" → 0, "화자 2" → 1, ...
|
|
const match = /(\d+)$/.exec(speaker)
|
|
const idx = match ? (parseInt(match[1], 10) - 1) : 0
|
|
return SPEAKER_COLORS[idx % SPEAKER_COLORS.length]
|
|
}
|
|
|
|
interface EditableSegmentProps {
|
|
segmentId: string
|
|
timestamp: number // ms, 상대 시간
|
|
text: string
|
|
edited: boolean // 수정 여부
|
|
onEdit: (segmentId: string, newText: string) => void
|
|
readOnly?: boolean
|
|
speaker?: string
|
|
}
|
|
|
|
function formatTimestamp(ms: number): string {
|
|
const totalSec = Math.floor(ms / 1000)
|
|
const min = Math.floor(totalSec / 60)
|
|
const sec = totalSec % 60
|
|
return `[${String(min).padStart(2, '0')}:${String(sec).padStart(2, '0')}]`
|
|
}
|
|
|
|
export function EditableSegment({
|
|
segmentId,
|
|
timestamp,
|
|
text,
|
|
edited,
|
|
onEdit,
|
|
readOnly = false,
|
|
speaker,
|
|
}: EditableSegmentProps): React.ReactElement {
|
|
const { t } = useI18n()
|
|
const [editing, setEditing] = useState(false)
|
|
const [draft, setDraft] = useState(text)
|
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
|
|
const handleClick = useCallback(() => {
|
|
if (readOnly) return
|
|
setDraft(text)
|
|
setEditing(true)
|
|
}, [readOnly, text])
|
|
|
|
const handleCommit = useCallback(() => {
|
|
const trimmed = draft.trim()
|
|
if (trimmed && trimmed !== text) {
|
|
onEdit(segmentId, trimmed)
|
|
}
|
|
setEditing(false)
|
|
}, [draft, text, segmentId, onEdit])
|
|
|
|
const handleKeyDown = useCallback(
|
|
(e: React.KeyboardEvent) => {
|
|
if (isImeComposingEvent(e)) return
|
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
e.preventDefault()
|
|
handleCommit()
|
|
} else if (e.key === 'Escape') {
|
|
setEditing(false)
|
|
}
|
|
},
|
|
[handleCommit],
|
|
)
|
|
|
|
const speakerColor = speaker ? getSpeakerColor(speaker) : undefined
|
|
|
|
if (editing) {
|
|
return (
|
|
<Box
|
|
sx={{
|
|
display: 'flex',
|
|
alignItems: 'flex-start',
|
|
gap: 1,
|
|
mb: 0.5,
|
|
borderLeft: speakerColor ? `4px solid ${speakerColor}` : undefined,
|
|
pl: speakerColor ? 0.75 : 0,
|
|
}}
|
|
>
|
|
<Box
|
|
component="span"
|
|
sx={{
|
|
fontFamily: d3roFontMono,
|
|
fontSize: 11,
|
|
color: d3roPalette.text.tertiary,
|
|
pt: '7px',
|
|
flexShrink: 0,
|
|
userSelect: 'none',
|
|
}}
|
|
>
|
|
{formatTimestamp(timestamp)}
|
|
</Box>
|
|
<TextField
|
|
inputRef={inputRef}
|
|
value={draft}
|
|
onChange={(e) => setDraft(e.target.value)}
|
|
onKeyDown={handleKeyDown}
|
|
onBlur={handleCommit}
|
|
autoFocus
|
|
size="small"
|
|
fullWidth
|
|
multiline
|
|
sx={{
|
|
'& .MuiInputBase-root': {
|
|
fontFamily: d3roFontSans,
|
|
...typoSx('body'),
|
|
bgcolor: d3roPalette.bg.input,
|
|
},
|
|
}}
|
|
/>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
const textNode = (
|
|
<Box
|
|
component="span"
|
|
onClick={handleClick}
|
|
role={readOnly ? undefined : 'button'}
|
|
tabIndex={readOnly ? undefined : 0}
|
|
onKeyDown={(e: React.KeyboardEvent) => {
|
|
if (readOnly || isImeComposingEvent(e)) return
|
|
if (e.key === 'Enter') {
|
|
e.preventDefault()
|
|
handleClick()
|
|
}
|
|
}}
|
|
sx={{
|
|
fontFamily: d3roFontSans,
|
|
...typoSx('body'),
|
|
color: d3roPalette.text.primary,
|
|
cursor: readOnly ? 'default' : 'text',
|
|
borderBottom: edited ? `1px dashed ${d3roPalette.text.tertiary}` : 'none',
|
|
borderRadius: d3roRadius.xs,
|
|
transition: d3roTransition('background-color'),
|
|
px: readOnly ? 0 : '2px',
|
|
'&:hover': readOnly
|
|
? {}
|
|
: {
|
|
color: d3roPalette.text.primary,
|
|
borderBottomColor: edited ? d3roPalette.accent.main : undefined,
|
|
bgcolor: edited ? undefined : d3roPalette.surface.overlaySoft,
|
|
},
|
|
'&:focus-visible': d3roFocusRing,
|
|
}}
|
|
>
|
|
{text}
|
|
</Box>
|
|
)
|
|
|
|
return (
|
|
<Box
|
|
sx={{
|
|
display: 'flex',
|
|
alignItems: 'flex-start',
|
|
gap: 1,
|
|
mb: 0.5,
|
|
borderLeft: speakerColor ? `4px solid ${speakerColor}` : undefined,
|
|
pl: speakerColor ? 0.75 : 0,
|
|
}}
|
|
>
|
|
<Box
|
|
component="span"
|
|
sx={{
|
|
fontFamily: d3roFontMono,
|
|
fontSize: 11,
|
|
color: d3roPalette.text.tertiary,
|
|
pt: '2px',
|
|
flexShrink: 0,
|
|
userSelect: 'none',
|
|
}}
|
|
>
|
|
{formatTimestamp(timestamp)}
|
|
</Box>
|
|
{speaker && (
|
|
<Chip
|
|
label={speaker}
|
|
size="small"
|
|
sx={{
|
|
fontSize: 10,
|
|
height: 18,
|
|
flexShrink: 0,
|
|
bgcolor: `${speakerColor}22`,
|
|
color: speakerColor,
|
|
border: `1px solid ${speakerColor}55`,
|
|
fontFamily: d3roFontSans,
|
|
}}
|
|
/>
|
|
)}
|
|
{edited ? (
|
|
<Tooltip title={t('meeting.modified')} placement="top">
|
|
{textNode}
|
|
</Tooltip>
|
|
) : (
|
|
textNode
|
|
)}
|
|
</Box>
|
|
)
|
|
}
|