paragraph-content 返回的是 sentences([book, para, start, end] 坐标数组), 前端类型却写成从未返回的 sentenceIds,ParaHandle 里 sentences.map 对 undefined 抛错。类型改成 sentences,在 Paragraph 里拼成 b-p-s-e 句子编号。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -172,7 +172,8 @@ export interface IParagraphNode {
para: number;
mode?: ArticleMode;
channels?: string[];
- sentenceIds: string[];
+ /** 段落内的句子坐标 [book, para, wordStart, wordEnd] */
+ sentences: [number, number, number, number][];
children?: IWidgetSentEditInner[];
}
@@ -22,7 +22,7 @@ const Paragraph = ({
para,
mode,
channels,
- sentenceIds,
+ sentences,
children,
loading,
onModeChange,
@@ -53,6 +53,11 @@ const Paragraph = ({
}, [book, focus, para]);
+ const sentenceIds = useMemo(
+ () => (sentences ?? []).map((item) => item.join("-")),
+ [sentences]
+ );
+
const borderColor = isFocus ? "#e35f00bd " : "rgba(128, 128, 128, 0.3)";
const border = mode === "read" ? "" : "2px solid " + borderColor;