Import a Word document as a blog post, and add table blocks

- Table content blocks (migration 044): a grid of text, a row per
  line, cells split by |, the first row the header; cells take the
  same formatting as a paragraph; wide tables scroll on a phone
- Blog posts -> Import from Word: the server reads the .docx (zip and
  XML read without a library, sizes capped) and creates an unpublished
  post through the CRUD engine: title, date, headings, paragraphs,
  lists, tables, bold, italic and links; the editor opens with a note
  of what came over and what didn't (images)
- docs/importing.md, and an nginx block for the upload

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 12:44:20 -05:00
parent adc88e5714
commit 7f12824c93
16 changed files with 656 additions and 6 deletions

63
docs/importing.md Normal file
View file

@ -0,0 +1,63 @@
# Importing a Word document as a blog post
Admin → Pages → Blog posts → **Import from Word** (editors and up). Pick
a `.docx`; the server turns it into a new blog post, **unpublished**, and
opens it in the editor with a note of what came over. Check it, add the
authors and a cover, then tick Published.
## What becomes what
| In the document | In the post |
| --- | --- |
| The Title, or the first Heading 1 | The post's title (the file name if there's neither) |
| A date line right under the title, eg. "Sep 28, 2026 · @Aidan" | The post's date (the rest of that line is dropped) |
| Heading 1 and Heading 2 | Heading blocks |
| Heading 3 and smaller | Subheading blocks |
| Paragraphs | Paragraph blocks |
| A run of bulleted or numbered paragraphs | One List block, one item each |
| Tables | Table blocks: a row per line, cells split by `\|`, the first row the header |
| Bold, italic, links (http, https, mailto) | `**bold**`, `*italic*`, `[text](url)`, in paragraphs, list items and table cells |
A post with three headings or more gets **Show contents** turned on. The
URL ID is the title as a slug, with `-2`, `-3` when it's taken.
Not carried over: images and drawings (the note says how many; add them
as Image blocks), text boxes, footnotes, comments, colours and fonts.
Numbered lists come over as bulleted lists.
The conversion is `server/src/docx.js`; the route is
`server/src/routes/import.js`.
## PDFs
A PDF has no headings, lists or tables inside it, only positioned
text, so it can't be converted the same way. Open it in Word (or Google
Docs) and save it as `.docx` first, or have it converted by hand.
## Table blocks
Any page's content blocks can have one (Content blocks → Type → Table):
```
Platform | Monthly cost | Best for
Zeffy | Free | Fee-free giving
[Breeze](https://www.breezechms.com) | $72 | **Small churches**
```
A literal `|` inside a cell is written `\|`. On a phone a wide table
scrolls sideways in its box.
## nginx
nginx caps `/api/` bodies at 64k, so the upload needs its own block
(in the site's `server` block, beside `/api/admin/media`; `nginx-dev`
has it):
```nginx
location = /api/admin/import/docx {
proxy_pass http://127.0.0.1:3001;
# the usual proxy_set_header lines
proxy_read_timeout 60s;
client_max_body_size 11m;
}
```

View file

@ -176,7 +176,7 @@ also in `server/src/admin-schema/` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |