Skip to content

Commit 75c3835

Browse files
fix(web): Word previews keep paragraphs up to 128K characters
The per-paragraph text limit stopped the preview at the first paragraph over 32K characters, which main previewed in full. Raise it to main's effective 128 KB per-element cap. AI-assisted; verified with the tests and tools listed above.
1 parent 1c686cc commit 75c3835

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎apps/web/src/components/files/officeArchive.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe("Word preview limits", () => {
9191
expect(await result.part("word/document.xml")).toContain("Item 5999");
9292
});
9393

94-
const text = "x".repeat(40_000);
94+
const text = "x".repeat(140_000);
9595
it.each([
9696
["on its own", `<w:p><w:r><w:t>${text}</w:t></w:r></w:p>`],
9797
[
@@ -110,7 +110,7 @@ describe("Word preview limits", () => {
110110
});
111111

112112
it("counts only the text a paragraph lays out", async () => {
113-
const formatted = `<w:p>${" ".repeat(40_000)}<w:r><w:instrText>${"x".repeat(40_000)}</w:instrText></w:r><w:r><w:t>Short</w:t></w:r></w:p>`;
113+
const formatted = `<w:p>${" ".repeat(140_000)}<w:r><w:instrText>${"x".repeat(140_000)}</w:instrText></w:r><w:r><w:t>${"x".repeat(40_000)}</w:t></w:r></w:p>`;
114114
const result = await prepared(await wordFile(formatted + paragraph("After")));
115115
expect(result.truncated).toBe(false);
116116
expect(await result.part("word/document.xml")).toContain("After");

‎apps/web/src/components/files/officeArchive.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export const WORD_LIMITS = {
1818
bodyTags: 1_000_000,
1919
/** A table is laid out in one go: 100,000 tags is a 4,000-row table, about 2 s. */
2020
elementTags: 100_000,
21-
/** Line breaking grows with the square of a paragraph's text: 32K characters take about 1.5 s. */
22-
paragraphText: 32 * 1024,
21+
/** Line breaking grows with the square of a paragraph's text: 40K characters take about 2 s. */
22+
paragraphText: 128 * 1024,
2323
styles: 8_192,
2424
styleBytes: 16 * 1024 * 1024,
2525
styleUnits: 400_000,

0 commit comments

Comments
 (0)