diff --git a/TODO.md b/TODO.md index 0381195..54b9896 100644 --- a/TODO.md +++ b/TODO.md @@ -128,8 +128,10 @@ - [x] **Image converter** (Tools → Image converter): pictures to JPG, PNG or WebP in the browser (nothing uploaded): pick or drop several, a quality slider for JPG and WebP, download each or all. JPG fills transparency white. Media's images each have a Download as… (JPG, PNG, WebP) doing the same (`src/lib/convertImage.ts`). - [x] **Directory tabs** (migration 078): the People directory preset takes several People tags, a tab each in the order picked (Directory: tags under the section); one tag shows without tabs, reading mode lists every tag. Each section's old single tag became its first. - [x] **Blog post tabs** (migration 079): a Tab block in a post (its text the tab's title) starts a tab holding the blocks after it; blocks before the first Tab are the intro above the tabs. The contents list follows the open tab, a link to a heading in another tab opens it, and Download PDF and reading mode show every tab under its title. Outside a post a Tab block reads as a heading. +- [x] **Featured event card height** (Sections): from lg up the event's photo sits beside its words instead of above them, with tighter type and buttons, so the card is about as tall as the hero's text beside it; stacked as before on a phone. The photo stays whole (16:9). +- [x] **Word import, more of it** (Page Features): a line starting `Tab:` (any style) starts a tab; the Quote style becomes a Quote (a dash and a name at the end is who said it), Intense Quote a Callout, a line of `---` a Divider, a YouTube, Vimeo or Facebook link alone on its line a Video, and `Button: Register` with Register linked a Button. Blog posts → What becomes what (beside Import from Word) shows the whole mapping; `docs/importing.md` too. The note after an import counts tabs and the rest. - [x] **Side nav sun into the footer** (Navigation): the sun is far bigger than the sticky layer that carries it, so once the last section went up past the list it hung over the footer. It now fades out as the list leaves with the last section, and back in on the way up. - - [ ] Check in a browser: the side nav sun fading at the end of a long page (2xl screen) and with a tall footer; the featured event hero at phone and desktop width, the footers' version line, converting a PNG with transparency to JPG and a JPG to WebP (and Download as in Media), a Directories section with two tags and with one, a post with an intro and three tabs (contents, keyboard arrows, PDF, reading mode). + - [ ] Check in a browser: the featured event card beside a two-line headline at 1024, 1280 and 1536px; What becomes what and a real Word document with Tab: lines, a quote and a video link; the side nav sun fading at the end of a long page (2xl screen) and with a tall footer; the featured event hero at phone and desktop width, the footers' version line, converting a PNG with transparency to JPG and a JPG to WebP (and Download as in Media), a Directories section with two tags and with one, a post with an intro and three tabs (contents, keyboard arrows, PDF, reading mode). ## Page Editing (branch `nav-access`, no PR yet; migration 077) - [x] **Drafts of every record** (migration 077, `docs/drafts.md`): an existing record of any kind (events, people, organizations, blog posts, the front page, the site pages, Navigation, Site settings...) can be saved as a draft instead of going live. One draft per record; anyone who can edit it can save, preview, publish or discard it. Opening a record with a draft opens the draft, saying who saved it and when, and warning when the live record was saved since. Lists mark records with a draft. diff --git a/docs/importing.md b/docs/importing.md index 3d770f2..1c77c96 100644 --- a/docs/importing.md +++ b/docs/importing.md @@ -18,6 +18,19 @@ authors and a cover, then tick Published. | 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 | +And lines written a certain way, in any style: + +| In the document | In the post | +| --- | --- | +| A line starting `Tab:`, eg. `Tab: Overview` | A Tab block: the post is split into tabs from there (the blocks before the first are the intro above the tabs) | +| The Quote style | A Quote block; a dash and a name at the end (`... - Jane Doe`) is who said it | +| The Intense Quote style | A Callout block | +| A line of `---` alone | A Divider | +| A YouTube, Vimeo or Facebook link alone on its line (the link text can be anything) | A Video block | +| `Button: Register`, with "Register" linked | A Button block, its label and link | + +The same table is on Blog posts, beside Import from Word (What becomes what). + 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. diff --git a/server/src/docx.js b/server/src/docx.js index 09d0567..d7b7806 100644 --- a/server/src/docx.js +++ b/server/src/docx.js @@ -14,6 +14,17 @@ cells split by |) bold, italic, links **bold**, *italic*, [text](url) + And a few lines written a certain way (docs/importing.md), any + style: + "Tab: Overview" a tab block (079): the post + is split into tabs there + the Quote style a quote block + the Intense Quote style a callout block + "---" alone a divider + a YouTube, Vimeo or Facebook link a video block + alone on its line + "Button: [Register](https://…)" a button block + Images, text boxes, footnotes and comments aren't carried over; the result counts what was skipped so the editor can say so. @@ -216,7 +227,7 @@ export function readDocx(buf) { if (!text) continue; const level = style === "title" ? 0 : Number(/^heading (\d)/.exec(style)?.[1] ?? NaN); - if (!title && (level === 0 || level === 1)) { + if (!title && (level === 0 || level === 1) && !lineBlock(text, style)) { close(); title = text.replace(/\*/g, ""); continue; @@ -231,6 +242,12 @@ export function readDocx(buf) { continue; } } + const special = lineBlock(text, style); + if (special) { + close(); + blocks.push(special); + continue; + } if (level >= 1) { close(); blocks.push({ type: level <= 2 ? "heading" : "subheading", text: text.replace(/\*/g, "") }); @@ -248,3 +265,37 @@ export function readDocx(buf) { return { title, date, blocks, skipped: counts }; } + +/* ── Lines written a certain way ──────────────────────────────── */ + +const VIDEO_HOST = /^https?:\/\/(www\.)?(youtube\.com|youtu\.be|m\.youtube\.com|vimeo\.com|player\.vimeo\.com|facebook\.com|fb\.watch)\//i; + +/* The one link a line is made of, "[text](url)" or a bare url, or null. */ +function loneLink(text) { + const md = /^\[[^\]]*\]\(([^)\s]+)\)$/.exec(text); + if (md) return md[1]; + return /^https?:\/\/\S+$/.test(text) ? text : null; +} + +/* A block a paragraph stands for by how it's written, or null for an + ordinary one (docs/importing.md). */ +function lineBlock(text, style) { + const plain = text.replace(/\*/g, "").trim(); + const tab = /^tab:\s*(.+)$/i.exec(plain); + if (tab) return { type: "tab", text: tab[1].trim().slice(0, 80) }; + if (/^(-{3,}|_{3,})$/.test(plain)) return { type: "divider" }; + + const button = /^button:\s*\[([^\]]+)\]\(([^)\s]+)\)$/i.exec(text.trim()); + if (button) return { type: "button", text: button[1].replace(/\*/g, ""), href: button[2] }; + + const link = loneLink(text.trim()); + if (link && VIDEO_HOST.test(link)) return { type: "video", href: link }; + + if (style === "intense quote") return { type: "callout", text }; + if (style === "quote") { + // A dash and a name at the end ("… - Jane Doe", any dash) is who said it. + const said = /^(.*\S)\s+[—–-]\s*([^—–-]{2,80})$/.exec(text); + return said ? { type: "quote", text: said[1], cite: said[2].trim() } : { type: "quote", text }; + } + return null; +} diff --git a/server/src/routes/import.js b/server/src/routes/import.js index d1c591d..e47818d 100644 --- a/server/src/routes/import.js +++ b/server/src/routes/import.js @@ -74,6 +74,8 @@ export function importDocx(db, buffer, fileName, byEmail) { slot: "body", type: block.type, text: block.text ?? null, + href: block.href ?? null, + cite: block.cite ?? null, items: block.items ?? [], })), }); @@ -87,6 +89,9 @@ export function importDocx(db, buffer, fileName, byEmail) { paragraphs: count("paragraph"), lists: count("list"), tables: count("table"), + tabs: count("tab"), + // Quotes, callouts, dividers, videos and buttons. + others: doc.blocks.filter((b) => ["quote", "callout", "divider", "video", "button"].includes(b.type)).length, skipped: doc.skipped, }, }; diff --git a/src/lib/adminSchema/blog.ts b/src/lib/adminSchema/blog.ts index 7a6033d..d70a5c0 100644 --- a/src/lib/adminSchema/blog.ts +++ b/src/lib/adminSchema/blog.ts @@ -46,7 +46,32 @@ export const blogPosts = { idLabel: "URL ID", slugFrom: "title", // Blog posts → Import from Word (server/src/routes/import.js). - importer: { label: "Import from Word", endpoint: "/admin/import/docx", accept: ".docx" }, + // `guide` is what becomes what (server/src/docx.js, docs/importing.md), + // shown beside the button. + importer: { + label: "Import from Word", + endpoint: "/admin/import/docx", + accept: ".docx", + guide: { + intro: "A .docx becomes a new, unpublished post. In the document:", + rows: [ + ["The Title style, or the first Heading 1", "The post's title"], + ["A date line under it, eg. Sep 28, 2026", "The post's date"], + ["Heading 1 and Heading 2", "Heading blocks"], + ["Heading 3 and smaller", "Subheading blocks"], + ["A line starting Tab:, eg. Tab: Overview (any style)", "A Tab: the post is split into tabs from there"], + ["The Quote style", "A Quote (a dash and a name at the end is who said it)"], + ["The Intense Quote style", "A Callout"], + ["Bulleted or numbered paragraphs", "One List block"], + ["Tables", "Table blocks"], + ["A line of --- alone", "A Divider"], + ["A YouTube, Vimeo or Facebook link alone on its line", "A Video"], + ["Button: Register, with Register linked", "A Button, its label and link"], + ["Other paragraphs", "Paragraphs, keeping bold, italic and links"], + ], + outro: "Images, text boxes, footnotes, comments, colors and fonts aren't carried over: add images as Image blocks after. PDFs: save as .docx first.", + }, + }, list: { columns: [ diff --git a/src/pages/admin/EntityEdit.tsx b/src/pages/admin/EntityEdit.tsx index 67f8e3d..f7fed00 100644 --- a/src/pages/admin/EntityEdit.tsx +++ b/src/pages/admin/EntityEdit.tsx @@ -691,6 +691,8 @@ function ImportedNote() { `${summary.paragraphs} paragraphs`, `${summary.lists} lists`, `${summary.tables} tables`, + ...(summary.tabs ? [`${summary.tabs} tabs`] : []), + ...(summary.others ? [`${summary.others} quotes, callouts, dividers, videos and buttons`] : []), ]; return (
diff --git a/src/pages/admin/EntityList.tsx b/src/pages/admin/EntityList.tsx index 072f9fd..86b5b45 100644 --- a/src/pages/admin/EntityList.tsx +++ b/src/pages/admin/EntityList.tsx @@ -282,13 +282,40 @@ function ImportButton({ manifest }: { manifest: any }) { } } + const guide = manifest.importer.guide; + return ( -
{guide.intro}
+| In Word | +In the post | +
|---|---|
| {from} | +{to} | +
{guide.outro}
} +