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:
parent
adc88e5714
commit
7f12824c93
16 changed files with 656 additions and 6 deletions
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
import { ArrowLeft } from "@phosphor-icons/react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import { get, post, patch, del, ApiError } from "../../lib/api.ts";
|
||||
import { isUnauthorized, useAuth } from "../../lib/auth.tsx";
|
||||
|
|
@ -367,6 +367,8 @@ export default function EntityEdit() {
|
|||
{isNew ? `New ${manifest.singular}` : heading}
|
||||
</h1>
|
||||
|
||||
<ImportedNote />
|
||||
|
||||
{/* Straight in the page, not wrapped: a sticky element only
|
||||
travels within its parent, so its parent has to be tall. */}
|
||||
<SectionJump sections={sections} />
|
||||
|
|
@ -527,3 +529,25 @@ export default function EntityEdit() {
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* After Import from Word (EntityList's ImportButton): what came over,
|
||||
and what's left to do before publishing. Gone on the next visit. */
|
||||
function ImportedNote() {
|
||||
const summary = (useLocation().state as any)?.imported;
|
||||
if (!summary) return null;
|
||||
const parts = [
|
||||
`${summary.headings} headings`,
|
||||
`${summary.paragraphs} paragraphs`,
|
||||
`${summary.lists} lists`,
|
||||
`${summary.tables} tables`,
|
||||
];
|
||||
return (
|
||||
<p role="status" className="mt-4 rounded-xl border border-brand/20 bg-tint px-4 py-3 text-sm text-body">
|
||||
Imported from Word: {parts.join(", ")}.
|
||||
{summary.skipped?.images
|
||||
? ` ${summary.skipped.images} image${summary.skipped.images === 1 ? " was" : "s were"} not carried over; add them as Image blocks.`
|
||||
: ""}{" "}
|
||||
It's saved unpublished: check it, add the authors and a cover, then tick Published.
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue