Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Also online at [p10node.github.io/office-engine](https://p10node.github.io/offic

- **Progressive loading**: lazy ZIP, HTTP Range requests, streaming XML parser in a Web Worker → UI never blocks
- **Virtualized views**: only visible pages, cells and slides render
- **DOCX pages cut like Word's**: a paragraph goes on at the top of the next page between two lines, a table between two rows with its header rows repeated; widow / orphan control, keep with next, keep lines together; editing goes on across the page end
- **Editing** with a Google Docs-style toolbar: DOCX text, styles, lists, images, tables; XLSX cells, formulas (540+ functions of Excel and Google Sheets, dynamic arrays, `LET` / `LAMBDA`), formats, borders, rows/columns, sheets; PPTX text, shapes, images, slides, slideshow
- **Fast save**: only edited parts are regenerated, everything else keeps its original bytes
- **Word, Excel and PowerPoint 97-2003, RTF, OpenDocument**: `.doc` / `.xls` / `.ppt`, `.rtf` and `.odt` / `.ods` / `.odp` (also templates and flat XML) are converted in the worker to DOCX / XLSX / PPTX and open **editable**: styles, lists, tables, pictures, headers and footers, notes and comments; formulas with their values, number formats, merged cells, frozen panes; masters, shapes, text and pictures of slides. Saved as `.docx` / `.xlsx` / `.pptx`
Expand Down
4 changes: 4 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ src/embed.ts mount() + <office-viewer>
src/collab real-time collaboration (hub, session, per-format adapters)
```

### DOCX pages

`DocxView` measures the blocks off screen in time slices (`src/react/docx/measure.ts`: a block's height, where a paragraph's lines and a table's rows are), `paginate()` cuts them into pages (`paginate.ts`: pure, lines and rows given, keep rules; unit tests in `test/docx-paginate.test.ts`) and only the pages in view render. The browser breaks the lines; the offset each line starts at is read (`lineStarts`) only for the paragraphs a page in view or an edit cuts. A paragraph split across pages renders as one element per part, each with the paragraph's `data-pa` address and the offsets it holds (`data-from`, `data-to`): `paraEl()` / `posFromDom()` / `domFromPos()` in `src/react/edit/input.ts` map DOM places to paragraph offsets over the parts, so the caret, selections, find and comments need nothing else. Header rows repeated on the following pages of a table are copies without an address (`.de-head-copy`).

## Browser tests

`e2e/*.spec.ts` drive a fixture app (`e2e/app`, served by Vite with `vite.e2e.config.ts`) in headless Chromium through `playwright-core`, one browser and server per file (`e2e/harness.ts`).
Expand Down
14 changes: 8 additions & 6 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
- **HTTP Range**: open a URL → fetch only the bytes needed (256 KB block cache); server without Range support → automatic full-download fallback
- **Streaming XML parser** runs in a **Web Worker** → UI never blocks
- **Progressive render**:
- DOCX: blocks (paragraph/table) stream in → offscreen height measurement in time slices → pagination → only visible pages render
- DOCX: blocks (paragraph/table) stream in → offscreen measurement in time slices (heights, where lines and table rows are) → pagination → only visible pages render
- XLSX: rows stream in, 2D virtualized grid (only cells in viewport render), freeze panes, merge, number format, sheet tabs
- PPTX: slides parsed on demand when scrolled into view, virtualized thumbnails
- **DOCX pages** are cut the way Word cuts them, with the lines the browser lays out: a paragraph that does not fit the rest of a page goes on at the top of the next one (split between two lines, the same lines as when whole; a justified paragraph's last line on the first page stays justified), a table between two rows, its header rows (`w:tblHeader`) repeated at the top of each following page; a merged cell cut by the page end goes on as an empty cell. Keep rules choose the cut: widow / orphan control (on unless the paragraph, its style or the document defaults turn it off), keep lines together, keep with next (a chain of headings goes with the first lines after it; a chain taller than a page is cut like any text). Only one line or one row taller than a page makes its page taller. Text columns are filled the same way, column after column

## Format support

| Format | Supported | Not yet |
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| DOCX | inherited styles, run formatting, lists/numbering, tables (merge, border, shading, table style), images, hyperlinks, header/footer, PAGE field, text boxes, page/section breaks, text columns, tracked changes | footnote body, charts, exact float wrapping, paragraphs split across pages |
| XLSX | shared strings, number/date formats, font/fill/border/align, merge, freeze, hidden columns/rows, wrap, formula calculation (540+ functions, recalculated on edit), multiple sheets, images (over the cells) | charts (placeholder), shapes, conditional formatting |
| PPTX | master/layout/theme, placeholder inheritance, ~50 preset shapes, custGeom, images (crop), tables + table style, groups, bullet/autonum, autofit | charts (placeholder), SmartArt, animations, video playback |
| Format | Supported | Not yet |
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| DOCX | inherited styles, run formatting, lists/numbering, tables (merge, border, shading, table style), images, hyperlinks, header/footer, PAGE field, text boxes, page/section breaks, text columns, tracked changes, paragraphs and tables split across pages | footnote body, charts, exact float wrapping |
| XLSX | shared strings, number/date formats, font/fill/border/align, merge, freeze, hidden columns/rows, wrap, formula calculation (540+ functions, recalculated on edit), multiple sheets, images (over the cells) | charts (placeholder), shapes, conditional formatting |
| PPTX | master/layout/theme, placeholder inheritance, ~50 preset shapes, custGeom, images (crop), tables + table style, groups, bullet/autonum, autofit | charts (placeholder), SmartArt, animations, video playback |

Password-protected (encrypted) files are not supported.

Expand Down Expand Up @@ -177,6 +178,7 @@ Diagram sources open as a document holding the drawing (an SVG picture, editable
- **Images**: insert (file picker/paste/drag & drop), click to select with 8 resize handles, original size, fit width, replace, alt text, download
- **Tables**: insert, add/delete rows & columns, delete table, Tab between cells; select cells by dragging across them, merge / unmerge (across and down), cell color, cell borders (all / outer / inner / none / one side, color, line style), vertical alignment, distribute columns, drag a column edge to resize
- **Page setup**: paper size (A4, Letter, Legal, A3, A5, B5), portrait / landscape, margins (cm, presets), 1–3 text columns with spacing; applies to the whole document
- **Across pages**: a paragraph cut by the end of a page is edited as one: click, type, select, delete, find and arrow keys go over the page end; typing that moves the page end keeps the caret where the typing is (also with an input method). In a table that goes on over pages every row is edited where it is; the header rows repeated on the following pages are copies, edited on the first page
- **Headers & footers**: header, footer and first-page parts (double-click the page's header / footer area, or the toolbar), alignment, bold, size, page number / page count fields with presets ("Page 1 of 5", "Trang 1/5"), different first page
- **Tracked changes**: insertions and deletions from Word shown in their author's color and kept on save; next / previous change, accept / reject (the change at the caret, the selection, or all); *Track changes* records your own edits as suggestions (typing, deleting, pasting, replacing)
- **Other**: select all (Ctrl/⌘+A), link (dialog), special characters, right-click context menu (clipboard, link, table, image, insert, styles), find & replace, word count, undo/redo
Expand Down
3 changes: 1 addition & 2 deletions e2e/docx-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('docx page setup', () => {

const after = await pageBox(v)
expect(after.width / after.height).toBeCloseTo(841.9 / 595.3, 1)
const colsCss = await v.page.locator('.de-page-cols').first().evaluate((el) => getComputedStyle(el).columnCount)
expect(colsCss).toBe('2')
expect(await v.page.locator('.de-page').first().locator('.de-page-cols > .de-page-col').count()).toBe(2)
if (SHOTS) await v.page.screenshot({ path: `${SHOTS}/page-setup-2cols.png` })

const m = await metaOf((await v.save()).bytes)
Expand Down
Loading