Repository navigation
feat(admin): lay out the content editor as a page - #3710
Conversation
The entry editor becomes a Notion-like page: a large title, the content field's Portable Text editor without a frame, and one top bar for navigation, save status, and the view and publish actions, shared with distraction-free mode. The document editor gets a floating sticky toolbar, block handles with a block menu (turn into, align, numbering, duplicate, move, delete), a grouped slash menu with ranked search, Escape block selection, a selection toolbar with turn-into and a link preview, and page typography.
Turn into ran clearNodes, which on a list or quote selected whole from its handle converted only the first item, flattened nested lists, and left a change that Undo couldn't reverse. It also fired for the type a block already had and dropped the block's alignment. The conversion now lifts each text block out of the lists and quotes around it, then applies the new type across all of them, in a single transaction. Switching between list types keeps the list and its nesting, choosing the current type does nothing, and alignment carries over.
…ing blocks - Enter or Down Arrow from the page title no longer selects an image or divider at the top of the body, where the next key replaced it; the caret goes above it. Up Arrow from there returns to the title. - The title keeps main's Enter-to-save when the entry has no body, and ignores the Enter that commits a Safari IME composition. - Select All selects just the code first only inside a code block; elsewhere it selects the whole document, as on main. - A selected block can't be replaced by dictation, autocorrect, or an IME, and Escape closes an open editor menu before it selects a block. - The gap cursor is visible on the dark theme.
…ected - Edit link in a link's preview focuses the URL field; before, it stayed in the text and typing replaced the link. A link edit left open no longer carries over to the next selection. - Removes the Cmd+K link shortcut, which belongs with the other shortcuts in a follow-up. - Escape from the selection toolbar's Turn into and More formatting menus returns to the text instead of leaving focus on the trigger. - The selection toolbar scrolls inside its own surface on narrow screens, so its buttons stay inside it and it stays on screen. - The formatting toolbar no longer turns vertical wheel scrolling into sideways scrolling, which stopped the page from scrolling under it. - The toolbar's heading menu offers headings 1 to 6 again, as on main. - The slash menu's arrow keys follow the listed order when a plugin block shares a built-in category, and a code block alias that could never match is gone. - Clicking below the last block moves the caret to the end without adding an empty paragraph. - The block menu's alignment defaults to the text direction.
…ayouts - The top bar switches its secondary buttons to icons by its own width, not the viewport's, so it stays on one row with the admin sidebar open at 768 to 1023px. Distraction-free mode's extra buttons go first. On touch screens each bar button's target spans the bar's height. - The page's margin doubles as the block handle gutter instead of adding to the canvas padding, giving the column 48px back at mid widths. - Block handles show on touch screens wide enough for the gutter. - Other Portable Text fields keep main's prose typography, block selection styles apply to them too, and their toolbar sticks flush with the top of the editor canvas instead of half under it. - The image and table toolbars use the same surface as the other editor menus, framed blocks are spaced evenly, the divider's handle is centered, and a selected code block's tint follows its corners.
…e test The test ended while the refused publish was still settling. Its queued save then ran against the next test's mock server with a stale token, used up that test's held autosave, and failed it. Waiting for the conflict banner asserts what the test describes and keeps the work inside it.
Only the page layout lacks room for block handles below 640px. The boxed editors on other screens keep them at every width, as on main.
Ordered-list repairs could remap the selected list to a caret inside it after Turn into, so the block menu's conversion dropped out of block selection for nested lists. A block that stays whole is selected again.
…atting - The bar's secondary buttons keep their labels down to 42rem of bar width, distraction-free mode's extras down to 60rem, and the breadcrumb shows from 44rem, so labels no longer vanish with room to spare at 1024px. - Publish and Schedule get the full touch target too; Kumo's primary button clipped it. - The selection toolbar's buttons scroll with the fixed toolbar's edge fade, so a narrow screen shows that more formatting is past the edge.
A boxed editor under 30rem drops to 1rem of side padding, where the handles were cut off by the editor's frame, on main too. They now hide there, as they do on the page below 640px. The touch target's overflow also uncovered the 1px of the primary button's shading that sits below it; clipping that layer keeps the button looking the same.
Keyboard focus stopped 4px short of the end of a scrolled toolbar, so the edge fade stayed over the focused button. Scroll padding matching the toolbar's own padding lets it reach the end.
🦋 Changeset detectedLatest commit: 303dcd5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 5,294 lines across 29 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
Select All only scoped itself to code blocks, so in a paragraph, heading, list item, quote, or table cell it selected the whole document. The first press now selects the text of the block holding the caret, and the second press selects the document.
…everywhere Quotes and list items could hold blocks that Portable Text can't store for them, which were dropped on save: Turn into, the toolbar's Quote button, and /quote wrapped headings, code, and media in a quote, and inserts, input rules, paste, and drag and drop nested blocks in lists and quotes. The schema now limits quotes to paragraphs and list items to text with nested lists, so that content lands beside them instead. - The toolbar's block buttons, the heading menu, and the slash menu convert through Turn into, so every surface gives the same result, joins a new list with a list of the same type beside it, and turns a heading or code block into quoted text. They're disabled where they can't apply, and Turn into also offers mixed selections. - Images, embeds, HTML, dividers, and tables go after a selected block instead of replacing it, and after the list or quote holding the caret. Paste goes after a selected block, and typing can't replace a selected image, divider, or embed. - Alignment is offered only where it's saved, not in lists or quotes. - Links: a bare domain gets https://, a link the editor won't apply keeps its field open, image links reject unsafe URLs, editing a link from the toolbar leaves the caret after it, and typing at the start of a block that opens with a link doesn't extend the link. - Subscript and superscript exclude each other. - The toolbar uses the menus' names (Bulleted list, Code block, Inline code, Add link), and its hover and pressed states show on the boxed editor's toolbar band too, with 44px buttons on touch screens.
A one- or two-letter slash query also matched letters inside titles and descriptions, so /t listed every command and /di listed every heading. Short queries now match title, word, and alias starts and initials (/bl still finds Bulleted list); substring, description, and loose matches need three letters.
- A selected image, HTML block, embed, or gallery gets a brand-coloured edge as well as the tint, which was nearly invisible on media. A selected divider's tint is no longer clipped. - Tables and node views follow the page's block spacing: a table before a heading gets the heading's space, and a code block or embed opening the page starts as close to the toolbar as text does. - Code blocks get a faint edge on the light page, and read left to right in right-to-left documents. - Block handles mirror in right-to-left text, centre on a code block's first line and a table's first row, and use stronger icons. On touch screens the grip has a 44px target and the toolbar's + replaces the gutter's. HTML and embed blocks drop their second, legacy drag grip. - Tab from the block menu, Turn into, or More formatting closes the menu back into the editor, and Escape in an HTML block's source selects the block. In a linked table cell, the link preview shows instead of the table toolbar it used to cover. - The link editor fits a phone screen, and the image toolbar's buttons share one radius and pressed style. - The featured image card switches to its compact layout by its own width, so its actions no longer clip at tablet and laptop widths.
…nd on insert - A list nested in a list of the other type reports its own type, so Turn into, the toolbar, and the slash menu switch just that list, and the toolbar no longer shows both list buttons pressed. Turning a list off moves the item up one level, as TipTap's toggles did. - Inserting a block from an empty list item or quote line turns that line into the block instead of leaving it behind, where it was saved as an empty bullet or quote line. Typing --- in one does the same. - A block inserted with the caret in a heading, code block, or other text goes after it instead of splitting it, and is scrolled into view. - A new numbered list doesn't join a following list that starts at its own number. - TipTap's block shortcuts (Mod+Shift+7/8/B, Mod+Alt+1-6/C) convert the way the toolbar does; Mod+Shift+B in a list item had fallen through to bold. Alignment buttons show no pressed state where they're disabled.
A link the editor refuses, such as javascript:, kept its field open with no explanation. The selection toolbar, the image toolbar, and the fixed toolbar's link fields now mark the field invalid and say the link can't be used, until it's edited. localhost:3000 and example.com:8080 were read as URL schemes and refused; they get https:// like other bare hosts.
- Opening Turn into while More formatting is open, or the reverse, now takes one click; the closing menu reset the opening one. - Selected links, inline code, and highlighted code keep their colours. - A selected HTML block or embed has one frame, the editor's, instead of its own brand border inside it. - The image toolbar clears the selected image's frame. - Remove link looks the same in the link editor and the link preview. - The featured image card wraps its actions when long labels don't fit on one line, instead of hiding them in a hidden scroller. - The toolbar's table control is 44px wide on touch screens, like the other buttons.
- A divider added from the last line of a list or quote at the end of the document left an extra empty paragraph and the caret between blocks; TipTap's command misplaces it there. Dividers from the slash menu and from --- in a list or quote now replace the empty line and put the caret in the text after them. - Toggling a list's type off with the whole list selected did nothing, because there's no single item to lift; it now turns the list back into text. - tel:5551234 and sms:12345 were read as host:port and given https://. Only localhost and dotted hosts with a port get it now.
The test slept 300 ms and checked the toolbar was absent, which a slow runner could pass even if the toolbar came back after its 120 ms update delay. Show it first, then wait for it to go.
The click handler skips every place ProseMirror would put a gap cursor, which includes the start of a document that opens with an embed, not only the space between two embeds.
The click calls TipTap's focus command, which on Chromium moves focus in the next animation frame, so checking it right after the click depended on a frame having already passed.
danielmlr
left a comment
There was a problem hiding this comment.
Thanks, Noah. I ran the latest commit (32087e8) on a local site alongside main and clicked through it at 1440, 1024 and 390 px, in light, dark and Arabic. A lot of it works well: Turn into is a single undo step, selecting a block with Escape and moving around with the arrow keys feels natural, the slash menu finds the right command quickly, right-to-left works throughout, existing content saves back unchanged, and typing in a 361-block document is as fast as on main.
Three things can change saved content or publishing state without the user meaning to, and two more are worth a look. I think all five are worth fixing before merge (details inline):
- Clicking + on a published entry creates a draft.
- Relative links such as
../about.htmlor./guide.pdfare saved withhttps://in front. - Pasting a quote that contains a heading leaves an empty quote behind, and the quoted paragraphs lose their quote formatting. A heading inside a list item leaves an empty bullet.
- At 390 px the entry title disappears from the bar when the button says "Unpublish" or "Publish changes".
- The page layout only applies to a Portable Text field named
content, so sites that usebody, our e2e fixture among them, don't get it.
It'd be good to document the keyboard changes, so editors know how to control the editor: Enter and the arrow keys between the title and the body, Escape to select a block and the arrow keys to move between blocks, Select All taking the current block first, Alt-click on +, and the block menu. The changeset covers them for people upgrading, but the "Write rich text" section of the user guide (docs/src/content/docs/guides/working-with-content.mdx) doesn't mention them yet. A short paragraph or a small table of keys there would do.
Not blocking:
- Turning a paragraph into a list right below another list can leave the wrong block selected (inline).
- A few renamed labels will lose their existing translations (inline).
- Was it intentional to drop Headings 4 to 6 from the block menu's Turn into? Main listed them; now they only show when the block already is one.
- #3827 changes the same parts of
PortableTextEditor.tsx, so it might be worth agreeing which one goes first.
Lint, typecheck and 45 admin test files (1,080 tests) pass locally; I didn't run the e2e suite.
| // the previous locale's body in the editor and silently overwrites | ||
| // the new translation on the next edit. | ||
| const fieldKey = `${name}:${item?.id ?? "new"}`; | ||
| const isDocumentBody = field.kind === "portableText" && name === "content"; |
There was a problem hiding this comment.
Only a Portable Text field named content gets the page layout. A collection whose body field is called body, like our e2e fixture's posts and pages, gets the new bar with the old boxed editor, and Enter in the title saves instead of moving into the body. Nothing tells the user why it behaves differently. Since the fixture uses body, the e2e tests and the new visual baselines never show the new layout. Would a collection setting, or the first Portable Text field after the title, work better?
~ 🤖 Claude Code (Opus 5.5)
There was a problem hiding this comment.
Keeping content for this PR: it's main's existing rule for the document outline, and choosing another field would change the layout on existing sites without them opting in. A collection setting for the page field would make a good follow-up.
The + button types a slash line to open the slash menu, and the editor reported that line as an edit right away, so a 2-second autosave saved it while the menu was open, turning a published entry into a draft. Changes now wait until the menu closes. When + typed into an empty line that was already there, the slash's undo step was left behind after the menu closed, so the first Undo did nothing. That slash now stays out of the undo history, as its removal already did.
A link such as ../about.html, ./guide.pdf, or docs/guide.pdf looked like a bare domain, so it was saved with https:// in front. Paths starting with ./ or ../, or with a slash before the first dot, now stay as typed.
Pasting a quote holding a heading left an empty quote behind, and the quoted paragraphs after the heading lost their quote. A heading in a list item left an empty bullet, and a numbered list continued after it as a bulleted one. The pasted HTML is now split around such blocks first, so the block lands between the two halves, and a numbered list keeps counting. The existing paste test now pastes into an empty line: pasted content that starts with a heading merges into a line that has text, as any ProseMirror paste does.
Turning a selected block into a list beside a list of the same type joins the two, which moves the block, but Turn into reselected the block's old position. That selected the paragraph inside the joined list, so typing replaced its text. The joined list is now selected.
Paragraph, Bullet List, Numbered List, Code Block, and Inline Code were renamed to Text, Bulleted list, Numbered list, Code block, and Inline code, which are new strings for translators, so about 30 locales showed them in English. The existing labels and their translations are back. The slash menu still finds /text and /bulleted.
Closing the + menu with Escape, Tab, or a click elsewhere left the new empty line in the document, which is still an edit, so autosave turned a published entry into a draft. The line now goes again, and when it is still the last change, its undo step goes with it, so the next Undo undoes the edit before it. A picker command that removes the line, and a command run in an empty line that was already there, no longer leave an undo step that does nothing either. This replaces keeping a reused line's slash out of the undo history, which left a slash that Undo couldn't remove when a query was kept.
In a narrow bar, as on a phone, Publish now, Publish changes, and Unpublish with the collection name kept their full labels and squeezed the entry title down to a few letters. There, both publish labels read Publish, and Unpublish shows only its icon like the bar's other secondary buttons; all keep their full names for screen readers.
danielmlr
left a comment
There was a problem hiding this comment.
Thanks, Noah, this looks great!
Everything I raised is fixed, and keeping content as the page field makes sense.
A short note on the new keys in the user guide would be nice later on.
…m-uploads-8f5d39 Brings in the page layout for the content editor (#3710). Its slash command list now builds each built-in top-level block from a module-scope command wrapped by topLevelInsert, so Video follows that pattern: a videoSlashCommand in Media, added after Gallery so the category stays together for the arrow keys, and left out when a plugin defines its own video block.
The empty-blockquote placeholder test from #3690 expected the document placeholder, but #3710 had already made an empty quote paragraph show "Quote". Both merged cleanly, and the test has failed Browser Tests on main since. Expect "Quote", which still proves that the blockquote p::before rule does not hide the placeholder.
What does this PR do?
Lays out the admin's content editor as a page, closer to Notion, while keeping every existing editor feature and Kumo's look.
Page
contentPortable Text field uses a newdocumentvariant:boxed) editor and its prose typography.Blocks
/quote, an input rule, an insert, paste, or a drop) and was dropped on save. Now it lands beside the quote or list. Pasted HTML is split around such a block first, so no empty quote or bullet is left behind and a numbered list keeps counting after it. Alignment is offered only where it's saved.Menus
/blfinds Bullet List). Each command shows its Markdown hint, and a footer describes the highlighted command. Headings 4 to 6 appear when you search for them.example.comor a host such aslocalhost:3000is linked withhttps://, a relative path such as../about.htmlstays as typed, and a link the editor won't apply keeps its field open and says why.editor/EditorMenu.tsx, built on Base UI's menu so submenus and icons use logical spacing in RTL.PortableTextEditorgains avariantprop ("boxed"by default, or"document") and anonArrowUpAtStartcallback. Both are additive.CI and test reliability
This PR changes
ci.yml, so CI runs the full test plan on it. These fix the failures and flakes that surfaced:publish-autosave-race, which keeps advancing fake time until the autosave arrives.plugin-types: the exhaustive capabilities round-trip gets a 60-second timeout. It timed out at 20 seconds on CI and takes about 4 seconds locally.Keyboard shortcut hints and new shortcuts are left for a follow-up.
The editor screens' visual-regression baselines change with this layout.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
Screenshots / test output
The sample post, before (main) and after, at 1440×900 unless noted.
Tests: the admin suite passes. The new tests cover: