From 4016b2b38b728ea7eb885279cd889276a1b25862 Mon Sep 17 00:00:00 2001 From: Qijun Date: Tue, 27 Oct 2026 00:07:23 -0700 Subject: [PATCH] fix: a Word text box written only as a drawing is marked where it stood, and the Tutorial says where folders cannot be added Mammoth reads a text box only through the VML copy Word writes beside it; a box written in DrawingML alone, as Google Docs and generated reports write it, lost its text without a word. It now gets "(Text box not converted)", like charts and equations. The Tutorial no longer tells iPhone and iPad readers to add folders or drop them onto Files. Closes #222 Closes #236 --- tutorial/guide/Files and projects.md | 4 ++-- ui-packages/web/src/formats/docx-unconverted.test.ts | 9 ++++++++- ui-packages/web/src/formats/docx-unconverted.ts | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tutorial/guide/Files and projects.md b/tutorial/guide/Files and projects.md index 6f2a918..9cd9411 100644 --- a/tutorial/guide/Files and projects.md +++ b/tutorial/guide/Files and projects.md @@ -7,10 +7,10 @@ Everything you read lives in **Files**, the panel on the left. A project is one Choose **+** at the top of Files: - **Add files…** picks one or more files from your computer. -- **Add folder…** brings in a whole folder and keeps its structure. Desktop Chrome and Edge read the folder directly; other browsers use their folder upload. +- **Add folder…** brings in a whole folder and keeps its structure. Desktop Chrome and Edge read the folder directly; other browsers use their folder upload. iPhone and iPad cannot choose a folder, so there the entry is missing; add the files instead. - **Add from URL…** downloads a file or folder from an address and opens it. -You can also drop files or folders onto Files. +On a computer, you can also drop files or folders onto Files. **Add from URL…** understands a few kinds of address: diff --git a/ui-packages/web/src/formats/docx-unconverted.test.ts b/ui-packages/web/src/formats/docx-unconverted.test.ts index 33230a8..9a455a2 100644 --- a/ui-packages/web/src/formats/docx-unconverted.test.ts +++ b/ui-packages/web/src/formats/docx-unconverted.test.ts @@ -10,6 +10,7 @@ const namespaces = [ 'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"', 'xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"', 'xmlns:dgm="http://schemas.openxmlformats.org/drawingml/2006/diagram"', + 'xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"', 'xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"', 'xmlns:v="urn:schemas-microsoft-com:vml"', ].join(' ') @@ -55,6 +56,10 @@ const diagram = drawing( 'http://schemas.openxmlformats.org/drawingml/2006/diagram', '', ) +const textBox = drawing( + 'http://schemas.microsoft.com/office/word/2010/wordprocessingShape', + 'Amount due', +) describe('unconverted Word content', () => { it('leaves a document whose content all converts exactly as it was', async () => { @@ -66,7 +71,7 @@ describe('unconverted Word content', () => { expect(markdown).toBe('**Styled body**') }) - it('marks equations, charts and diagrams where they stood', async () => { + it('marks equations, charts, diagrams and text boxes where they stood', async () => { const { markdown } = await convertDocxToMarkdown( await docx( [ @@ -75,6 +80,7 @@ describe('unconverted Word content', () => { 'Inline x', `${chart}`, `${diagram}`, + `${textBox}`, paragraph('After'), ].join(''), ), @@ -85,6 +91,7 @@ describe('unconverted Word content', () => { 'Inline *(Equation not converted)*', '*(Chart not converted)*', '*(Diagram not converted)*', + '*(Text box not converted)*', 'After', ]) }) diff --git a/ui-packages/web/src/formats/docx-unconverted.ts b/ui-packages/web/src/formats/docx-unconverted.ts index 23f8c84..4cb46ea 100644 --- a/ui-packages/web/src/formats/docx-unconverted.ts +++ b/ui-packages/web/src/formats/docx-unconverted.ts @@ -5,6 +5,7 @@ const namespaces = { m: 'http://schemas.openxmlformats.org/officeDocument/2006/math', c: 'http://schemas.openxmlformats.org/drawingml/2006/chart', dgm: 'http://schemas.openxmlformats.org/drawingml/2006/diagram', + wps: 'http://schemas.microsoft.com/office/word/2010/wordprocessingShape', mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006', v: 'urn:schemas-microsoft-com:vml', } @@ -59,6 +60,9 @@ const markEquations = (document: Document) => { const drawingLabel = (drawing: Element) => { if (contains(drawing, namespaces.c, 'chart')) return 'Chart' if (contains(drawing, namespaces.dgm, 'relIds')) return 'Diagram' + // Word writes its text boxes twice and Mammoth reads the VML copy; a box written only this way, + // as Google Docs and generated reports do, would lose its text. + if (contains(drawing, namespaces.wps, 'txbx')) return 'Text box' return null }