Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/page-builder-lean-rich-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@frontlit/page-builder": minor
---

Rich text in page blocks is basic formatting only: paragraphs, headings 2–4, lists, quotes, code blocks, dividers and line breaks, with bold, italic, strikethrough, inline code and links. The editor no longer offers images, tables, tabs, steps, callouts or other text-editor blocks (pages have their own Media and Embed blocks), and saves, page files and the renderer refuse them, so no route (builder, REST, MCP or Git) can add them. `pageTextProfile` and `PAGE_TEXT_FORMAT` are exported from `@frontlit/page-builder/schema`, and the JSON Schema and MCP `update_page` describe the allowed format.
5 changes: 5 additions & 0 deletions .changeset/text-editor-dark-tokens.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@frontlit/text-editor": patch
---

The editor's fallback colour tokens have a dark set, used under a `.dark` ancestor. Links, the toolbar and the selection and `/` menus no longer keep light-theme colours in a dark host, where links were dark on dark.
7 changes: 7 additions & 0 deletions .changeset/text-editor-selection-menu-keyboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@frontlit/text-editor": patch
---

The selection formatting menu works from the keyboard. Escape in the text closes it until the selection changes. Alt+F10 with text selected moves focus into it, where ←/→/Home/End move between buttons and Escape returns to the text with the selection kept. Escape in its link field returns to the link button. It is a toolbar labelled "Text formatting", and its mark buttons report whether they are on (`aria-pressed`).

Ctrl/⌘+Shift+Space does what Alt+F10 does (formatting menu, table bar, block controls), for keyboards where Alt+F10 doesn't reach the page, such as laptop F-rows or GPU overlays that take it.
5 changes: 5 additions & 0 deletions .changeset/text-editor-underline-links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@frontlit/text-editor": patch
---

`TextRenderer` underlines links inside rich text whatever the theme's link style. Themes style links for navigation (often `no-underline` with `hover:underline`), which left links in a sentence marked only by a slightly heavier weight (WCAG 1.4.1). The theme's colour, weight and hover still apply; navigation links are unchanged.
4 changes: 2 additions & 2 deletions apps/api/src/mcp/tools/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from "./responses";
import { getTeamId } from "./auth";
import { omitInternal, serializeDates } from "../../utils/public";
import { PAGE_TEXT_FORMAT } from "@frontlit/page-builder/schema";
import { InvalidPageLayoutError } from "../../pages/shared-widgets";
import { PageOwnedByGitError } from "../../pages/git-pr";

Expand Down Expand Up @@ -119,8 +120,7 @@ export function registerPageTools(server: McpToolRegistrar): void {
server.registerTool(
"update_page",
{
description:
"Updates a page's metadata (name, SEO) and/or its block layout. Writes only the page's draft state — call publish_page to make changes live. Block settings are validated against the block schemas (https://frontlit.app/schema/page.v1.json describes them; rich text there is Markdown, here TipTap JSON) and stored in canonical form, with settings equal to a block default omitted.",
description: `Updates a page's metadata (name, SEO) and/or its block layout. Writes only the page's draft state — call publish_page to make changes live. Block settings are validated against the block schemas (https://frontlit.app/schema/page.v1.json describes them; rich text there is Markdown, here TipTap JSON) and stored in canonical form, with settings equal to a block default omitted. Rich text holds only basic formatting; anything else is rejected. ${PAGE_TEXT_FORMAT}`,
inputSchema: {
pageId: z.string(),
name: z.string().optional(),
Expand Down
12 changes: 9 additions & 3 deletions apps/api/src/pages/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ export function derivePageStatus(
entry: ReleaseEntry | null,
): PageStatus {
if (!entry) return "draft";
return pageRevisionFile(draftDocument(page)).hash === entry.revision.hash
? "published"
: "published_with_changes";
try {
return pageRevisionFile(draftDocument(page)).hash === entry.revision.hash
? "published"
: "published_with_changes";
} catch {
// A draft saved before a schema change no longer validates; it can't
// equal a release, and the page must still open so it can be fixed.
return "published_with_changes";
}
}

async function getRawPageByPageId(pageId: string) {
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/content/docs/components/text-editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ that small theme shape instead of importing `@frontlit/page-builder`, so this pa

Type `/` in the editor to insert a block; the menu filters as you type. Hover a block to drag it by its
handle, and open a block's settings from the gear on its bar. From the keyboard, Ctrl/⌘+Shift+↑/↓ moves the
block at the cursor, Alt+F10 jumps to its controls and Escape returns to its text. In a table, a bar
above it inserts and deletes rows and columns; Alt+F10 reaches it too.
block at the cursor, Alt+F10 (or Ctrl/⌘+Shift+Space) jumps to its controls, or to the formatting menu when
text is selected, and Escape returns to its text. In a table, a bar above it inserts and deletes rows and
columns; the same keys reach it too.

A **profile** lists what a document can hold: base nodes and marks, blocks and size limits. One profile
builds the editor, the renderer, a Markdown parser and serializer, a validator and a format reference.
Expand Down
5 changes: 4 additions & 1 deletion apps/docs/content/docs/developers/pages-from-git.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ A page file:
- `layout` lists blocks top to bottom. A block's `settings` only needs what
differs from the block's defaults; the JSON Schema documents every setting and
its default.
- Rich-text settings are Markdown (CommonMark + GFM).
- Rich-text settings are Markdown with basic formatting only: paragraphs,
`##` to `####` headings, lists, quotes, code blocks, `---` dividers, bold,
italic, strikethrough, inline code and links. Tables, images, raw HTML and
`<Block>` tags are rejected; use page blocks for media and embeds.
- Media is `{ "url", "alt" }`. The URL is an `https://` URL, or a path in the
repository (no scheme), relative to the file or to the repository root when
it starts with `/`; FrontLit uploads the image when it syncs. `http://` and
Expand Down
14 changes: 14 additions & 0 deletions apps/sites/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

@source "../../../packages/page-builder/src";
@source "../../../packages/text-editor/src";
/* Editor-only UI: the site renders rich text, it never edits it. */
@source not "../../../packages/text-editor/src/editor.tsx";
@source not "../../../packages/text-editor/src/toolbar.tsx";
@source not "../../../packages/text-editor/src/bubble-menu.tsx";
@source not "../../../packages/text-editor/src/image-picker.tsx";
@source not "../../../packages/text-editor/src/components/link-editor-popover.tsx";
@source not "../../../packages/text-editor/src/components/docs-block-views.tsx";
@source not "../../../packages/text-editor/src/ui/block-frame.tsx";
@source not "../../../packages/text-editor/src/ui/library-ui.tsx";
@source not "../../../packages/text-editor/src/ui/media-picker.tsx";
@source not "../../../packages/text-editor/src/ui/slash-command.tsx";
@source not "../../../packages/text-editor/src/ui/table-bar.tsx";
@source not "../../../packages/text-editor/src/ui/insert-items.ts";
@source not "../../../packages/text-editor/src/ui/editor-extensions.tsx";

@layer base {
* {
Expand Down
5 changes: 4 additions & 1 deletion apps/sites/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import "@frontlit/text-editor/styles.css";
// Rich-text reading styles only. The package's styles.css is a whole
// Tailwind build for the editor (toolbar, menus, block settings); the site
// compiles its own utilities (globals.css).
import "@frontlit/text-editor/prose.css";
import "./globals.css";
import { fontCss } from "@/lib/font-css";
import { ColorModeProvider } from "@/components/color-mode-provider";
Expand Down
27 changes: 20 additions & 7 deletions apps/sites/app/sites/[teamId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Metadata } from "next";
import { preload } from "react-dom";
import { BUILD_TEAM_ID, getSettings } from "@/lib/api";
import { themeFontPreloads } from "@/lib/font-css";
import { loadSiteTheme } from "@/lib/load-site-theme";
Expand Down Expand Up @@ -51,11 +50,25 @@ export default async function TenantLayout({
const { teamId } = await params;
const siteTheme = await loadSiteTheme(teamId);

// Only the fonts the active theme paints with are preloaded.
// Only the fonts the active theme paints with are preloaded. Rendered as
// tags, not `preload()` from react-dom: the root layout's <head> has gone
// out before this layout runs, and a late `preload()` only reaches the RSC
// payload, which the browser acts on after the scripts run. A `<link>` is
// hoisted into the head or, failing that, written into the HTML stream.
const { theme } = resolveSiteTheme(siteTheme.themeId, siteTheme.themeStyle);
for (const href of themeFontPreloads(theme)) {
preload(href, { as: "font", type: "font/woff2", crossOrigin: "anonymous" });
}

return children;
return (
<>
{themeFontPreloads(theme).map((href) => (
<link
key={href}
rel="preload"
href={href}
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
))}
{children}
</>
);
}
18 changes: 9 additions & 9 deletions packages/page-builder/schema/page.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"buttonCaption": {
"type": "string",
Expand Down Expand Up @@ -586,7 +586,7 @@
},
"body": {
"type": "string",
"description": "Markdown (CommonMark + GFM).",
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds).",
"default": "FrontLit brings your website, content, customer support, and audience engagement into one connected front office."
},
"media": {
Expand Down Expand Up @@ -827,7 +827,7 @@
},
"text": {
"type": "string",
"description": "Markdown (CommonMark + GFM).",
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds).",
"default": "Write anything here — an announcement, a longer explanation, or a passage of prose that doesn't need a title or media."
},
"alignment": {
Expand Down Expand Up @@ -1075,7 +1075,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"headerAlignment": {
"type": "string",
Expand Down Expand Up @@ -1359,7 +1359,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"headerAlignment": {
"type": "string",
Expand Down Expand Up @@ -2230,7 +2230,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"headerAlignment": {
"type": "string",
Expand Down Expand Up @@ -2868,7 +2868,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"buttonCaption": {
"type": "string",
Expand Down Expand Up @@ -3134,7 +3134,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"buttonCaption": {
"type": "string",
Expand Down Expand Up @@ -3388,7 +3388,7 @@
},
"description": {
"type": "string",
"description": "Markdown (CommonMark + GFM)."
"description": "Markdown: paragraphs, headings (## to ####), - and 1. lists, > quotes, ``` code blocks, --- dividers and line breaks (two trailing spaces), with **bold**, *italic*, ~~strike~~, `code` and [links](https://… or /path or mailto:…). Nothing else: no # headings, tables, images, raw HTML or <Block> tags (use page blocks for media and embeds)."
},
"buttonCaption": {
"type": "string",
Expand Down
10 changes: 5 additions & 5 deletions packages/page-builder/src/blocks/_shared/fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useId } from "react";
import { ImageIcon, Plus } from "lucide-react";
import { ImageUploadDialog } from "@frontlit/media-uploader";
import { Editor, emptyDoc } from "@frontlit/text-editor";
import { pageTextProfile, toPageText } from "../../schema/rich-text";
import { getMediaUrl, type Media } from "../../models/media";
import type { HeadingLevel, ResponsiveTextSize, TitleSettings } from "../../models";
import { cn } from "../../primitives/lib/utils";
Expand Down Expand Up @@ -96,24 +97,23 @@ export function RichTextField({
label,
value,
onChange,
showToolbar = true,
minHeight = 80,
}: {
label: string;
value?: any;
onChange: (value: any) => void;
showToolbar?: boolean;
minHeight?: 80 | 100 | 160;
}) {
return (
<div className="flex flex-col gap-1 text-sm">
<span className="font-medium text-foreground">{label}</span>
<Editor
profile="documentation"
initialContent={value ?? emptyDoc}
profile={pageTextProfile}
initialContent={value ? toPageText(value) : emptyDoc}
onChange={onChange}
debounceMs={150}
showToolbar={showToolbar}
// Formatting comes from the selection menu, "/" and Markdown shortcuts.
showToolbar={false}
editorClassName={RICH_TEXT_MIN_HEIGHT[minHeight]}
/>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/page-builder/src/blocks/banner/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function BannerEditor({
label="Description"
value={settings.description}
onChange={(description) => update({ description })}
showToolbar={false}
minHeight={80}
/>
</FieldGroup>
Expand Down
4 changes: 2 additions & 2 deletions packages/page-builder/src/blocks/banner/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ThemeStyle, WidgetProps } from "../../models";
import type { BannerSettings } from "./settings";
import { renderTitle, titleProps } from "../_shared/title";
import { NavLink } from "../../components/nav-link";
import { TextRenderer } from "../../components/text-renderer";
import { PageText } from "../../components/page-text";
import {
Button,
Header1,
Expand Down Expand Up @@ -49,7 +49,7 @@ export function BannerWidget({
</Header1>
{description && (
<Subheader1 theme={overriddenTheme} component="span">
<TextRenderer json={description} theme={overriddenTheme} />
<PageText json={description} theme={overriddenTheme} />
</Subheader1>
)}
</>
Expand Down
6 changes: 3 additions & 3 deletions packages/page-builder/src/blocks/content/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getMediaUrl, getMediaAlt } from "../../models/media";
import type { ContentSettings } from "./settings";
import { renderTitle, titleProps } from "../_shared/title";
import { Image } from "../../components/image";
import { TextRenderer } from "../../components/text-renderer";
import { PageText } from "../../components/page-text";
import { Header2, Section } from "../../primitives";

const roundedMap: Record<number, string> = {
Expand Down Expand Up @@ -83,7 +83,7 @@ export function ContentWidget({
{renderTitle(title, overriddenTheme)}
</Header2>
)}
{body && <TextRenderer json={body} theme={overriddenTheme} />}
{body && <PageText json={body} theme={overriddenTheme} />}
</div>
</div>
</div>
Expand Down Expand Up @@ -120,7 +120,7 @@ export function ContentWidget({
{renderTitle(title, overriddenTheme)}
</Header2>
)}
{body && <TextRenderer json={body} theme={overriddenTheme} />}
{body && <PageText json={body} theme={overriddenTheme} />}
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/page-builder/src/blocks/email-form/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function EmailFormEditor({
label="Description"
value={settings.description}
onChange={(description) => update({ description })}
showToolbar={false}
minHeight={80}
/>
</FieldGroup>
Expand Down
4 changes: 2 additions & 2 deletions packages/page-builder/src/blocks/email-form/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from "clsx";
import type { ThemeStyle, WidgetProps } from "../../models";
import type { EmailFormSettings } from "./settings";
import { renderTitle, titleProps } from "../_shared/title";
import { TextRenderer } from "../../components/text-renderer";
import { PageText } from "../../components/page-text";
import { Header1, Section, Subheader1 } from "../../primitives";
import { EmailForm } from "./form";

Expand Down Expand Up @@ -33,7 +33,7 @@ export function EmailFormWidget({

const descriptionNode = description && (
<Subheader1 theme={overriddenTheme} component="span">
<TextRenderer json={description} theme={overriddenTheme} />
<PageText json={description} theme={overriddenTheme} />
</Subheader1>
);

Expand Down
1 change: 0 additions & 1 deletion packages/page-builder/src/blocks/featured/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function FeaturedEditor({
label="Description"
value={settings.description}
onChange={(description) => update({ description })}
showToolbar={false}
minHeight={80}
/>
<SelectField
Expand Down
Loading
Loading