---
title: Architecture
url: https://lhero.org/portfolio/lh-spreadsheets/architecture/
date: 2026-10-25T01:48:00+11:00
modified: 2026-10-25T02:45:11+11:00
type: lh-portfolio-doc
---

- **Part of:** [LH Spreadsheets](https://lhero.org/portfolio/lh-spreadsheets/)

## Storage

A spreadsheet is a post of type `lh_spreadsheet` (filter `lh_spreadsheets_return_post_type`). Its `post_content` is a single `lh-spreadsheets/sheet` block whose `workbook` object attribute holds the Univer workbook snapshot (`IWorkbookData`). The title is `post_title` and the description `post_excerpt`. The post type registers that block as its locked template (`template_lock: all`), so a spreadsheet always contains exactly one grid.

Before 2.0.0 the workbook was a JSON string in a `sheetData` attribute, which stored every double quote as a six-character unicode escape and roughly doubled the size on disk. A block deprecation migrates it to `workbook` when the post is opened, and the REST API reads both forms.

## The editor: Univer inside the canvas iframe

In the iframed block editor, block JavaScript runs in the parent admin window while the block’s DOM lives in the canvas iframe. Univer listens on, measures and portals into its own `window` and `document`, so run from the parent it renders nothing usable: menus and dropdowns land in the wrong document and its stylesheet never reaches the canvas. That was why 1.x never worked on WordPress 7.0.

- `build/univer-host.js` bundles Univer with its own React and no WordPress externals, and exposes `window.LHSpreadsheets.mount( element, workbook, onChange )`.
- It and `build/univer-host.css` are enqueued on `enqueue_block_assets`, only on the spreadsheet editor screen and only during core’s iframe pass (when `wp_should_load_block_editor_scripts_and_styles()` is false). Univer’s stylesheet has global resets that would restyle wp-admin if it reached the parent page.
- The block’s edit component (`build/index.js`) is thin: it finds `LHSpreadsheets` on the iframe’s own window (waiting for the `lh-spreadsheets-ready` event if needed) and mounts the grid into its element.
- Univer’s lazy chunks load on demand from `build/univer-host-chunks/`. The bundle is minified ASCII-only, so it parses whatever charset the server sends with `.js` files.
- Theme styles are stripped from the spreadsheet editor canvas (`block_editor_settings_all`).