@lincyaw/workbench 0.2.0-rc.3 → 0.2.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/MediaClipEditor.tsx +1 -1
- package/src/authoring-client.ts +3 -3
- package/src/authoring-draft-fragment.ts +3 -1
- package/src/component-property-drafts.ts +5 -5
- package/src/components.tsx +10 -28
- package/src/document-drafts.ts +6 -7
- package/src/document-editor/BlockNoteSurface.tsx +25 -9
- package/src/document-editor/ComponentMaterials.tsx +3 -9
- package/src/document-editor/ComponentPropertiesDialog.tsx +3 -3
- package/src/document-editor/DocumentBlockPreview.tsx +2 -0
- package/src/document-editor/DocumentComments.tsx +58 -9
- package/src/document-editor/DocumentEditor.tsx +44 -7
- package/src/document-editor/DocumentStepNarration.tsx +24 -19
- package/src/document-editor/NarrationEditor.tsx +54 -20
- package/src/document-editor/NewCommentDrafts.tsx +4 -3
- package/src/document-editor/PlaceComment.tsx +150 -0
- package/src/document-editor/comment-drafts.ts +16 -14
- package/src/document-editor/comments.ts +30 -10
- package/src/document-editor/component-label.ts +11 -0
- package/src/document-editor/file-input.ts +2 -2
- package/src/document-editor/focus.ts +0 -2
- package/src/document-editor/insertion-place.ts +60 -0
- package/src/document-editor/messages.ts +3 -3
- package/src/document-editor/narration-schema.tsx +12 -6
- package/src/document-editor/narration.ts +19 -3
- package/src/document-editor/page-body.ts +60 -0
- package/src/document-editor/projection.ts +2 -2
- package/src/document-editor/rich-text.ts +3 -2
- package/src/document-editor/selection.ts +13 -0
- package/src/document-editor/style.css +12 -1
- package/src/document-editor/table-identities.ts +2 -1
- package/src/document-session.ts +50 -16
- package/src/history.ts +2 -2
- package/src/index.ts +0 -3
- package/src/messages.ts +19 -4
- package/src/panels/DocumentView.tsx +10 -10
- package/src/panels/ExportPanel.tsx +1 -6
- package/src/panels/PreviewPanel.tsx +1 -4
- package/src/panels/ProductionCaptionSize.tsx +20 -0
- package/src/panels/ProductionCaptionTiming.tsx +3 -3
- package/src/panels/ProductionMediaClips.tsx +2 -1
- package/src/panels/ProductionPanel.tsx +5 -1
- package/src/panels/ProductionRecordingRange.tsx +2 -2
- package/src/panels/ProductionTimeline.tsx +6 -1
- package/src/panels/ProductionTranscription.tsx +2 -1
- package/src/panels/SourceDocumentPanel.tsx +3 -6
- package/src/panels/TranscriptionAdoption.tsx +7 -6
- package/src/places.ts +1 -36
- package/src/production-messages.ts +6 -0
- package/src/sha256.ts +9 -0
- package/src/styles.css +16 -41
- package/src/workbench.ts +124 -88
- package/src/workspace-client.ts +2 -1
- package/src/assistant-mascot.ts +0 -62
- package/src/mascot-preference.ts +0 -37
- package/src/panels/ChangeTrail.tsx +0 -79
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import type { CSSProperties, RefObject } from 'react'
|
|
3
|
-
import type { MascotAction } from '@lincyaw/design/mascot'
|
|
4
|
-
import { PmMascot } from '../components.tsx'
|
|
5
|
-
import { useMascotEnabled } from '../mascot-preference.ts'
|
|
6
|
-
import { useWorkbenchState } from '../context.tsx'
|
|
7
|
-
import { pageId, richNodeIds } from '../document-editor/projection.ts'
|
|
8
|
-
|
|
9
|
-
/** How long the kitten walks from one changed place to the next, pats it, and stays when it is done (ms). */
|
|
10
|
-
const WALK_MS = 700, PAT_MS = 900, DONE_MS = 2200
|
|
11
|
-
/** At most this many changed places are visited. */
|
|
12
|
-
const STOPS = 6
|
|
13
|
-
|
|
14
|
-
type Point = { x: number, y: number }
|
|
15
|
-
type Phase = 'walk' | 'pat' | 'done' | 'gone'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The kitten visiting a list of points in its host (each the lower left of a changed place): it walks to each, pats it,
|
|
19
|
-
* hops when it is done and leaves. A new `id` starts it again from the first point; `where(i)` is asked on every
|
|
20
|
-
* render, so the kitten follows the places as the host lays out again. Nothing shows when the kitten is turned off.
|
|
21
|
-
*/
|
|
22
|
-
function KittenTrail({ id, count, where }: { id: number | undefined, count: number, where(index: number): Point | undefined }) {
|
|
23
|
-
const enabled = useMascotEnabled()
|
|
24
|
-
const [step, setStep] = useState<{ id: number, stop: number, phase: Phase }>()
|
|
25
|
-
const facing = useRef<'left' | 'right'>('right'), last = useRef<Point>()
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (id !== undefined && count > 0) setStep(current => current?.id === id ? current : { id, stop: 0, phase: 'walk' })
|
|
28
|
-
}, [id, count])
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!step || step.phase === 'gone') return
|
|
31
|
-
const stops = Math.min(STOPS, count)
|
|
32
|
-
const next: typeof step = step.phase === 'walk' ? { ...step, phase: 'pat' }
|
|
33
|
-
: step.phase === 'pat' ? (step.stop + 1 < stops ? { ...step, stop: step.stop + 1, phase: 'walk' } : { ...step, phase: 'done' })
|
|
34
|
-
: { ...step, phase: 'gone' }
|
|
35
|
-
const timer = setTimeout(() => setStep(next), step.phase === 'walk' ? WALK_MS : step.phase === 'pat' ? PAT_MS : DONE_MS)
|
|
36
|
-
return () => clearTimeout(timer)
|
|
37
|
-
}, [step, count])
|
|
38
|
-
if (!enabled || !step || step.phase === 'gone' || step.id !== id) return null
|
|
39
|
-
const point = where(Math.min(step.stop, count - 1))
|
|
40
|
-
if (!point) return null
|
|
41
|
-
if (last.current && Math.abs(point.x - last.current.x) > 2 && step.phase === 'walk') facing.current = point.x < last.current.x ? 'left' : 'right'
|
|
42
|
-
if (step.phase === 'walk') last.current = point
|
|
43
|
-
const action: MascotAction = step.phase === 'walk' ? 'walk' : step.phase === 'pat' ? 'write' : 'done'
|
|
44
|
-
return (
|
|
45
|
-
<div className="pmw-change-trail" data-phase={step.phase} style={{ '--pmw-trail-x': `${point.x}px`, '--pmw-trail-y': `${point.y}px` } as CSSProperties}>
|
|
46
|
-
<div className="pmw-change-trail__facing" data-facing={facing.current}><PmMascot size="small" action={action} /></div>
|
|
47
|
-
</div>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** In the preview: the blocks the preview reports blinking, in the active frame's viewport. */
|
|
52
|
-
export function PreviewChangeTrail({ stage, frames }: { stage: RefObject<HTMLDivElement | null>, frames: RefObject<HTMLDivElement | null> }) {
|
|
53
|
-
const trail = useWorkbenchState(state => state.changeTrail)
|
|
54
|
-
return <KittenTrail id={trail?.id} count={trail?.rects.length ?? 0} where={index => {
|
|
55
|
-
const rect = trail?.rects[index]
|
|
56
|
-
const frame = frames.current?.querySelector<HTMLIFrameElement>('iframe[data-active="true"]:not([hidden])')
|
|
57
|
-
const host = stage.current
|
|
58
|
-
if (!rect || !frame || !host) return undefined
|
|
59
|
-
const offset = frame.getBoundingClientRect(), origin = host.getBoundingClientRect()
|
|
60
|
-
return { x: offset.left - origin.left + rect.x, y: offset.top - origin.top + rect.y + rect.height }
|
|
61
|
-
}} />
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** In the editor: each changed block (a text block by its first paragraph), else its page's title, on the sheet. */
|
|
65
|
-
export function EditorChangeTrail({ sheet }: { sheet: RefObject<HTMLDivElement | null> }) {
|
|
66
|
-
const places = useWorkbenchState(state => state.changedPlaces)
|
|
67
|
-
const content = useWorkbenchState(state => state.authoring?.content)
|
|
68
|
-
return <KittenTrail id={places?.id} count={places?.targets.length ?? 0} where={index => {
|
|
69
|
-
const target = places?.targets[index], host = sheet.current
|
|
70
|
-
if (!target || !host) return undefined
|
|
71
|
-
const block = target.block ? content?.blocks[target.block] : undefined
|
|
72
|
-
const ids = [...target.block ? [target.block] : [], ...block?.type === 'text' ? richNodeIds(block.content) : [], pageId(target.section)]
|
|
73
|
-
const element = ids.map(id => host.querySelector<HTMLElement>(`[data-id="${CSS.escape(id)}"]`)).find(Boolean)
|
|
74
|
-
if (!element) return undefined
|
|
75
|
-
const box = element.getBoundingClientRect(), origin = host.getBoundingClientRect()
|
|
76
|
-
// the kitten stands on the place's first line, at its left edge
|
|
77
|
-
return { x: box.left - origin.left, y: box.top - origin.top + Math.min(box.height, 28) }
|
|
78
|
-
}} />
|
|
79
|
-
}
|