🐛 Keep timeline opinion menus in view
This commit is contained in:
parent
dc7c4b9bee
commit
19f28e5957
@ -25,7 +25,7 @@ import { readReviewCaptionPlacement, writeReviewCaptionPlacement } from "../lib/
|
||||
import { reviewCaptionAtTime } from "../lib/review-captions.js";
|
||||
import { sliceEditActionsWithDrafts, workbenchDraftsFingerprint } from "../lib/annotation-autosave.js";
|
||||
import { DiscardReasonFields, type DiscardReasonChoice } from "./DiscardReasonFields";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import { cancelActionPartition, lastActionFrame, moveActionBoundary } from "../lib/action-frame-boundary.js";
|
||||
import { actionJudgment, completeActionPartitions } from "../lib/continuous-actions.js";
|
||||
import { adjacentAnnotation } from "../lib/annotation-list-navigation.js";
|
||||
@ -555,6 +555,17 @@ export function CaptureAnnotationWorkbench({
|
||||
// which is exactly the E′ direct path — fully functional on its own.
|
||||
const [moviVideoReady, setMoviVideoReady] = useState(() => moviElementReady());
|
||||
const [opinionMarkerOpen, setOpinionMarkerOpen] = useState<string | null>(null);
|
||||
const [opinionTrackWidth, setOpinionTrackWidth] = useState(0);
|
||||
const opinionTrackObserver = useRef<ResizeObserver | null>(null);
|
||||
const observeOpinionTrack = useCallback((node: HTMLDivElement | null) => {
|
||||
opinionTrackObserver.current?.disconnect();
|
||||
opinionTrackObserver.current = null;
|
||||
if (!node) return;
|
||||
const measure = () => setOpinionTrackWidth(node.clientWidth);
|
||||
measure();
|
||||
opinionTrackObserver.current = new ResizeObserver(measure);
|
||||
opinionTrackObserver.current.observe(node);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (browserReadyMedia || moviRuntimeMode() !== "movi") return;
|
||||
if (moviElementReady()) {
|
||||
@ -3182,39 +3193,47 @@ export function CaptureAnnotationWorkbench({
|
||||
reviewTimestampOpinions &&
|
||||
reviewTimestampOpinions.length > 0 && (
|
||||
<div
|
||||
ref={observeOpinionTrack}
|
||||
aria-label="时间点意见标记"
|
||||
className="absolute inset-x-0 top-0 z-20 h-4"
|
||||
onPointerDown={(e) => e.stopPropagation()}
|
||||
>
|
||||
{(() => {
|
||||
// §4.3:点位标记不涂红父切片;近邻聚合,重叠可展开选择。
|
||||
// Reserve space for a count badge even when the timeline narrows.
|
||||
const span = Math.max(end - start, 0.001);
|
||||
const badgeSpacing = Math.max(20, String(reviewTimestampOpinions.length).length * 6 + 12);
|
||||
const clusterDistance = opinionTrackWidth > 0 ? Math.max(0.8, (badgeSpacing / opinionTrackWidth) * 100) : 0.8;
|
||||
const sorted = [...reviewTimestampOpinions].sort((a, b) => a.atSeconds - b.atSeconds);
|
||||
const clusters: { key: string; opinions: typeof sorted; left: number }[] = [];
|
||||
for (const opinion of sorted) {
|
||||
const left = Math.min(100, Math.max(0, ((opinion.atSeconds + offset - start) / span) * 100));
|
||||
const last = clusters[clusters.length - 1];
|
||||
if (last && Math.abs(last.left - left) < 0.8) last.opinions.push(opinion);
|
||||
if (last && left - last.left < clusterDistance) last.opinions.push(opinion);
|
||||
else clusters.push({ key: opinion.id, opinions: [opinion], left });
|
||||
}
|
||||
return clusters.map((cluster) => (
|
||||
<div key={cluster.key} className="absolute top-0" style={{ left: `${cluster.left}%` }}>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`时间点意见 ${cluster.opinions.length > 1 ? `${cluster.opinions.length} 条` : cluster.opinions[0].text.slice(0, 12)}`}
|
||||
title={cluster.opinions.map((o) => `${formatTime(o.atSeconds)} ${o.text}`).join("\n")}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (cluster.opinions.length > 1)
|
||||
setOpinionMarkerOpen(opinionMarkerOpen === cluster.key ? null : cluster.key);
|
||||
else reviewController.seekTime(cluster.opinions[0].atSeconds);
|
||||
}}
|
||||
className="block -translate-x-1/2 rounded-full border border-orange-500 bg-orange-400 px-1 text-[9px] font-bold leading-3 text-white shadow"
|
||||
>
|
||||
{cluster.opinions.length > 1 ? cluster.opinions.length : "•"}
|
||||
</button>
|
||||
<Fragment key={cluster.key}>
|
||||
<div className="absolute top-0" style={{ left: `${cluster.left}%` }}>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={`时间点意见 ${cluster.opinions.length > 1 ? `${cluster.opinions.length} 条` : cluster.opinions[0].text.slice(0, 12)}`}
|
||||
title={cluster.opinions.map((o) => `${formatTime(o.atSeconds)} ${o.text}`).join("\n")}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (cluster.opinions.length > 1)
|
||||
setOpinionMarkerOpen(opinionMarkerOpen === cluster.key ? null : cluster.key);
|
||||
else reviewController.seekTime(cluster.opinions[0].atSeconds);
|
||||
}}
|
||||
className="block -translate-x-1/2 rounded-full border border-orange-500 bg-orange-400 px-1 text-[9px] font-bold leading-3 text-white shadow"
|
||||
>
|
||||
{cluster.opinions.length > 1 ? cluster.opinions.length : "•"}
|
||||
</button>
|
||||
</div>
|
||||
{cluster.opinions.length > 1 && opinionMarkerOpen === cluster.key && (
|
||||
<div className="absolute left-0 top-4 z-30 max-h-24 w-44 overflow-auto rounded border border-orange-300 bg-white p-1 text-left text-[10px] shadow-lg dark:border-orange-700 dark:bg-[#151619]">
|
||||
<div
|
||||
className="capture-timestamp-opinion-menu absolute top-4 z-30 max-h-24 overflow-auto rounded border border-orange-300 bg-white p-1 text-left text-[10px] shadow-lg dark:border-orange-700 dark:bg-[#151619]"
|
||||
style={{ "--opinion-marker-position": `${cluster.left}%` } as CSSProperties}
|
||||
>
|
||||
{cluster.opinions.map((o) => (
|
||||
<button
|
||||
key={o.id}
|
||||
@ -3231,7 +3250,7 @@ export function CaptureAnnotationWorkbench({
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Fragment>
|
||||
));
|
||||
})()}
|
||||
</div>
|
||||
|
||||
@ -1235,6 +1235,11 @@
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
}
|
||||
.capture-timestamp-opinion-menu {
|
||||
--opinion-menu-width: min(11rem, 100%);
|
||||
width: var(--opinion-menu-width);
|
||||
inset-inline-start: min(var(--opinion-marker-position), 100% - var(--opinion-menu-width));
|
||||
}
|
||||
|
||||
/* Dense actions keep the existing player/editor structure, adding only a
|
||||
narrow selection rail; the same axes survive every camera presentation. */
|
||||
|
||||
@ -602,6 +602,46 @@ try {
|
||||
"dense left list scrolls instead of expanding the video row",
|
||||
);
|
||||
await page.screenshot({ path: `${out}/dense-focused-scrollbar.png`, fullPage: true });
|
||||
|
||||
actionMode = "ready";
|
||||
draft.problems = Array.from({ length: 160 }, (_, index) => ({
|
||||
id: `dense-note-${index}`,
|
||||
sourceItemId: "synthetic-source",
|
||||
sliceId: index < 158 ? "slice-000001" : "slice-000003",
|
||||
timeBasis: "slice-seconds",
|
||||
scope: "timestamp",
|
||||
atSeconds: index < 158 ? index * 0.045 : index === 158 ? 7.7 : 7.8,
|
||||
text: `时间点样例 ${index + 1}`,
|
||||
}));
|
||||
await page.setViewportSize({ width: 850, height: 800 });
|
||||
await page.goto(`${base}/__acceptance_playback_rate?readonly=1`);
|
||||
const layer = page.getByLabel("时间点意见标记", { exact: true });
|
||||
const badges = layer.getByRole("button", { name: /^时间点意见 \d+ 条$/ });
|
||||
await badges.first().waitFor();
|
||||
assert(
|
||||
await badges.evaluateAll((buttons) =>
|
||||
buttons.every(
|
||||
(button, index) =>
|
||||
index === 0 || buttons[index - 1].getBoundingClientRect().right <= button.getBoundingClientRect().left,
|
||||
),
|
||||
),
|
||||
"dense markers in a narrow viewport must stay individually clickable",
|
||||
);
|
||||
await page.getByRole("combobox", { name: "切片列表", exact: true }).selectOption({ index: 2 });
|
||||
const group = layer.getByRole("button", { name: "时间点意见 2 条", exact: true });
|
||||
await group.click();
|
||||
const endNote = layer.getByRole("button", { name: /时间点样例 160$/ });
|
||||
const popup = await endNote.evaluate((button) => {
|
||||
const menu = button.parentElement.getBoundingClientRect();
|
||||
const layer = button.closest('[aria-label="时间点意见标记"]').getBoundingClientRect();
|
||||
return { offset: menu.left - layer.left, rightGap: layer.right - menu.right };
|
||||
});
|
||||
assert(popup.offset >= 0 && popup.rightGap >= -1 && popup.rightGap < 2, "end menu must fit inside the axis");
|
||||
await endNote.click();
|
||||
await page.waitForFunction(() => {
|
||||
const slider = document.querySelector('[aria-label="总视频播放位置"]');
|
||||
return Math.abs(Number(slider.value) - 23.8) < 0.04;
|
||||
});
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
await page.screenshot({ path: `${out}/${engine}.png`, fullPage: true });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user