|
@@ -107,7 +107,7 @@ function collectParagraphs(doc: ProsemirrorNode): ParagraphInfo[] {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Build the combined text (joined by \n) and boundary offsets.
|
|
|
|
|
|
|
+ * Build the combined text (joined by \n\n) and boundary offsets.
|
|
|
* boundaries[0] = 0, boundaries[i] = start offset of paragraph i,
|
|
* boundaries[0] = 0, boundaries[i] = start offset of paragraph i,
|
|
|
* boundaries[N] = total length (last para end, no trailing \n).
|
|
* boundaries[N] = total length (last para end, no trailing \n).
|
|
|
*/
|
|
*/
|
|
@@ -117,11 +117,14 @@ function buildCombinedText(paragraphs: ParagraphInfo[]): {
|
|
|
} {
|
|
} {
|
|
|
const parts: string[] = []
|
|
const parts: string[] = []
|
|
|
const boundaries: number[] = [0]
|
|
const boundaries: number[] = [0]
|
|
|
- for (const p of paragraphs) {
|
|
|
|
|
- parts.push(p.text)
|
|
|
|
|
- boundaries.push(boundaries[boundaries.length - 1]! + p.text.length + 1)
|
|
|
|
|
|
|
+ for (let i = 0; i < paragraphs.length; i++) {
|
|
|
|
|
+ parts.push(paragraphs[i]!.text)
|
|
|
|
|
+ const sepLen = i < paragraphs.length - 1 ? 2 : 1
|
|
|
|
|
+ boundaries.push(
|
|
|
|
|
+ boundaries[boundaries.length - 1]! + paragraphs[i]!.text.length + sepLen,
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
- return { text: parts.join("\n"), boundaries }
|
|
|
|
|
|
|
+ return { text: parts.join("\n\n"), boundaries }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|