Repository navigation
feat(page-builder): keep block rich text to basic formatting - #216
Merged
Merged
Conversation
Page blocks used the documentation profile, so their rich text took images, tabs, steps, callouts and every other text-editor block. A page text profile now drives the builder's editor, the renderer, validation and Markdown page files, and the JSON Schema and MCP update_page describe it, so agents see only what is allowed and saves refuse the rest.
…ofile A draft holding an image or docs block made the page GET fail (the draft-status hash validates) and would make the site renderer throw. toPageText cuts such text down to the profile: the builder cleans every rich-text setting on load, so its first save stores a valid layout, the renderer shows only what the profile holds, and the status check treats an invalid draft as changed instead of failing.
Every page rich-text field now hides the editor toolbar, as most already did; formatting comes from the selection menu, the / menu and Markdown shortcuts.
tokens.css set light-only colours on .tiptap-editor and the portaled menus, overriding a dark host's tokens: links (var(--primary)) rendered dark on dark and the toolbar stayed white. Add the matching dark set under .dark.
Escape in the text closes the menu until the selection changes (a dismissed flag in the plugin's shouldShow, so refocusing doesn't reopen it). Alt-F10 with text selected shows it at once and focuses it; it is a labelled toolbar with arrow/Home/End movement, aria-pressed on mark buttons, Escape back to the text and from the link field to its button.
Alt+F10 often never reaches the page: laptop F-rows default to hardware keys and GPU overlays (NVIDIA Instant Replay) take it. Mod-Shift-Space does the same: formatting menu, table bar or block controls. Documented in the README keyboard table, the docs site and the package AGENTS.md.
Font preload never reached the HTML on any hosted site: the tenant layout called react-dom preload() after the root layout's <head> had streamed, so the hint only went into the RSC payload and the browser acted on it after the scripts ran. Render the <link rel=preload> tags instead; React hoists them into the head (verified in a production build). Public pages loaded the editor's whole Tailwind build (@frontlit/text-editor/styles.css: toolbar, menus, block settings) and scanned editor-only files for utilities. Import prose.css only and skip the editor-only files: 276.5 KB -> 262.6 KB raw (43.0 -> 40.0 KB gzip) of CSS per page, with identical computed styles on the home and docs pages (every element compared).
Theme link styles are made for navigation (no-underline, hover:underline), so a link inside a sentence was marked only by font weight (WCAG 1.4.1) and looked different from the editor, which underlines. The renderer now always adds underline underline-offset-4 after the theme's classes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Page blocks used the
documentationtext-editor profile, so their rich text offered and accepted images, tables, tabs, steps, callouts, cards, buttons, web previews and H5P. Pages already have Media, Embed and other blocks for those.This adds one
pageTextProfilein@frontlit/page-builder/schemaand uses it everywhere page rich text is handled.Allowed:
Not allowed: H1 (the block title is the heading), tables, underline and highlight (no Markdown form), and all text-editor blocks.
RichTextField)documentationprofilepageTextProfile; the/menu, Insert menu and text styles only list allowed itemsTextRendererwith thedefaultprofilePageTextwithpageTextProfilecanonicalizeLayout)validateContent(pageTextProfile)parseMarkdownandserializeMarkdownwithpageTextProfilePAGE_TEXT_FORMATinpage.v1.jsonand the MCPupdate_pagedescription; the Pages-from-Git docs updated tooAgents are told only the allowed format. Anything else is refused on save with a located message, for example
/layout/1/settings/text Unsupported node: tabs.orline 1: Images are not allowed here.The public
TextRendererre-export from@frontlit/page-builder/componentsis unchanged, becauseapps/webuses it for documentation content.Content saved before this change
Rich text already holding an image, docs block, H1, underline or highlight no longer validates. Before the fix, opening such a page returned 500, because the draft-status hash validates the draft. QA's "My Team" homepage has an image in its hero description.
toPageTextcuts that content down to what the profile allows: it drops nodes and marks outside it and moves headings into 2–4.PageTextrenders only what the profile allows, so a published revision with old content still renders.published_with_changesinstead of failing.Writes from REST, MCP and Git stay strict.
Editor follow-ups from local testing
/menu and Markdown shortcuts. Six of the nine fields already hid it; Rich text, Content and Grid now do too.tokens.cssonly had light colours, set directly on the editor, so links were dark on dark and the toolbar stayed white. Added a matching dark set under.dark.aria-pressed.AGENTS.md.Public site: font preload and CSS
main.preload()from react-dom after the root layout's<head>had streamed, so the hint only went into the RSC payload (:HL[…]). The browser acted on it after the scripts ran.<link rel="preload" as="font">tags, which React hoists into<head>. Verified in a production build: the link is at byte ~1,300, before</head>at ~13,500.@frontlit/text-editor/styles.cssis a complete Tailwind build including the toolbar, menus and block settings, and Tailwind also scanned editor-only files.prose.cssonly and skips the editor-only files.v0.0.1build)Most of the remaining ~246 KB comes from page-builder styles, which #149 tracks.
Testing
#, tables, images,<Callout>,<Tabs>and H1 are rejected and basic content round-trips) and API pages/MCP (75);tscpasses for page-builder, api and web./menu shows only the Text section;/codesaves ("Draft saved") and renders in the canvas and on the published public page.update_pagecalls the sameupdatePageandcanonicalizeLayout.published).qa-pr216-a367f8a:/privacypage;tools/listshows the newupdate_pagedescription;update_pagewith a callout returns "Unsupported node: callout.".