fix(web): 审稿面板去重标题/去英文 slug + 伏笔待登记数实时递减 + 移动端决策栏 + 对比度修复

This commit is contained in:
Yaojia Wang
2026-06-30 08:56:23 +02:00
parent 69030eacc3
commit f0f925b195
6 changed files with 114 additions and 40 deletions

View File

@@ -1,8 +1,12 @@
"use client";
import { useRef, type ReactNode, type RefObject } from "react";
import Link from "next/link";
import { PenLine } from "lucide-react";
import { EmptyState } from "@/components/ui/EmptyState";
import { locateInDraft } from "@/lib/review/locate";
import { buttonClass, proseBody } from "@/lib/ui/variants";
import type { ReviewConflict } from "@/lib/review/sse";
interface AnnotatedTextProps {
@@ -12,14 +16,16 @@ interface AnnotatedTextProps {
// 当前聚焦的冲突下标(来自报告卡「跳转」/锚点),用于锚点高亮联动。
focusedIndex: number | null;
onAnchorClick: (index: number) => void;
// 空待审正文时,引导回写作页起草本章。
projectId: string;
chapterNo: number;
// 转发给可编辑 textarea供父组件 setSelectionRange 定位/高亮问题区域。
editorRef?: RefObject<HTMLTextAreaElement | null>;
}
// 高亮叠层编辑器:背景层渲染带 <mark> 高亮的正文,前景透明 textarea 负责编辑。
// 两层必须共享同一盒模型/排版常量,否则高亮与文字像素错位。
const TYPO =
"box-border w-full font-serif text-[17px] leading-[1.9] tracking-normal whitespace-pre-wrap break-words";
// 两层必须共享同一盒模型/排版常量,否则高亮与文字像素错位;正文排版与写作页 Editor 一致proseBody
const TYPO = `box-border w-full whitespace-pre-wrap break-words ${proseBody}`;
// 把终稿按已定位的冲突区间切成 [纯文本 | <mark> | …]<mark> 带 id 供父组件滚动定位。
// 区间按 start 排序,重叠区间保留先到者(跳过后者),避免标签嵌套。
@@ -61,6 +67,8 @@ export function AnnotatedText({
conflicts,
focusedIndex,
onAnchorClick,
projectId,
chapterNo,
editorRef,
}: AnnotatedTextProps) {
const backdropRef = useRef<HTMLDivElement>(null);
@@ -69,6 +77,26 @@ export function AnnotatedText({
const anchorable = conflicts
.map((c, i) => ({ c, i }))
.filter(({ c }) => locateInDraft(value, c) !== null);
// 空待审正文:不渲染高亮叠层,直接引导回写作页起草本章(避免对着空编辑器发懵)。
if (!value) {
return (
<EmptyState
icon={PenLine}
title="本章还没有待审正文"
description="先到写作页起草本章,写完回到这里审稿、裁决与验收。"
action={
<Link
href={`/projects/${projectId}/write?chapter=${chapterNo}`}
className={buttonClass({ variant: "primary" })}
>
<PenLine className="h-4 w-4" aria-hidden="true" />
</Link>
}
/>
);
}
return (
<div className="flex flex-col gap-3">
{anchorable.length > 0 ? (
@@ -104,13 +132,7 @@ export function AnnotatedText({
aria-hidden="true"
className={`${TYPO} pointer-events-none relative select-none text-ink`}
>
{value ? (
segments
) : (
<span className="text-ink-soft/60">
</span>
)}
{segments}
{"\n"}
</div>
{/* 前景编辑层:文字透明(由背景层显示),仅保留光标;无内部滚动(页面滚动)。 */}